From 6a4ff370594d6af6f2c78474f25e928488c8c59b Mon Sep 17 00:00:00 2001 From: Martina Date: Tue, 8 Jun 2021 12:42:29 -0700 Subject: [PATCH] edited default routing page for activity and headers --- common/navigation-data.js | 4 + components/core/WebsitePrototypeHeader.js | 4 +- .../core/WebsitePrototypeHeaderGeneric.js | 104 ------------------ scenes/SceneActivity.js | 30 +++-- 4 files changed, 19 insertions(+), 123 deletions(-) delete mode 100644 components/core/WebsitePrototypeHeaderGeneric.js diff --git a/common/navigation-data.js b/common/navigation-data.js index 3da274a5..6781dcbf 100644 --- a/common/navigation-data.js +++ b/common/navigation-data.js @@ -34,6 +34,10 @@ export const getByHref = (href, viewer) => { return { page: { ...activityPage } }; } + if (viewer && pathname === "/_/auth") { + return { page: { ...activityPage } }; //NOTE(martina): authenticated users should be redirected to the home page rather than the + } + let page = navigation.find((each) => pathname.startsWith(each.pathname)); let details; diff --git a/components/core/WebsitePrototypeHeader.js b/components/core/WebsitePrototypeHeader.js index e8e3f26e..5bafbffa 100644 --- a/components/core/WebsitePrototypeHeader.js +++ b/components/core/WebsitePrototypeHeader.js @@ -195,7 +195,7 @@ const WebsitePrototypeHeader = (props) => { }; const communityURL = "https://github.com/filecoin-project/slate"; - const signInURL = "/_/auth"; + const signInURL = "/_/auth?tab=signin"; const styleMenu = open ? openMenu : null; const styleBurgerBun = open ? openBurgerBun : null; const styleBurgerBun2 = open ? openBurgerBun2 : null; @@ -227,7 +227,7 @@ const WebsitePrototypeHeader = (props) => { Get involved - Sign in + Use Slate diff --git a/components/core/WebsitePrototypeHeaderGeneric.js b/components/core/WebsitePrototypeHeaderGeneric.js deleted file mode 100644 index 5a89cf33..00000000 --- a/components/core/WebsitePrototypeHeaderGeneric.js +++ /dev/null @@ -1,104 +0,0 @@ -import * as React from "react"; -import * as Constants from "~/common/constants"; -import * as SVGLogo from "~/common/logo"; - -import { css } from "@emotion/react"; - -const STYLES_ROOT = css` - padding: 24px 88px 24px 64px; - width: 100%; - margin: 0 auto; - z-index: ${Constants.zindex.header}; - - @media (max-width: ${Constants.sizes.mobile}px) { - padding: 16px 24px; - } -`; - -const STYLES_CONTAINER = css` - max-width: 1440px; - margin: 0 auto; - font-family: ${Constants.font.text}; - font-weight: 400; - font-size: ${Constants.typescale.lvl1}; - width: 100%; -`; - -const STYLES_NAV_CONTAINER = css` - display: flex; - justify-content: space-between; - margin-bottom: 8px; -`; - -const STYLES_LINK = css` - color: ${Constants.system.grayBlack}; - text-decoration: none; - transition: 200ms ease color; - text-align: left; - display: block; - - :hover { - color: ${Constants.system.brand}; - } -`; - -const STYLES_PARAGRAPH = css` - font-family: ${Constants.font.text}; - color: ${Constants.system.pitchBlack}; - text-decoration: none; - transition: 200ms ease color; - overflow-wrap: break-word; - max-width: 50%; - min-width: 10%; - text-align: left; - margin-left: 30px; - display: block; - - @media (max-width: ${Constants.sizes.mobile}px) { - max-width: 100%; - } -`; - -const STYLES_LEFT = css` - flex-shrink: 0; - display: flex; - max-width: 70%; -`; - -const STYLES_RIGHT = css` - min-width: 10%; - width: 100%; - display: flex; - justify-content: flex-end; - text-align: left; -`; - -const WebsitePrototypeHeaderGeneric = (props) => { - return ( -
-
-
-
- - - - - {props.title} - -
-
- - Sign up - - - Sign in - -
-
-
{props.children}
-
-
- ); -}; - -export default WebsitePrototypeHeaderGeneric; diff --git a/scenes/SceneActivity.js b/scenes/SceneActivity.js index cdac2290..b9ac4a0f 100644 --- a/scenes/SceneActivity.js +++ b/scenes/SceneActivity.js @@ -216,6 +216,17 @@ export default class SceneActivity extends React.Component { window.removeEventListener("scroll", this.scrollDebounceInstance); } + getTab = () => { + const tab = this.props.page.params?.tab; + if (tab) { + return tab; + } + if (this.props.viewer.following?.length || this.props.viewer.subscriptions?.length) { + return "activity"; + } + return "explore"; + }; + _handleScroll = (e) => { if (this.state.loading) { return; @@ -239,14 +250,7 @@ export default class SceneActivity extends React.Component { fetchActivityItems = async (update = false) => { if (this.state.loading === "loading") return; - let tab = this.props.page.params?.tab || "explore"; - // if (!tab) { - // if (this.props.viewer) { - // tab = "activity"; - // } else { - // tab = "explore"; - // } - // } + let tab = this.getTab(); const isExplore = tab === "explore"; this.setState({ loading: "loading" }); let activity; @@ -359,16 +363,8 @@ export default class SceneActivity extends React.Component { }; render() { - let tab = this.props.page.params?.tab || "explore"; - // if (!tab) { - // if (this.props.viewer) { - // tab = "activity"; - // } else { - // tab = "explore"; - // } - // } + let tab = this.getTab(); let activity; - if (this.props.viewer) { activity = tab === "activity" ? this.props.viewer?.activity || [] : this.props.viewer?.explore || [];