Skip to content

Commit 56106bf

Browse files
ovflowdcanerakdasbmuenzenmeyerAugustinMauroy
authored
feat: introduced home layout (#6214)
* fix: fix codebox tabs and copy button * chore: normalize export of withCurrentOS * chore: normalized layout types and layout connector * fix: fixed codetabs styles * feat: download button component * chore: mdx codetabs with external link * feat: home page layout * fix: base-layout without overflow hidden * chore: tailwind changes * feat: shiki and highlighter changes * chore: website redesign route rewrite * fix: markdown styles * chore: banner and badge on home * fix: fixed types and code * chore: fixed rewrites * chore: rephrase text * chore: design fixes and removed bloat * chore: revert site.json test changes * chore: tailwind fixes * chore: make default layout more organised * chore: more design fixes * chore: use css modules * refactor: styling updates * refactor: feedbacks from review * chore: some fixes and formatting * Update next.rewrites.mjs Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Claudio W <[email protected]> * fix: numerous accessibility issues * feat(styles): use `size` instead of `h` and `w` * fix: codebox accessible comment color * docs: color replacements on shikiji * fix: fixed mdxcontent css priority * fix: link component href and types * refactor: button to be an anchor element * fix: minor css fixes * fix: fixed tests for button * fix: button text always centered --------- Signed-off-by: Claudio W <[email protected]> Co-authored-by: Caner Akdas <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Augustin Mauroy <[email protected]>
1 parent 4a604d5 commit 56106bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1160
-436
lines changed

app/[locale]/[[...path]]/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { FC } from 'react';
55

66
import { setClientContext } from '@/client-context';
77
import { MDXRenderer } from '@/components/mdxRenderer';
8-
import { WithLayout } from '@/components/withLayout';
8+
import WithLayout from '@/components/withLayout';
99
import { ENABLE_STATIC_EXPORT, VERCEL_REVALIDATE } from '@/next.constants.mjs';
1010
import { DEFAULT_VIEWPORT } from '@/next.dynamic.constants.mjs';
1111
import { dynamicRouter } from '@/next.dynamic.mjs';

app/[locale]/layout.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ const RootLayout: FC<PropsWithChildren> = async ({ children }) => {
4242
</ThemeProvider>
4343
</LocaleProvider>
4444

45-
<a rel="me" href="https://social.lfx.dev/@nodejs" />
45+
<a
46+
rel="me"
47+
aria-hidden="true"
48+
className="hidden"
49+
href="https://social.lfx.dev/@nodejs"
50+
/>
4651

4752
{VERCEL_ENV && (
4853
<>

components/Common/Breadcrumbs/BreadcrumbHomeLink/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const BreadcrumbHomeLink: FC<BreadcrumbHomeLinkProps> = ({
2121
const navigateToHome = t('components.common.breadcrumbs.navigateToHome');
2222

2323
return (
24-
<BreadcrumbLink href={href} {...props}>
24+
<BreadcrumbLink href={href} aria-label={navigateToHome} {...props}>
2525
<HomeIcon
2626
title={navigateToHome}
2727
aria-label={navigateToHome}

components/Common/Breadcrumbs/BreadcrumbLink/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const BreadcrumbLink: FC<BreadcrumbLinkProps> = ({
1818
itemScope
1919
itemType="http://schema.org/Thing"
2020
itemProp="item"
21-
itemID={href.toString()}
21+
itemID={href?.toString()}
2222
href={href}
2323
className={classNames(
2424
styles.link,

components/Common/Breadcrumbs/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { type LinkProps } from 'next/link';
21
import { useMemo, type FC } from 'react';
32

43
import BreadcrumbHomeLink from '@/components/Common/Breadcrumbs/BreadcrumbHomeLink';
@@ -10,7 +9,7 @@ import type { FormattedMessage } from '@/types';
109

1110
type BreadcrumbLink = {
1211
label: FormattedMessage;
13-
href: LinkProps['href'];
12+
href: string | undefined;
1413
};
1514

1615
type BreadcrumbsProps = {

components/Common/Button/index.module.css

+47-47
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
1-
@import '../../../styles/new/mixins';
2-
31
.button {
42
@apply relative
5-
px-4.5
6-
py-2.5
7-
font-semibold;
3+
px-4.5
4+
py-2.5
5+
text-center
6+
font-semibold;
87

98
&.primary {
109
@apply rounded
11-
border
12-
border-green-600
13-
bg-green-600
14-
text-white
15-
shadow-sm;
10+
border
11+
border-green-600
12+
bg-green-600
13+
text-white
14+
shadow-sm;
1615

1716
&:hover {
1817
@apply border-green-700
19-
bg-green-700;
18+
bg-green-700
19+
text-white;
2020
}
2121

2222
&:focus {
2323
@apply border-green-700
24-
bg-green-700;
24+
bg-green-700;
2525
}
2626

27-
&:disabled {
27+
&[aria-disabled='true'] {
2828
@apply bg-green-600
29-
opacity-50;
29+
opacity-50;
3030
}
3131
}
3232

3333
&.secondary {
3434
@apply rounded-lg
35-
text-neutral-800
36-
dark:text-neutral-200/100;
35+
text-neutral-800
36+
dark:text-neutral-200;
3737

3838
&:hover {
3939
@apply bg-neutral-100
40-
text-neutral-800
41-
dark:bg-neutral-900
42-
dark:text-neutral-200;
40+
text-neutral-800
41+
dark:bg-neutral-900
42+
dark:text-neutral-200;
4343
}
4444

45-
&:disabled {
46-
@apply bg-neutral-100/0
45+
&[aria-disabled='true'] {
46+
@apply bg-transparent
4747
opacity-50;
4848
}
4949

5050
&:focus {
5151
@apply bg-neutral-100
52-
text-neutral-800
53-
dark:bg-neutral-900
54-
dark:text-neutral-200;
52+
text-neutral-800
53+
dark:bg-neutral-900
54+
dark:text-neutral-200;
5555
}
5656
}
5757

5858
&.special {
5959
@apply rounded-lg
60-
border
61-
border-green-600/30
62-
bg-green-600/10
63-
text-white
64-
shadow-sm;
60+
border
61+
border-green-600/30
62+
bg-green-600/10
63+
text-white
64+
shadow-sm;
6565

6666
&::before {
6767
@apply absolute
68-
right-0
69-
top-0
70-
z-[-1]
71-
h-full
72-
w-full
73-
opacity-30;
74-
75-
@mixin glow-backdrop 8em, theme(colors.green.500);
76-
77-
content: '';
68+
right-0
69+
top-0
70+
-z-10
71+
h-full
72+
w-full
73+
bg-gradient-glow-backdrop
74+
opacity-30
75+
content-[''];
7876
}
7977

8078
&::after {
8179
@apply absolute
82-
right-0
83-
top-[-1px]
84-
h-px
85-
w-[40%] bg-gradient-to-r from-green-600/0 via-green-600
86-
to-green-600/0;
87-
88-
content: '';
80+
-top-px
81+
right-0
82+
h-px
83+
w-2/5
84+
bg-gradient-to-r
85+
from-green-600/0
86+
via-green-600
87+
to-green-600/0
88+
content-[''];
8989
}
9090

91-
&:disabled {
91+
&[aria-disabled='true'] {
9292
@apply opacity-50;
9393
}
9494

components/Common/Button/index.stories.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ type Meta = MetaObj<typeof Button>;
77

88
export const Primary: Story = {
99
args: {
10-
variant: 'primary',
10+
kind: 'primary',
1111
children: 'Download Node (LTS)',
1212
disabled: false,
1313
},
1414
};
1515

1616
export const Secondary: Story = {
1717
args: {
18-
variant: 'secondary',
18+
kind: 'secondary',
1919
children: 'Download Node (LTS)',
2020
disabled: false,
2121
},
2222
};
2323

2424
export const Special: Story = {
2525
args: {
26-
variant: 'special',
26+
kind: 'special',
2727
children: 'Download Node (LTS)',
2828
disabled: false,
2929
},

components/Common/Button/index.tsx

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
import classNames from 'classnames';
2-
import type { FC, ButtonHTMLAttributes } from 'react';
2+
import type { FC, AnchorHTMLAttributes } from 'react';
3+
4+
import Link from '@/components/Link';
35

46
import styles from './index.module.css';
57

6-
type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
7-
variant?: 'primary' | 'secondary' | 'special';
8+
type ButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
9+
kind?: 'primary' | 'secondary' | 'special';
10+
// We have an extra `disabled` prop as we simulate a button
11+
disabled?: boolean;
812
};
913

1014
const Button: FC<ButtonProps> = ({
11-
variant = 'primary',
15+
kind = 'primary',
16+
disabled = false,
17+
href = undefined,
1218
children,
1319
className,
1420
...props
1521
}) => (
16-
<button
17-
className={classNames(styles.button, styles[variant], className)}
22+
<Link
23+
role="button"
24+
href={disabled ? undefined : href}
25+
aria-disabled={disabled}
26+
className={classNames(styles.button, styles[kind], className)}
1827
{...props}
1928
>
2029
{children}
21-
</button>
30+
</Link>
2231
);
2332

2433
export default Button;

components/Common/CodeBox/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const CodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
6363
language,
6464
// For now we only want to render the Copy Button by default
6565
// if the Website Redesign is Enabled
66+
// @todo remove this check once we migrate to website redesign
6667
showCopyButton = ENABLE_WEBSITE_REDESIGN,
6768
}) => {
6869
const ref = useRef<HTMLPreElement>(null);
@@ -98,7 +99,7 @@ const CodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
9899
<span className={styles.language}>{language}</span>
99100

100101
{showCopyButton && (
101-
<Button type="button" className={styles.action} onClick={onCopy}>
102+
<Button className={styles.action} onClick={onCopy}>
102103
<DocumentDuplicateIcon className={styles.icon} />
103104
{t('components.common.codebox.copy')}
104105
</Button>

components/Common/CodeTabs/index.module.css

+21-20
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
border-neutral-900
1111
bg-neutral-950
1212
px-4
13-
pr-5
14-
pt-3;
13+
pt-3
14+
xs:px-2;
1515

16-
& [role='tab'] {
16+
& [role='tablist'] > button {
1717
@apply border-b
1818
border-b-transparent
1919
px-1
@@ -24,27 +24,28 @@
2424
text-green-400;
2525
}
2626
}
27-
}
2827

29-
.link {
30-
@apply flex
31-
items-center
32-
gap-2
33-
text-center
34-
text-neutral-200;
28+
.link {
29+
@apply hidden
30+
items-center
31+
gap-2
32+
text-center
33+
text-neutral-200
34+
lg:flex;
3535

36-
& > .icon {
37-
@apply h-4
38-
w-4
39-
text-neutral-300;
40-
}
36+
& > .icon {
37+
@apply h-4
38+
w-4
39+
text-neutral-300;
40+
}
4141

42-
&:is(:link, :visited) {
43-
&:hover {
44-
@apply text-neutral-400;
42+
&:is(:link, :visited) {
43+
&:hover {
44+
@apply text-neutral-400;
4545

46-
& > .icon {
47-
@apply text-neutral-600;
46+
& > .icon {
47+
@apply text-neutral-600;
48+
}
4849
}
4950
}
5051
}

components/Common/CodeTabs/index.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import { Link } from '@/navigation.mjs';
66

77
import styles from './index.module.css';
88

9-
type CodeTabsProps = Pick<
10-
ComponentProps<typeof Tabs>,
11-
'tabs' | 'onValueChange' | 'defaultValue'
12-
> & {
9+
export type CodeTabsExternaLink = {
1310
linkUrl?: string;
1411
linkText?: string;
1512
};
1613

14+
type CodeTabsProps = Pick<
15+
ComponentProps<typeof Tabs>,
16+
'tabs' | 'onValueChange' | 'defaultValue'
17+
> &
18+
CodeTabsExternaLink;
19+
1720
const CodeTabs: FC<PropsWithChildren<CodeTabsProps>> = ({
1821
children,
1922
linkUrl,

components/Common/Pagination/__tests__/index.test.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('Pagination', () => {
162162
screen.getByRole('button', {
163163
name: 'components.common.pagination.prevAriaLabel',
164164
})
165-
).toBeDisabled();
165+
).toHaveAttribute('aria-disabled');
166166
});
167167

168168
it('Disables "Next" button when the currentPage is equal to the last page', () => {
@@ -175,7 +175,7 @@ describe('Pagination', () => {
175175
screen.getByRole('button', {
176176
name: 'components.common.pagination.nextAriaLabel',
177177
})
178-
).toBeDisabled();
178+
).toHaveAttribute('aria-disabled');
179179
});
180180
});
181181
});

0 commit comments

Comments
 (0)