Skip to content

Commit

Permalink
Update components (#73)
Browse files Browse the repository at this point in the history
* Deploy `develop` to staging

* Display language switcher

* Update dependencies + add language switcher to footer

* Fix Korean translations

* Fix translations of outline titles on landing page

* Add Graph Day link to nav

* Prepare to merge to `main`
  • Loading branch information
benface authored Mar 1, 2022
1 parent 21670e7 commit 96b1d57
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 270 deletions.
12 changes: 6 additions & 6 deletions components/NavTree.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { HTMLAttributes, createContext, Context, useState, useContext } from 'react'
import * as Collapsible from '@radix-ui/react-collapsible'
import {
Diamond,
DiamondProps,
NewGDSDivider,
Text,
TextProps,
Flex,
Icon,
IconProps,
Spacing,
buildTransition,
} from '@edgeandnode/components'
Expand All @@ -34,7 +33,7 @@ export type NavTreeItemProps = HTMLAttributes<HTMLElement> &
Pick<LinkProps, 'href' | 'target'> & {
active?: boolean
linkProps?: LinkProps & SxProp
diamondProps?: DiamondProps & SxProp
diamondProps?: IconProps & SxProp
}
export type NavTreeGroupProps = HTMLAttributes<HTMLElement> & {
active?: boolean
Expand Down Expand Up @@ -84,10 +83,11 @@ const NavTreeItem = ({
>
{children}
{active && (
<Diamond
<Icon.DiamondSolid
size="12px"
sx={{
position: 'absolute',
left: '6px',
left: Spacing.S,
top: 0,
bottom: 0,
my: 'auto',
Expand Down Expand Up @@ -177,7 +177,7 @@ const NavTreeGroupContent = ({ children, ...props }: NavTreeGroupContentProps) =
const NavTreeDivider = (props: NavTreeDividerProps) => {
return (
<li aria-hidden="true" sx={{ my: Spacing.M }} {...props}>
<NewGDSDivider simple />
<NewGDSDivider />
</li>
)
}
Expand Down
2 changes: 1 addition & 1 deletion i18n/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Locale } from './locales'
import enTranslations from '@/pages/en/translations'
import esTranslations from '@/pages/es/translations'
import arTranslations from '@/pages/ar/translations'
import koTranslations from '@/pages/ar/translations'
import koTranslations from '@/pages/ko/translations'
import zhTranslations from '@/pages/zh/translations'
import jaTranslations from '@/pages/ja/translations'
import viTranslations from '@/pages/vi/translations'
Expand Down
34 changes: 15 additions & 19 deletions layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
[localesDetails]
)

const languageSwitcher = useMemo(
() => (
<LanguageSwitcher
key="languageSwitcher"
languages={languages}
value={currentLocale}
onSelect={(locale) => setLocale(locale as Locale)}
label={translations.global.language}
/>
),
[languages, currentLocale, setLocale, translations]
)

return (
<div>
<div
Expand All @@ -32,7 +45,6 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
backgroundImage: `url('${process.env.NEXT_PUBLIC_BASE_PATH}/img/page-background.png')`,
backgroundSize: 'cover',
backgroundPosition: 'center top',
backgroundRepeat: 'no-repeat',
'@media (min-width: 1440px)': {
aspectRatio: '1440/768',
},
Expand All @@ -45,23 +57,7 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
>
<div sx={{ flexShrink: 0 }}>
<Container sx={{ '--container-padding': '32px' }}>
<NavigationMarketing
activeRoute="/docs"
NextLink={NextLink}
rightAlignItems={
[
/*
<LanguageSwitcher
key="languageSwitcher"
languages={languages}
value={currentLocale}
onSelect={(locale) => setLocale(locale as Locale)}
label={translations.global.language}
/>,
*/
]
}
/>
<NavigationMarketing activeRoute="/docs" NextLink={NextLink} /* rightAlignItems={[languageSwitcher]} */ />
</Container>
</div>
<main sx={{ flexGrow: 1 }}>
Expand All @@ -70,7 +66,7 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
<div sx={{ flexShrink: 0 }}>
<Container>
<div sx={{ mx: 'auto', maxWidth: [null, null, null, 'calc(100vw - 500px)'] }}>
<Footer />
<Footer /* languageSwitcher={languageSwitcher} */ />
</div>
</Container>
</div>
Expand Down
4 changes: 2 additions & 2 deletions layout/MDXLayoutNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const MobileWrapper = ({ title, children }: PropsWithChildren<{ title?: string }
sx={{ px: Spacing.L_XL, py: '20px' }}
>
<Flex.Column as="span" gap={Spacing.S}>
<Text.T10 color="White64">Docs</Text.T10>
<Text.S10 color="White64">Docs</Text.S10>
<Text size="16px">{title}</Text>
</Flex.Column>
<Flex.Column
Expand Down Expand Up @@ -145,7 +145,7 @@ export const MDXLayoutNav = ({ mobile = false }: { mobile?: boolean }) => {
active={currentPage?.path === navItem.path}
sx={mobile ? { py: 0 } : {}}
linkProps={{ sx: mobile ? {} : { pr: 0 } }}
diamondProps={{ sx: mobile ? { left: '10px' } : {} }}
diamondProps={{ sx: mobile ? { left: '6px' } : {} }}
>
{navItem.title}
</NavTree.Item>
Expand Down
8 changes: 4 additions & 4 deletions layout/MDXLayoutOutline.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react'
import { Text, Flex, NewGDSDivider as Divider, Spacing, buildTransition } from '@edgeandnode/components'
import { Text, Flex, NewGDSDivider, Spacing, buildTransition } from '@edgeandnode/components'

import { DocumentContext } from '@/layout'
import { Link, EditPageLink } from '@/components'
Expand Down Expand Up @@ -28,11 +28,11 @@ export const MDXLayoutOutline = () => {
<Flex.Row>
<EditPageLink />
</Flex.Row>
<Divider simple sx={{ my: Spacing.XL }} />
<NewGDSDivider sx={{ my: Spacing.XL }} />
<nav sx={{ pr: '16px' }}>
<Text.T10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
<Text.S10 as="header" color="White64" sx={{ mb: Spacing.M_L }}>
{translations.global.pageSections}
</Text.T10>
</Text.S10>
<Text as="ul" size="14px" color="White48">
{outline.map((outlineItem, outlineItemIndex) => {
if (outlineItem.level > 3) {
Expand Down
6 changes: 3 additions & 3 deletions layout/MDXLayoutPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const MDXLayoutPagination = () => {

return (
<div sx={{ overflow: 'hidden' }}>
<NewGDSDivider />
<NewGDSDivider diamonds />
<Flex.Row justify="space-between" sx={{ mt: Spacing.XL }}>
<div>
{previousPage && (
Expand All @@ -30,7 +30,7 @@ export const MDXLayoutPagination = () => {
<Flex.Column align="start" gap={Spacing.S} sx={{ textAlign: 'left' }}>
<Flex.Row align="center" gap={Spacing.S}>
<Icon.ArrowLeft size="12px" />
<Text.T10>{translations.global.previous}</Text.T10>
<Text.S10>{translations.global.previous}</Text.S10>
</Flex.Row>
<Text
weight="Semibold"
Expand Down Expand Up @@ -67,7 +67,7 @@ export const MDXLayoutPagination = () => {
>
<Flex.Column align="end" gap={Spacing.S} sx={{ textAlign: 'right' }}>
<Flex.Row align="center" gap={Spacing.S}>
<Text.T10>{translations.global.next}</Text.T10>
<Text.S10>{translations.global.next}</Text.S10>
<Icon.ArrowRight size="12px" />
</Flex.Row>
<Text
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"dependencies": {
"@edgeandnode/components": "^18.1.1",
"@edgeandnode/components": "^20.3.1",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mdx-js/loader": "^2.0.0",
Expand All @@ -32,7 +32,7 @@
"@radix-ui/react-visually-hidden": "^0.1.3",
"next": "^12.0.10",
"next-seo": "^4.29.0",
"prism-react-renderer": "^1.2.1",
"prism-react-renderer": "^1.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-intersection-observer": "^8.33.1",
Expand All @@ -44,12 +44,12 @@
"@sindresorhus/slugify": "^2.1.0",
"@svgr/webpack": "^6.2.1",
"@types/color": "^3.0.3",
"@types/lodash-es": "^4.17.5",
"@types/node": "^16.11.21",
"@types/react": "^17.0.38",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.11.24",
"@types/react": "^17.0.39",
"acorn": "^8.7.0",
"acorn-jsx": "^5.3.2",
"eslint": "^8.8.0",
"eslint": "^8.9.0",
"eslint-config-next": "^12.0.10",
"husky": "^7.0.4",
"lodash-es": "^4.17.21",
Expand Down
40 changes: 22 additions & 18 deletions pages/[locale]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react'
import { GetStaticPaths, GetStaticProps } from 'next'
import { Text, Flex, Spacing, BorderRadius, buildBorder, buildShadow, buildTransition } from '@edgeandnode/components'

Expand All @@ -11,24 +12,6 @@ export const frontmatter = (locale: Locale): Frontmatter => ({
title: translations[locale].index.title,
})

const outline: OutlineItem[] = [
{
id: 'network-roles',
title: 'Network Roles',
level: 2,
},
{
id: 'products',
title: 'Products',
level: 2,
},
{
id: 'supported-networks',
title: 'Supported Networks',
level: 2,
},
]

export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: Object.values(Locale).map((locale) => ({
Expand All @@ -51,6 +34,27 @@ export const getStaticProps: GetStaticProps = async (context) => {
const Index = ({ navItems }: { navItems: NavItem[] }) => {
const { currentLocale, translations } = useI18n()

const outline: OutlineItem[] = useMemo(
() => [
{
id: 'network-roles',
title: translations.index.networkRoles.title,
level: 2,
},
{
id: 'products',
title: translations.index.products.title,
level: 2,
},
{
id: 'supported-networks',
title: translations.index.supportedNetworks.title,
level: 2,
},
],
[translations]
)

return (
<MDXLayout
pagePath="[locale]/index.tsx"
Expand Down
Loading

0 comments on commit 96b1d57

Please sign in to comment.