Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds index page #46

Merged
merged 35 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b244e53
Adds initial nav implementation
narbs91 Nov 21, 2021
fa95561
Adds initial skeleton of all-terms page
narbs91 Nov 21, 2021
07c6b39
Adds all-terms-item def
narbs91 Nov 21, 2021
e564df2
Adds basic all-terms implementation
narbs91 Nov 22, 2021
d0fd81c
Merge branch 'main' into adds-index-page
narbs91 Nov 24, 2021
32b91f7
Fixes build issue; changes data fetch to SSG
narbs91 Nov 24, 2021
c56c48d
Changes Link to chakra.a
narbs91 Nov 24, 2021
5c3d4ba
Merge branch 'main' into adds-index-page
narbs91 Nov 28, 2021
d6ca5b8
Modularizes search result components into reusable pieces
narbs91 Nov 28, 2021
78311b3
Makes full definitons available on the all-terms page
narbs91 Nov 28, 2021
3318775
Adds section for requesting new terms
narbs91 Nov 28, 2021
58a74e9
Changes Home text in Nav to Search
narbs91 Nov 28, 2021
b514519
Adds scroll to top button
narbs91 Nov 28, 2021
cca1c1d
removes hover on scrollToTop button
narbs91 Nov 28, 2021
64110c3
Makes nav bar 100vw in width
narbs91 Nov 28, 2021
6ddee0f
renames all-terms page to glossary
narbs91 Nov 28, 2021
951e3e2
Fixes hover issue with scrollToTopButton
narbs91 Nov 28, 2021
69fb47b
Moves mobile nav into it's own component
narbs91 Nov 28, 2021
7c54aa5
Makes the nav items there own component
narbs91 Nov 28, 2021
71e0e47
Minor tweaks
narbs91 Nov 28, 2021
344e264
Minor element switch up on index page
narbs91 Nov 28, 2021
e106778
Removes hover color override on glosseta icon
narbs91 Nov 28, 2021
cef0e54
Simplifies nav-items component
narbs91 Nov 28, 2021
bb9e1f2
Removes erronous piece of text
narbs91 Nov 28, 2021
c511b14
Adds back glossary nav button text
narbs91 Nov 28, 2021
8d56444
Fixes styling issues with ResultBoxes being to wide on desktop
narbs91 Nov 28, 2021
b0de683
Adds error page when glossary terms unavailable
narbs91 Nov 28, 2021
5890426
Specifies nav items to be white; removes icons from heading
narbs91 Nov 29, 2021
ddc1dc6
Merge branch 'main' into adds-index-page
narbs91 Nov 29, 2021
36b9ee8
Makes sytling tweaks for landing page
narbs91 Nov 29, 2021
da182be
Fixes accessibilty bug wrt to scrollToTopButton
narbs91 Nov 29, 2021
81571fd
Tweaks to margin on landing page; tweaks scroll on search bar click
narbs91 Nov 29, 2021
147c20b
Further tweaks to search-bar
narbs91 Nov 29, 2021
2b22dab
Makes nav items buttons
narbs91 Nov 29, 2021
b11d9fd
Makes mobile nav have same background whether light/dark mode enabled
narbs91 Nov 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ const { i18n } = require('./next-i18next.config');

module.exports = {
reactStrictMode: true,
i18n
i18n,
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};

return config;
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@emotion/styled": "^11.3.0",
"arweave": "^1.10.17",
"axios": "^0.22.0",
"fast-csv": "^4.3.6",
"framer-motion": "^4.1.17",
"graphql": "^15.6.1",
"next": "11.1.2",
Expand Down
14 changes: 13 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"glossetaTitle": "Glosseta",
"glossetaNavbarButtonA11yText": "Takes you to the main search page",
"glossaryButton": "Glossary",
"searchButtonTitle": "Search",
"scrollToTheTopButton": "Click here to scroll to the top of the page",

"web3GlossaryHeading": "Web3 Glossary",
"glossetaDescription": "Glosseta is an open-source glossary meant to help people explore and learn the terminology behind web3",

