Skip to content

Commit a0f03ae

Browse files
authored
fix(site): close release modal on eol link click (#7903)
* fix(site): close release modal on eol button click * feat: review nits * feat: reorder alertbox
1 parent 84fa725 commit a0f03ae

File tree

5 files changed

+52
-37
lines changed

5 files changed

+52
-37
lines changed

apps/site/components/Downloads/ReleaseModal/index.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import AlertBox from '@node-core/ui-components/Common/AlertBox';
2-
import Modal from '@node-core/ui-components/Common/Modal';
2+
import { Modal, Title, Content } from '@node-core/ui-components/Common/Modal';
33
import { useTranslations } from 'next-intl';
44
import type { FC } from 'react';
55

@@ -32,15 +32,22 @@ const ReleaseModal: FC<ReleaseModalProps> = ({
3232
});
3333

3434
return (
35-
<Modal open={isOpen} onOpenChange={closeModal} heading={modalHeading}>
35+
<Modal open={isOpen} onOpenChange={closeModal}>
3636
{release.status === 'End-of-life' && (
3737
<AlertBox
3838
title={t('components.common.alertBox.warning')}
3939
level="warning"
4040
size="small"
4141
>
4242
{t.rich('components.releaseModal.unsupportedVersionWarning', {
43-
link: text => <Link href="/about/previous-releases/">{text}</Link>,
43+
link: text => (
44+
<Link
45+
onClick={closeModal}
46+
href="/about/previous-releases#release-schedule"
47+
>
48+
{text}
49+
</Link>
50+
),
4451
})}
4552
</AlertBox>
4653
)}
@@ -57,19 +64,23 @@ const ReleaseModal: FC<ReleaseModalProps> = ({
5764
</AlertBox>
5865
)}
5966

60-
{release.releaseAnnounceLink && (
61-
<LinkWithArrow href={release.releaseAnnounceLink}>
62-
{t('components.releaseModal.releaseAnnouncement')}
63-
</LinkWithArrow>
64-
)}
67+
<Title>{modalHeading}</Title>
68+
69+
<Content>
70+
{release.releaseAnnounceLink && (
71+
<LinkWithArrow href={release.releaseAnnounceLink}>
72+
{t('components.releaseModal.releaseAnnouncement')}
73+
</LinkWithArrow>
74+
)}
6575

66-
<h5>{t('components.releaseModal.overview')}</h5>
76+
<h5>{t('components.releaseModal.overview')}</h5>
6777

68-
<ReleaseOverview release={release} />
78+
<ReleaseOverview release={release} />
6979

70-
<h5>{t('components.releaseModal.minorVersions')}</h5>
80+
<h5>{t('components.releaseModal.minorVersions')}</h5>
7181

72-
<MinorReleasesTable releases={release.minorVersions} />
82+
<MinorReleasesTable releases={release.minorVersions} />
83+
</Content>
7384
</Modal>
7485
);
7586
};

packages/i18n/locales/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@
163163
"details": "Details"
164164
},
165165
"releaseModal": {
166-
"title": "Node.js {version} ({codename})",
167-
"titleWithoutCodename": "Node.js {version}",
166+
"title": "Node.js v{version} ({codename})",
167+
"titleWithoutCodename": "Node.js v{version}",
168168
"overview": "Overview",
169169
"minorVersions": "Minor versions",
170170
"releaseAnnouncement": "Release Announcement",
171-
"unsupportedVersionWarning": "This version is out of maintenance. Please use a currently supported version. <link>Understand EOL support.</link>",
171+
"unsupportedVersionWarning": "This version is out of maintenance. Please use a supported version. <link>Understand EOL support.</link>",
172172
"ltsVersionFeaturesNotice": "Want new features sooner? Get the <link>latest Node.js version</link> instead and try the latest improvements!"
173173
},
174174
"minorReleasesTable": {

packages/ui-components/Common/Modal/index.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
w-full
1818
max-w-3xl
1919
flex-col
20+
gap-2
2021
overflow-y-auto
2122
rounded
2223
border
@@ -47,16 +48,15 @@
4748
}
4849

4950
.title {
50-
@apply mb-2
51-
text-3xl
51+
@apply text-3xl
5252
font-semibold
5353
text-neutral-900
5454
dark:text-white;
5555
}
5656

5757
.description {
5858
@apply font-regular
59-
mb-4
59+
mb-2
6060
text-lg
6161
text-neutral-800
6262
dark:text-neutral-200;

packages/ui-components/Common/Modal/index.stories.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
22

3-
import Modal from '#ui/Common/Modal';
3+
import { Modal, Title, Description, Content } from '#ui/Common/Modal';
44

55
type Story = StoryObj<typeof Modal>;
66
type Meta = MetaObj<typeof Modal>;
77

88
export const Default: Story = {
99
args: {
1010
open: true,
11-
heading: 'Node.js Versions Information',
12-
subheading: 'Get all information about Node.js versions and their changes.',
1311
children: (
14-
<>
12+
<Content>
13+
<Title>Node.js Versions Information</Title>
14+
<Description>
15+
Get all information about Node.js versions and their changes.
16+
</Description>
1517
<p>
1618
Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto
1719
atque sint doloremque, sapiente recusandae debitis libero nostrum
@@ -24,7 +26,7 @@ export const Default: Story = {
2426
amet minus sit architecto blanditiis hic sed odit cumque numquam
2527
dignissimos delectus.
2628
</p>
27-
</>
29+
</Content>
2830
),
2931
},
3032
};

packages/ui-components/Common/Modal/index.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ import type { FC, PropsWithChildren } from 'react';
77
import styles from './index.module.css';
88

99
type ModalProps = PropsWithChildren<{
10-
heading: string;
11-
subheading?: string;
1210
open?: boolean;
1311
onOpenChange?: (open: boolean) => void;
1412
}>;
1513

1614
const Modal: FC<ModalProps> = ({
17-
heading,
18-
subheading,
1915
children,
2016
open = false,
2117
onOpenChange = () => {},
@@ -28,15 +24,7 @@ const Modal: FC<ModalProps> = ({
2824
<XMarkIcon />
2925
</Dialog.Trigger>
3026

31-
<Dialog.Title className={styles.title}>{heading}</Dialog.Title>
32-
33-
{subheading && (
34-
<Dialog.Description className={styles.description}>
35-
{subheading}
36-
</Dialog.Description>
37-
)}
38-
39-
<main className={styles.wrapper}>{children}</main>
27+
{children}
4028

4129
<Dialog.Close />
4230
</Dialog.Content>
@@ -45,4 +33,18 @@ const Modal: FC<ModalProps> = ({
4533
</Dialog.Root>
4634
);
4735

48-
export default Modal;
36+
const Title = ({ children }: PropsWithChildren) => (
37+
<Dialog.Title className={styles.title}>{children}</Dialog.Title>
38+
);
39+
40+
const Description = ({ children }: PropsWithChildren) => (
41+
<Dialog.Description className={styles.description}>
42+
{children}
43+
</Dialog.Description>
44+
);
45+
46+
const Content = ({ children }: PropsWithChildren) => (
47+
<main className={styles.wrapper}>{children}</main>
48+
);
49+
50+
export { Modal, Title, Description, Content };

0 commit comments

Comments
 (0)