From 9a4eb840a503c095c56503f3a0734e1c5ea4db48 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad Date: Thu, 9 Nov 2023 16:31:00 +0500 Subject: [PATCH] Finish navbar desktop + mobile --- .../widget/components/button/join-now.jsx | 73 +++++ apps/homepage/widget/propose.jsx | 2 +- apps/homepage/widget/section/hero.jsx | 3 + package.json | 2 +- src/App.js | 8 +- src/App.scss | 1 - src/components/navigation/Navbar.js | 253 ++++++++++++++++++ src/pages/SignInPage.js | 2 +- yarn.lock | 6 +- 9 files changed, 339 insertions(+), 11 deletions(-) create mode 100644 apps/homepage/widget/components/button/join-now.jsx create mode 100644 src/components/navigation/Navbar.js diff --git a/apps/homepage/widget/components/button/join-now.jsx b/apps/homepage/widget/components/button/join-now.jsx new file mode 100644 index 00000000..db597892 --- /dev/null +++ b/apps/homepage/widget/components/button/join-now.jsx @@ -0,0 +1,73 @@ +const daoId = "build.sputnik-dao.near"; +const accountId = context.accountId; + +// get DAO policy, deposit, and group +const policy = Near.view(daoId, "get_policy"); + +if (policy === null) { + return ""; +} + +const deposit = policy.proposal_bond; +const roleId = "community"; +const group = policy.roles + .filter((role) => role.name === roleId) + .map((role) => role.kind.Group); + +const proposalId = Near.view(daoId, "get_last_proposal_id") - 1; + +// get data from last proposal +const proposal = Near.view(daoId, "get_proposal", { + id: proposalId, +}); + +if (proposal === null) { + return ""; +} + +// check if the potential member submitted last proposal +const canJoin = accountId && accountId !== proposal.proposer; + +const Button = styled.a` + width: max-content; + all: unset; + display: flex; + padding: 10px 20px; + justify-content: center; + align-items: center; + gap: 4px; + + &:hover { + text-decoration: none; + color: #000 !important; + cursor: pointer; + background: var(--Yellow, #ffaf51); + } + + border-radius: 8px; + background: var(--Yellow, #ffaf51); + + color: var(--black-100, #000); + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; +`; + +const Container = styled.div` + width: max-content; + margin-left: auto; + + @media screen and (max-width: 768px) { + margin: 0; + width: 100%; + } +`; + +return ( + + {canJoin ? : props.children} + +); diff --git a/apps/homepage/widget/propose.jsx b/apps/homepage/widget/propose.jsx index 7c1eda86..8d0af761 100644 --- a/apps/homepage/widget/propose.jsx +++ b/apps/homepage/widget/propose.jsx @@ -157,7 +157,7 @@ return ( {view === "selection" ? ( <>

What would you like to do?

-
+
- + @@ -189,12 +189,12 @@ function App() { - + - + diff --git a/src/App.scss b/src/App.scss index b29daf0b..89d79485 100644 --- a/src/App.scss +++ b/src/App.scss @@ -3,7 +3,6 @@ body { overflow-y: scroll; background-color: #0b0c14; - color: #fff; } body, html { diff --git a/src/components/navigation/Navbar.js b/src/components/navigation/Navbar.js new file mode 100644 index 00000000..bbb8b75b --- /dev/null +++ b/src/components/navigation/Navbar.js @@ -0,0 +1,253 @@ +import React, { useCallback, useState } from "react"; +import styled from "styled-components"; +import { UserDropdown } from "./desktop/UserDropdown"; +import { Widget } from "near-social-vm"; +import { useBosLoaderStore } from "../../stores/bos-loader"; + +const StyledNavbar = styled.nav` + display: flex; + width: 100%; + padding: 24px 48px; + align-items: center; + justify-content: space-between; + + .logo { + flex-grow: 1; + flex-basis: 0; + + img { + width: auto; + height: 32px; + flex-shrink: 0; + object-fit: cover; + } + } + + .active { + border-radius: 8px; + background: var(--Yellow, #ffaf51) !important; + color: var(--black-100, #000) !important; + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; + } + + .sign-in { + all: unset; + + display: flex; + padding: 10px 20px; + justify-content: center; + align-items: center; + gap: 4px; + + border-radius: 8px; + border: 1px solid var(--white-100, #fff); + + color: var(--white-100, #fff); + transition: all 300ms; + + &:hover { + text-decoration: none; + background: #fff; + color: #000; + } + + cursor: pointer; + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; + } +`; + +const NavLink = styled.a` + all: unset; + + display: flex; + padding: 10px 20px; + justify-content: center; + align-items: center; + gap: 10px; + + border-radius: 8px; + background: var(--bg-2, #23242b) !important; + color: var(--white-100, #fff) !important; + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; + + cursor: pointer; + transition: all 300ms; + + &:hover { + text-decoration: none; + background: #ffaf51 !important; + color: #000 !important; + } +`; + +const MobileDropdownButton = styled.button` + all: unset; + + color: #fff; + padding: 0.5rem; + font-size: 2rem; +`; + +const MobileLink = styled.a` + all: unset; + + display: flex; + padding: 10px 20px; + justify-content: center; + align-items: center; + gap: 4px; + + border-radius: 8px; + border: 1px solid var(--white-100, #fff); + + color: var(--white-100, #fff); + transition: all 300ms; + + &:hover { + text-decoration: none; + background: #fff; + color: #000; + } + + cursor: pointer; + + /* Other/Button_text */ + font-size: 14px; + font-style: normal; + font-weight: 500; + line-height: normal; +`; + +const logoLink = + "https://ipfs.near.social/ipfs/bafkreihbwho3qfvnu4yss3eh5jrx6uxhrlzdgtdjyzyjrpa6odro6wdxya"; + +export function Navbar(props) { + const redirectStore = useBosLoaderStore(); + const [dropdown, setDropdown] = useState(false); + + const toggleDropdown = useCallback(() => { + setDropdown((prev) => !prev); + }, []); + + return ( + +
+ + + +
+
+ + Home + + + Editor + + Docs +
+
+ {!props.signedIn && ( + + )} + {props.signedIn && ( +
+ , + }} + /> +
+ )} +
+
+ + + +
+
+ + Home + + + Editor + + Docs + {!props.signedIn && ( + + )} + {props.signedIn && ( +
+ , + }} + /> +
+ )} +
+
+ ); +} diff --git a/src/pages/SignInPage.js b/src/pages/SignInPage.js index a3175ec7..7b0f1597 100644 --- a/src/pages/SignInPage.js +++ b/src/pages/SignInPage.js @@ -48,7 +48,7 @@ export default function SignInPage(props) { }, [params.accountId, params.privateKey]); return ( -
+