Expand All @@ -10,10 +16,16 @@
"searchResultContentSourceDescription" : "The definition you see above is stored on the Arweave network which is a protocol for storing data permanently in a decentralized manner among network users who have storage to spare. As a result, this definition will live forever on the Arweave network.",
"searchResultContentSourceTransactionLinkText" : "Click here to view the Arweave transaction for this definition",

"glossaryPageHeading" : "Glossary",
"somethingMissingHeading" : "Something missing?",
"twitterTermRequestDescription" : "If there's a specific term you were looking for but didn't see above, please let us know and we'll get it added. Give us a shout on ",
"glossaryTermFetchErrorHeading": "Error",
"glossaryTermFetchErrorText" : "Something went wrong trying to retrieve the glossary terms. Please refresh the page or try searching for an individual term. If the issue persists please reach out to us on ",

"opensInANewWindow" : "Opens in a new window",
"twitter" : "Twitter",
"or" : "or",
"gitHubIssueText": "open up a GitHub issue",
"gitHubIssueText" : "open up a GitHub issue",

"unavailableSearchResultDescription" : "This term isn't in our knowledge base at the moment. If you think this is something we should have, please reach out to us on",
"apiFetchErrorText" : "Something went wrong while trying to retrieve the definition. Please refresh the page or search for another term.",
Expand Down
26 changes: 15 additions & 11 deletions src/pages/components/layout/page/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React from "react";
import { Stack } from "@chakra-ui/react";
import Footer from "../../footer/footer";
import Nav from "../../nav";

const PageLayout = ({ children }: { children?: object }): JSX.Element => {
return (
<Stack
spacing={10}
padding={1}
display="flex"
justifyContent="center"
flexDirection="column"
alignItems="center"
minHeight="100vh"
>
{children}
<>
<Nav />
<Stack
spacing={10}
padding={1}
display="flex"
justifyContent="center"
flexDirection="column"
alignItems="center"
minHeight="100vh"
>
{children}
</Stack>
<Footer />
</Stack>
</>
);
};

Expand Down
81 changes: 81 additions & 0 deletions src/pages/components/nav/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from "react";
import { chakra, Flex, HStack, Avatar } from "@chakra-ui/react";
import Link from "next/link";
import { useTranslation } from "react-i18next";
import MobileNav from "./mobile-nav";
import NavItems from "./nav-items";
import { useRouter } from "next/router";

/**
* Implementation inspired from the developer dao website
*
* source: https://github.com/Developer-DAO/developerdao.com
* */
export default function Nav() {
const { t } = useTranslation();
const router = useRouter();

const isHomePage = router.pathname === "/";
const isGlossaryPage = router.pathname === "/glossary";
const isSearchPage = router.pathname === "/search";

return (
<chakra.nav
borderBottom="1px solid"
borderColor="#2C3539"
backgroundColor="#2C3539"
minWidth="100vw"
>
<Flex
alignItems="center"
justifyContent="space-between"
mx="auto"
maxW="7xl"
py={3}
px={5}
>
<Link href="/" passHref>
<HStack
as="a"
title={t("glossetaTitle")}
display="flex"
alignItems="center"
>
<Avatar
name="Glosseta"
src="/glosseta_icon.png"
alt="Glosseta logo"
bg="#7a08fc"
/>
<chakra.span
fontWeight="bold"
fontSize="sm"
transition="color 300ms ease-in-out"
color="white"
>
{t("glossetaTitle")}
</chakra.span>
</HStack>
</Link>
<HStack display="flex" alignItems="center" spacing={1}>
<HStack
spacing={{ base: 3, sm: 10 }}
display={{ base: "none", md: "inline-flex" }}
>
<NavItems
isHomePage={isHomePage}
isGlossaryPage={isGlossaryPage}
isSearchPage={isSearchPage}
/>
</HStack>

<MobileNav
isHomePage={isHomePage}
isGlossaryPage={isGlossaryPage}
isSearchPage={isSearchPage}
/>
</HStack>
</Flex>
</chakra.nav>
);
}
59 changes: 59 additions & 0 deletions src/pages/components/nav/mobile-nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from "react";
import {
Box,
useColorModeValue,
useDisclosure,
VStack,
IconButton,
CloseButton,
} from "@chakra-ui/react";
import { AiOutlineMenu } from "react-icons/ai";
import NavItems from "./nav-items";

