Skip to content

Commit ebafff4

Browse files
authored
Adding github and discord in docs header (#2083)
1 parent b1d983c commit ebafff4

File tree

5 files changed

+87
-65
lines changed

5 files changed

+87
-65
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
import { Icon } from '@aws-amplify/ui-react';
2+
import { SiGithub, SiDiscord, SiW3C, SiReact } from 'react-icons/si';
23

3-
export const DesignTokenIcon = ({ ariaLabel, ...rest }) => (
4+
export const ReactIcon = ({ ariaLabel = '', ...rest }) => (
5+
<Icon {...rest} ariaLabel={ariaLabel} as={SiReact} />
6+
);
7+
8+
export const W3CIcon = ({ ariaLabel = '', ...rest }) => (
9+
<Icon {...rest} ariaLabel={ariaLabel} as={SiW3C} />
10+
);
11+
12+
export const DiscordIcon = ({ ariaLabel = '', ...rest }) => (
13+
<Icon {...rest} ariaLabel={ariaLabel} as={SiDiscord} />
14+
);
15+
16+
export const GithubIcon = ({ ariaLabel = '', ...rest }) => (
17+
<Icon {...rest} ariaLabel={ariaLabel} as={SiGithub} />
18+
);
19+
20+
export const DesignTokenIcon = ({ ariaLabel = '', ...rest }) => (
421
<Icon
522
{...rest}
623
ariaLabel={ariaLabel}

docs/src/components/Layout/Footer.tsx

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { Icon, Link, Text, Flex, View, useTheme } from '@aws-amplify/ui-react';
1+
import { Link, Text, Flex, View, Button } from '@aws-amplify/ui-react';
22

3-
import * as links from '@/data/links';
4-
import * as icons from '@/data/icon';
3+
import { DISCORD, GITHUB_REPO, TERMS, PRIVACY } from '@/data/links';
54
import { Logo } from '@/components/Logo';
5+
import { DiscordIcon, GithubIcon } from '../Icons';
66

77
export const Footer = () => {
8-
const { tokens } = useTheme();
98
return (
109
<Flex as="footer" direction="column" className="docs-footer">
1110
<Flex direction="row" justifyContent="center">
@@ -15,41 +14,24 @@ export const Footer = () => {
1514
justifyContent="center"
1615
alignItems="center"
1716
direction={{ base: 'column', medium: 'row' }}
18-
gap={tokens.space.xs}
17+
gap="xs"
1918
>
20-
<Link
21-
href="https://github.com/aws-amplify/amplify-ui"
22-
isExternal={true}
19+
<Button
20+
as={Link}
21+
variation="link"
22+
href={GITHUB_REPO}
23+
isExternal
24+
gap="xs"
2325
>
24-
<Flex
25-
as="span"
26-
alignItems="baseline"
27-
justifyContent="center"
28-
display="flex"
29-
gap={tokens.space.xs}
30-
>
31-
<Icon ariaLabel="Github" pathData={icons.GITHUB} />
32-
Contribute on Github
33-
</Flex>
34-
</Link>
35-
<Link href="https://discord.gg/amplify" isExternal={true}>
36-
<Flex
37-
as="span"
38-
alignItems="baseline"
39-
justifyContent="center"
40-
display="flex"
41-
gap={tokens.space.xxs}
42-
>
43-
<Icon
44-
ariaLabel=""
45-
viewBox={{ minX: 0, minY: 0, width: 245, height: 240 }}
46-
pathData={icons.DISCORD}
47-
/>
48-
Discuss on Discord
49-
</Flex>
50-
</Link>
26+
<GithubIcon ariaLabel="" />
27+
Contribute on Github
28+
</Button>
29+
<Button as={Link} variation="link" href={DISCORD} isExternal gap="xs">
30+
<DiscordIcon ariaLabel="" />
31+
Discuss on Discord
32+
</Button>
5133
</Flex>
52-
<View fontSize={tokens.fontSizes.small}>
34+
<View fontSize="small">
5335
<Text>
5436
Amplify open source software, documentation and community are
5537
supported by Amazon Web Services.
@@ -58,16 +40,16 @@ export const Footer = () => {
5840
{' '}
5941
© {new Date().getFullYear()} Amazon Web Services, Inc. and its
6042
affiliates. All rights reserved. View the{' '}
61-
<Link isExternal={true} href={links.TERMS}>
43+
<Link isExternal href={TERMS}>
6244
site terms
6345
</Link>{' '}
6446
and{' '}
65-
<Link isExternal={true} href={links.PRIVACY}>
47+
<Link isExternal href={PRIVACY}>
6648
privacy policy
6749
</Link>
6850
.
6951
</Text>
70-
<Text marginBlockStart={tokens.space.medium}>
52+
<Text marginBlockStart="medium">
7153
Flutter and the related logo are trademarks of Google LLC. We are not
7254
endorsed by or affiliated with Google LLC.
7355
</Text>

docs/src/components/Layout/Header.tsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import * as React from 'react';
22
import { DocSearch } from '@docsearch/react';
3-
import { Flex, Image } from '@aws-amplify/ui-react';
3+
import {
4+
Button,
5+
Flex,
6+
Image,
7+
Link,
8+
View,
9+
VisuallyHidden,
10+
useBreakpointValue,
11+
} from '@aws-amplify/ui-react';
412

513
import { ColorModeSwitcher } from './ColorModeSwitcher';
614
import { Sidebar } from './Sidebar';
715
import { LogoLink } from './LogoLink';
816
import { MenuButton } from './MenuButton';
9-
17+
import { DISCORD, GITHUB_REPO } from '@/data/links';
1018
import '@docsearch/css';
19+
import { DiscordIcon, GithubIcon } from '../Icons';
1120

1221
export const Header = ({
1322
expanded,
@@ -17,6 +26,11 @@ export const Header = ({
1726
platform,
1827
}) => {
1928
const [showSearch, setShowSearch] = React.useState(false);
29+
const hiddenOnMobile = useBreakpointValue({
30+
base: false,
31+
small: true,
32+
});
33+
2034
React.useEffect(() => {
2135
setShowSearch(true);
2236
}, [showSearch]);
@@ -51,6 +65,34 @@ export const Header = ({
5165
/>
5266
)}
5367
<ColorModeSwitcher colorMode={colorMode} setColorMode={setColorMode} />
68+
{hiddenOnMobile ? (
69+
<View>
70+
<Button
71+
variation="link"
72+
size="small"
73+
as={Link}
74+
href={DISCORD}
75+
isExternal
76+
color="font.tertiary"
77+
fontSize="medium"
78+
>
79+
<VisuallyHidden>Discord</VisuallyHidden>
80+
<DiscordIcon />
81+
</Button>
82+
<Button
83+
variation="link"
84+
size="small"
85+
as={Link}
86+
href={GITHUB_REPO}
87+
isExternal
88+
color="font.tertiary"
89+
fontSize="medium"
90+
>
91+
<VisuallyHidden>Github</VisuallyHidden>
92+
<GithubIcon />
93+
</Button>
94+
</View>
95+
) : null}
5496
</Flex>
5597
</Flex>
5698
);

docs/src/components/Layout/index.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import * as React from 'react';
22
import debounce from 'lodash/debounce';
3-
import {
4-
Icon,
5-
Heading,
6-
Link,
7-
Text,
8-
View,
9-
useTheme,
10-
} from '@aws-amplify/ui-react';
11-
import { SiW3C, SiReact } from 'react-icons/si';
3+
import { Heading, Link, Text, View, useTheme } from '@aws-amplify/ui-react';
124

13-
import { Sidebar } from './Sidebar';
145
import { TableOfContents } from '../TableOfContents';
156
import { Footer } from './Footer';
167
import { GITHUB_REPO_FILE } from '@/data/links';
17-
import { DesignTokenIcon } from '@/components/DesignTokenIcon';
8+
import { DesignTokenIcon, ReactIcon, W3CIcon } from '@/components/Icons';
189

1910
export default function Page({
2011
children,
@@ -90,11 +81,7 @@ export default function Page({
9081
href={ariaPattern}
9182
isExternal
9283
>
93-
<Icon
94-
ariaLabel="W3C"
95-
as={SiW3C}
96-
marginInlineEnd={tokens.space.xs}
97-
/>
84+
<W3CIcon ariaLabel="W3C" marginInlineEnd={tokens.space.xs} />
9885
ARIA pattern
9986
</Link>
10087
) : null}
@@ -117,10 +104,9 @@ export default function Page({
117104
href={`${GITHUB_REPO_FILE}${reactSource}`}
118105
isExternal
119106
>
120-
<Icon
107+
<ReactIcon
121108
ariaLabel=""
122109
aria-hidden="true"
123-
as={SiReact}
124110
marginInlineEnd={tokens.space.xs}
125111
/>
126112
React source

docs/src/data/icon.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)