Skip to content

Commit 7a99b73

Browse files
authored
feat(Preview): add Preview component (#6014)
* feat(Preview): add Preview component * feat(Preview): use radial gradient * feat(Preview): add width and height props * feat(Preview): update storybook * fix(Preview): update css
1 parent aed5386 commit 7a99b73

5 files changed

Lines changed: 567 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.root {
2+
@apply relative
3+
flex
4+
items-center
5+
bg-neutral-950
6+
bg-[url('/static/images/patterns/hexagon-grid.svg')]
7+
bg-contain
8+
bg-center
9+
after:absolute
10+
after:inset-0
11+
after:m-auto
12+
after:aspect-square
13+
after:w-1/3
14+
after:rounded-full
15+
after:bg-gradient-radial
16+
after:blur-3xl;
17+
18+
&.announcement {
19+
@apply after:from-green-700/90;
20+
}
21+
22+
&.release {
23+
@apply after:from-info-600/90;
24+
}
25+
26+
&.vulnerability {
27+
@apply after:from-warning-600/90;
28+
}
29+
30+
& > .container {
31+
@apply z-10
32+
mx-auto
33+
flex
34+
max-w-xl
35+
flex-col
36+
gap-12
37+
text-center
38+
text-3xl
39+
font-semibold
40+
text-white;
41+
42+
& > .logo {
43+
@apply mx-auto;
44+
}
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
2+
3+
import Preview from './';
4+
5+
type Story = StoryObj<typeof Preview>;
6+
type Meta = MetaObj<typeof Preview>;
7+
8+
export const Default: Story = {
9+
args: {
10+
title:
11+
'Changing the End-of-Life Date for Node.js 16 to September 11th, 2023',
12+
},
13+
};
14+
15+
export const Announcement: Story = {
16+
args: {
17+
type: 'announcement',
18+
title:
19+
'Changing the End-of-Life Date for Node.js 16 to September 11th, 2023',
20+
},
21+
};
22+
23+
export const Release: Story = {
24+
args: {
25+
type: 'release',
26+
title: 'Node v20.5.0 (Current)',
27+
},
28+
};
29+
30+
export const Vulnerability: Story = {
31+
args: {
32+
type: 'vulnerability',
33+
title: 'OpenSSL update assessment, and Node.js project plans',
34+
},
35+
};
36+
37+
export const CustomSize: Story = {
38+
args: {
39+
title:
40+
'Changing the End-of-Life Date for Node.js 16 to September 11th, 2023',
41+
width: 600,
42+
height: 315,
43+
},
44+
};
45+
46+
export default { component: Preview } as Meta;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import classNames from 'classnames';
2+
import Image from 'next/image';
3+
import type { CSSProperties, ComponentProps, FC, ReactNode } from 'react';
4+
5+
import { useRouter } from '@/hooks/useRouter';
6+
7+
import styles from './index.module.css';
8+
9+
type PreviewProps = {
10+
type?: 'announcement' | 'release' | 'vulnerability';
11+
title: ReactNode;
12+
height?: CSSProperties['height'];
13+
width?: CSSProperties['width'];
14+
} & Omit<ComponentProps<'div'>, 'children'>;
15+
16+
const Preview: FC<PreviewProps> = ({
17+
type = 'announcement',
18+
title,
19+
height = 630,
20+
width = 1200,
21+
...props
22+
}) => {
23+
const { basePath } = useRouter();
24+
25+
return (
26+
<div
27+
{...props}
28+
style={{ width, height, ...props.style }}
29+
className={classNames(styles.root, styles[type], props.className)}
30+
>
31+
<div className={styles.container}>
32+
<Image
33+
className={styles.logo}
34+
priority
35+
width="71"
36+
height="80"
37+
src={`${basePath}/static/images/logos/js-white.svg`}
38+
alt="Node.js"
39+
/>
40+
<h1>{title}</h1>
41+
</div>
42+
</div>
43+
);
44+
};
45+
46+
export default Preview;

0 commit comments

Comments
 (0)