export default function MobileNav({
isHomePage,
isGlossaryPage,
isSearchPage,
}: any) {
const bg = useColorModeValue("gray.800", "gray.800");
const { onClose, onOpen, isOpen } = useDisclosure();

return (
<Box display={{ base: "inline-flex", md: "none" }}>
<IconButton
display={{ base: "flex", md: "none" }}
aria-label="Open menu"
fontSize="20px"
color="white"
variant="ghost"
icon={<AiOutlineMenu />}
onClick={onOpen}
/>

<VStack
pos="absolute"
top={0}
left={0}
right={0}
display={isOpen ? "flex" : "none"}
flexDirection="column"
pt={7}
pb={7}
m={0}
bg={bg}
spacing={3}
rounded="sm"
shadow="sm"
zIndex="99"
>
<CloseButton aria-label="Close menu" onClick={onClose} color="white" />

<NavItems
isHomePage={isHomePage}
isGlossaryPage={isGlossaryPage}
isSearchPage={isSearchPage}
/>
</VStack>
</Box>
);
}
41 changes: 41 additions & 0 deletions src/pages/components/nav/nav-items.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";

import Link from "next/link";
import { useTranslation } from "react-i18next";
import styles from "../../../../styles/Home.module.css";
import { Button } from "@chakra-ui/react";

export default function NavItems({
isHomePage,
isGlossaryPage,
isSearchPage,
}: any) {
const { t } = useTranslation();

/**
* The intent of the conditional checks is so that the respective pages link is not available to the user to click.
* So if the user is on the Glossary page, they will see every nav item except the Search (i.e. Home) item.
*/
return (
<>
{isGlossaryPage && (
<Link href="/" passHref>
<Button color="white" variant="ghost">
{t("searchButtonTitle")}
<span className={styles.visuallyhidden}>
{t("glossetaNavbarButtonA11yText")}
</span>
</Button>
</Link>
)}

{(isHomePage || isSearchPage) && (
<Link href="/glossary" passHref>
<Button color="white" variant="ghost">
{t("glossaryButton")}
</Button>
</Link>
)}
</>
);
}
46 changes: 46 additions & 0 deletions src/pages/glossary/glossary-data-fetch-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Box, Text, Container, VStack, Heading, Link } from "@chakra-ui/react";
import { ExternalLinkIcon } from "@chakra-ui/icons";
import { useTranslation } from "next-i18next";
import styles from "../../../styles/Home.module.css";

export const GlossaryDataFetchError = (): JSX.Element => {
const twitter_href = `https://twitter.com/intent/tweet?screen_name=Glossetadotcom`;
const { t } = useTranslation();

return (
<>
<Container maxW={{ base: "sm", sm: "xl" }}>
<Box
width="100%"
background="#2C3539"
borderWidth="1px"
borderColor="black"
>
<VStack padding={3}>
<Heading
as="h1"
padding={2}
maxWidth="50%"
color="white"
fontSize={{ base: "md", sm: "xl" }}
isTruncated
>
{t("glossaryTermFetchErrorHeading")}
</Heading>
<Text padding={2} fontSize={{ base: "xs", sm: "md" }} color="white">
{t("glossaryTermFetchErrorText")}{" "}
<Link color="aquamarine" href={twitter_href} isExternal>
{t("twitter")} <ExternalLinkIcon mx="2px" />
<span className={styles.visuallyhidden}>
{t("opensInANewWindow")}
</span>
</Link>
</Text>
</VStack>
</Box>
</Container>
</>
);
};

export default GlossaryDataFetchError;
Loading