From 44127d77f486bcf85682a118a327745c26695f82 Mon Sep 17 00:00:00 2001
From: srgooglo <38926803+srgooglo@users.noreply.github.com>
Date: Sun, 16 Feb 2020 17:20:14 +0100
Subject: [PATCH] 0.1.16-T1 Layout Update
---
globals/endpoints.js | 3 +-
package.json | 2 +-
src/@ycore/libs/comty_ng/pre.js | 74 ++++-----
src/components/Layout/Sider.less | 14 +-
src/components/LikeBtn/index.js | 22 +++
src/components/LikeBtn/index.scss | 214 +++++++++++++++++++++++++
src/components/MainFeed/index.js | 89 ++++++++++
src/components/MicroHeader/index.js | 53 ++++++
src/components/MicroHeader/index.less | 23 +++
src/components/PostCard/index.js | 18 +--
src/components/PostCreator/index.js | 23 ++-
src/components/UserProfile/index.js | 48 ++----
src/components/UserProfile/styles.less | 31 ++--
src/components/index.js | 5 +-
src/layouts/BaseLayout.js | 5 -
src/layouts/BaseLayout.less | 4 +-
src/layouts/PrimaryLayout.js | 5 +-
src/layouts/PrimaryLayout.less | 10 +-
src/pages/main/index.js | 47 +-----
src/pages/settings/style.less | 17 +-
20 files changed, 530 insertions(+), 177 deletions(-)
create mode 100644 src/components/LikeBtn/index.js
create mode 100644 src/components/LikeBtn/index.scss
create mode 100644 src/components/MainFeed/index.js
create mode 100644 src/components/MicroHeader/index.js
create mode 100644 src/components/MicroHeader/index.less
diff --git a/globals/endpoints.js b/globals/endpoints.js
index 6f9faf8f..8d2ba07c 100644
--- a/globals/endpoints.js
+++ b/globals/endpoints.js
@@ -1,6 +1,6 @@
module.exports = {
Endpoints: {
- get_user_posts: "https://api.ragestudio.net/RS-YIBTP/yid/posts?access_token=",
+ get_posts: "https://api.ragestudio.net/RS-YIBTP/yid/posts?access_token=",
find_user: "https://api.ragestudio.net/RS-YIBTP/yid/find_user?access_token=",
search_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/search?access_token=",
get_sessions: "https://api.ragestudio.net/RS-YIBTP/yid/session_id?access_token=",
@@ -12,7 +12,6 @@ module.exports = {
get_marketplace_global: "https://api.ragestudio.net/RS-YIBTP/rs/marketplaceHandler?access_token=",
get_config_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/get-site-settings?access_token=",
get_userData_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/get-user-data?access_token=",
- get_userPostFeed: "https://api.ragestudio.net/RS-YIBTP/yid/posts?access_token=",
update_userData_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/update-user-data?access_token=",
removeToken: "https://api.ragestudio.net/RS-YIBTP/yid/delete-access-token?access_token=",
register_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/create-account",
diff --git a/package.json b/package.json
index ac7dbc16..e3174f80 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "comty-development",
"title": "Comty™",
"DevBuild": true,
- "version": "0.1.15",
+ "version": "0.1.16",
"description": "",
"main": "index.js",
"author": "RageStudio",
diff --git a/src/@ycore/libs/comty_ng/pre.js b/src/@ycore/libs/comty_ng/pre.js
index 615309e4..c37f2403 100644
--- a/src/@ycore/libs/comty_ng/pre.js
+++ b/src/@ycore/libs/comty_ng/pre.js
@@ -49,47 +49,39 @@ export function SeachKeywords(key, callback){
})
}
-export function GetUserPosts(id, callback) {
- let formdata = new FormData();
- formdata.append("server_key", ycore.yConfig.server_key);
- formdata.append("type", "get_user_posts");
- formdata.append("id", id)
- const urlOBJ = `${ycore.endpoints.get_user_posts}${ycore.GetUserToken.decrypted().UserToken}`
- const settings = {
- "url": urlOBJ,
- "method": "POST",
- "timeout": 10000,
- "processData": false,
- "mimeType": "multipart/form-data",
- "contentType": false,
- "data": formdata
- };
- jquery.ajax(settings)
- .done(function (response) {
- return callback(null, response);
- })
- .fail(function (response) {
- const exception = 'Request Failed';
- return callback(exception, response);
- })
-}
-
-export function GetFeedPosts(callback) {
- let formdata = new FormData();
- formdata.append("server_key", ycore.yConfig.server_key);
- formdata.append("type", "get_news_feed");
- const requestOptions = {
- method: 'POST',
- body: formdata,
- redirect: 'follow'
- };
- const objUrl = `${ycore.endpoints.get_userPostFeed}${ycore.GetUserToken.decrypted().UserToken}`
- fetch(objUrl, requestOptions)
- .then(response => response.text())
- .then(result => {
- return callback( null, result)
- })
- .catch(error => console.log('Load Post error => ', error))
+export function GetPosts(userid, type, callback) {
+ let formdata = new FormData();
+ formdata.append("server_key", ycore.yConfig.server_key);
+ switch (type) {
+ case 'feed':
+ formdata.append("type", "get_news_feed");
+ break;
+ case 'user':
+ formdata.append("type", "get_user_posts");
+ formdata.append("id", userid)
+ break;
+ default:
+ formdata.append("type", "get_news_feed");
+ break;
+ }
+ const urlOBJ = `${ycore.endpoints.get_posts}${ycore.GetUserToken.decrypted().UserToken}`
+ const settings = {
+ "url": urlOBJ,
+ "method": "POST",
+ "timeout": 10000,
+ "processData": false,
+ "mimeType": "multipart/form-data",
+ "contentType": false,
+ "data": formdata
+ };
+ jquery.ajax(settings)
+ .done(function (response) {
+ return callback(null, response);
+ })
+ .fail(function (response) {
+ const exception = 'Request Failed';
+ return callback(exception, response);
+ })
}
export const get_app_session = {
diff --git a/src/components/Layout/Sider.less b/src/components/Layout/Sider.less
index bb84ef16..18da473f 100644
--- a/src/components/Layout/Sider.less
+++ b/src/components/Layout/Sider.less
@@ -63,6 +63,7 @@
}
.brand {
+ cursor: pointer;
img{
display: flex;
vertical-align: middle;
@@ -72,11 +73,7 @@
max-height: 58px;
}
}
-.brand:hover{
- img{
- size: 9cm;
- }
-}
+
.avatarFull{
width: 120px;
@@ -92,7 +89,6 @@
bottom: 0;
position: absolute;
width: 100%;
-
}
}
.siderhead{
@@ -120,6 +116,9 @@
.ant-layout-sider-dark {
background-color: @LDarkMode-backgroud;
color: @DarkMode-color;
+ h2{
+ color: @Theme-SiderDeco-Color;
+ }
.ant-menu-item{
color: @DarkMode-color;
}
@@ -134,6 +133,9 @@
.ant-layout-sider-light {
background-color: @Theme-SiderDeco-Backgroud;
color: @Theme-SiderDeco-Color;
+ h2{
+ color: @Theme-SiderDeco-Color;
+ }
.ant-menu-item{
color: @Theme-SiderDeco-Color;
}
diff --git a/src/components/LikeBtn/index.js b/src/components/LikeBtn/index.js
new file mode 100644
index 00000000..edf2687c
--- /dev/null
+++ b/src/components/LikeBtn/index.js
@@ -0,0 +1,22 @@
+import React from 'react'
+import styles from './index.scss'
+import classnames from 'classnames'
+
+class LikeBTN extends React.PureComponent {
+ render(){
+ const { active } = this.props
+ return(
+
+ )
+ }
+}
+
+export default LikeBTN
\ No newline at end of file
diff --git a/src/components/LikeBtn/index.scss b/src/components/LikeBtn/index.scss
new file mode 100644
index 00000000..668c2104
--- /dev/null
+++ b/src/components/LikeBtn/index.scss
@@ -0,0 +1,214 @@
+.like_button, .like_button:before, .like_button:after {
+ position: relative;
+ box-sizing: border-box;
+ }
+ .ripple, .ripple:before, .ripple:after {
+ position: relative;
+ box-sizing: border-box;
+ }
+
+ :root {
+ --color-heart: #EA442B;
+ --easing: cubic-bezier(.7,0,.3,1);
+ --duration: .5s;
+ }
+
+
+ .like_button {
+ font-size: 40px;
+ border: none;
+ border-radius: 50%;
+ background: white;
+ width: 1em;
+ height: 1em;
+ padding: 0;
+ margin: 0;
+ outline: none;
+ z-index: 2;
+ transition: transform var(--duration) var(--easing);
+ cursor: pointer;
+
+ &:before {
+ z-index: -1;
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ border-radius: inherit;
+ transition: inherit;
+ }
+
+ &:after {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: #fff;
+ border-radius: inherit;
+ z-index: -1;
+ }
+
+ &:active {
+ &:before {
+ animation: depress-shadow var(--duration) var(--easing) both;
+ }
+ }
+
+ &:focus:after {
+ animation: depress var(--duration) var(--easing) both;
+ }
+
+ @keyframes depress {
+ from, to {
+ transform: none;
+ }
+ 50% {
+ transform: translateY(5%) scale(0.9);
+ }
+ }
+
+ @keyframes depress-shadow {
+ from, to {
+ transform: none;
+ }
+ 50% {
+ transform: scale(0.5);
+ }
+ }
+ }
+
+ .like_wrapper {
+ display: grid;
+ align-items: center;
+ justify-content: center;
+ z-index: 1;
+ > * {
+ margin: auto;
+ grid-area: 1 / 1;
+ }
+ }
+
+ .heart {
+ width: .5em;
+ height: .5em;
+ display: block;
+
+ > path {
+ stroke: var(--color-heart);
+ stroke-width: 2;
+ fill: transparent;
+ transition: fill var(--duration) var(--easing);
+
+ .like_button:focus & {
+ fill: var(--color-heart);
+ }
+ }
+
+ transform-origin: center 80%;
+ &.activated{
+ animation: heart-bounce var(--duration) var(--easing);
+ @keyframes heart-bounce {
+ 40% { transform: scale(0.7); }
+ 0%, 80%, 100% { transform: scale(1); }
+ }
+ }
+ .like_button:focus & {
+ animation: heart-bounce var(--duration) var(--easing);
+ @keyframes heart-bounce {
+ 40% { transform: scale(0.7); }
+ 0%, 80%, 100% { transform: scale(1); }
+ }
+ }
+ }
+
+ /* Added wrapper to prevent layout jank with resizing particles */
+ .particles {
+
+ width: 100%;
+ height: 100%;
+ }
+
+ .particle {
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: .1em;
+ width: .1em;
+ border-radius: .05em;
+ background-color: var(--color);
+ --percentage: calc( var(--i) / var(--total-particles) );
+ --Θ: calc( var(--percentage) * 1turn );
+ transform: translate(-50%, -50%) rotate( var(--Θ) ) translateY(0) scaleY(0);
+ transition: all var(--duration) var(--easing);
+
+ .like_button:focus & {
+ animation: particles-out calc(var(--duration) * 1.2) var(--easing) forwards;
+
+ @keyframes particles-out {
+ 50% {
+ height: .3em;
+ }
+ 50%, 60% {
+ height: .3em;
+ transform:
+ translate(-50%, -50%)
+ rotate( var(--Θ) )
+ translateY(.8em)
+ scale(1)
+ ;
+ }
+ 60% {
+ height: .2em;
+ }
+ 100% {
+ transform:
+ translate(-50%, -50%)
+ rotate( var(--Θ) )
+ translateY(1em)
+ scale(0)
+ ;
+ }
+ }
+ }
+ }
+
+ .ripple {
+ height: 1em;
+ width: 1em;
+ border-radius: 50%;
+ overflow: hidden;
+ z-index: 1;
+
+ &:before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ border: .4em solid var(--color-heart);
+ border-radius: inherit;
+ transform: scale(0);
+ }
+
+ .like_button:focus & {
+ &:before {
+ animation: ripple-out var(--duration) var(--easing);
+ @keyframes ripple-out {
+ from { transform: scale(0); }
+ to { transform: scale(5); }
+ }
+ }
+ }
+ }
+
+
+ /* Reset the animation when clicking again! */
+ .like_button:focus {
+ pointer-events: none;
+ cursor: normal;
+ }
\ No newline at end of file
diff --git a/src/components/MainFeed/index.js b/src/components/MainFeed/index.js
new file mode 100644
index 00000000..1e0e7f53
--- /dev/null
+++ b/src/components/MainFeed/index.js
@@ -0,0 +1,89 @@
+import React from 'react'
+import * as antd from 'antd'
+import * as ycore from 'ycore'
+import {PostCard} from 'components'
+
+var userData = ycore.SDCP()
+
+export function RefreshFeed(){
+ ycore.DevOptions.ShowFunctionsLogs? console.log('Refreshing Feed...') : null
+ window.MainFeedComponent.handleRefreshList();
+ return
+}
+class MainFeed extends React.Component {
+ constructor(props){
+ super(props)
+ window.MainFeedComponent = this;
+ this.state = {
+ loading: true,
+ }
+ }
+ toogleLoader(){
+ this.setState({ loading: !this.state.loading })
+ }
+ componentDidMount(){
+ const { get, uid, filters } = this.props
+ if (!get) {
+ console.error('Please, fill params with an catch type...')
+ return
+ }
+ ycore.GetPosts(uid, get, (err, result) => this.setState({ feedRaw: result, loading: false }))
+ }
+ handleRefreshList(){
+ const { get, uid, filters } = this.props
+ if (!get) {
+ console.error('Please, fill params with an catch type...')
+ return
+ }
+ this.toogleLoader()
+ ycore.GetPosts(uid, get, (err, result) => this.setState({ feedRaw: result, loading: false }))
+ }
+ renderFeedPosts(e){
+ const {feedRaw} = this.state
+ const { get, filters } = this.props
+ try {
+ const feedParsed = JSON.parse(feedRaw)['data']
+ ycore.DevOptions.ShowFunctionsLogs? console.log(feedParsed) : null
+ return (
+ feedParsed.map(item=> {
+ const {id, postText, post_time, publisher, postFile, postFileName, is_liked, is_post_saved, is_post_reported, is_post_boosted, is_post_pinned, post_likes} = item
+ const paylodd = {
+ user: publisher.username,
+ ago: post_time,
+ avatar: publisher.avatar,
+ content: postText,
+ file: postFile,
+ postFileName: postFileName,
+ publisher: publisher,
+ post_likes: post_likes,
+ is_liked: is_liked,
+ is_post_saved: is_post_saved,
+ is_post_reported: is_post_reported,
+ is_post_boosted: is_post_boosted,
+ is_post_pinned: is_post_pinned,
+ }
+ return