-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat: add toggle to show/hide LTS releases #8263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
efekrskl
wants to merge
15
commits into
nodejs:main
Choose a base branch
from
efekrskl:feat/eol-table-lts-toggle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b37d970
feat: add switch in eol table
efekrskl 680b0ca
feat: translation keys
efekrskl 6f7ab98
refactor: client renaming
efekrskl bdf5ce9
fix: dont create arrow fn onCheckedChange
efekrskl aebe830
chore: use tilde for version
efekrskl 4502c6c
refactor: rename prop
efekrskl f530878
fixes test, but does it?
bmuenzenmeyer 39eb665
fix: add use client directive
efekrskl fee09ef
fix: apply motion safe
efekrskl a0ae7e0
refactor: use size instead of w&h
efekrskl 8cbd84a
fix: use motion safe
efekrskl d73475e
refactor: use import type for types
efekrskl ce14ae6
fix: adjust focus visible ring offset
efekrskl a90d6ce
Merge remote-tracking branch 'upstream/main' into feat/eol-table-lts-…
efekrskl 52fd77b
chore: update pnpm lock
efekrskl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| 'use client'; | ||
|
|
||
| import Switch from '@node-core/ui-components/Common/Switch'; | ||
| import { useTranslations } from 'next-intl'; | ||
| import type { FC } from 'react'; | ||
| import { Fragment, useState } from 'react'; | ||
|
|
||
| import FormattedTime from '#site/components/Common/FormattedTime'; | ||
| import LinkWithArrow from '#site/components/Common/LinkWithArrow'; | ||
| import EOLModal from '#site/components/EOL/EOLModal'; | ||
| import VulnerabilityChips from '#site/components/EOL/VulnerabilityChips'; | ||
| import type { NodeRelease } from '#site/types/releases.js'; | ||
| import type { GroupedVulnerabilities } from '#site/types/vulnerabilities.js'; | ||
|
|
||
| type EOLReleaseTableBodyProps = { | ||
| eolReleases: Array<NodeRelease>; | ||
| vulnerabilities: GroupedVulnerabilities; | ||
| }; | ||
|
|
||
| const EOLReleaseTableClient: FC<EOLReleaseTableBodyProps> = ({ | ||
| eolReleases, | ||
| vulnerabilities, | ||
| }) => { | ||
| const t = useTranslations(); | ||
|
|
||
| const [currentModal, setCurrentModal] = useState<string | undefined>(); | ||
| const [hideNonLts, setHideNonLts] = useState(false); | ||
|
|
||
| const filteredReleases = hideNonLts | ||
| ? eolReleases.filter(release => release.isLts) | ||
| : eolReleases; | ||
|
|
||
| return ( | ||
| <> | ||
| <Switch | ||
| label={t('components.eolTable.hideNonLts')} | ||
| checked={hideNonLts} | ||
| onCheckedChange={setHideNonLts} | ||
| /> | ||
| <table id="tbVulnerabilities"> | ||
| <thead> | ||
| <tr> | ||
| <th> | ||
| {t('components.eolTable.version')} ( | ||
| {t('components.eolTable.codename')}) | ||
| </th> | ||
| <th>{t('components.eolTable.lastUpdated')}</th> | ||
| <th>{t('components.eolTable.vulnerabilities')}</th> | ||
| <th>{t('components.eolTable.details')}</th> | ||
| </tr> | ||
| </thead> | ||
|
|
||
| <tbody> | ||
| {filteredReleases.map(release => ( | ||
| <Fragment key={release.major}> | ||
| <tr> | ||
| <td data-label="Version"> | ||
| v{release.major}{' '} | ||
| {release.codename ? `(${release.codename})` : ''} | ||
| </td> | ||
|
|
||
| <td data-label="Date"> | ||
| <FormattedTime date={release.releaseDate} /> | ||
| </td> | ||
|
|
||
| <td> | ||
| <VulnerabilityChips | ||
| vulnerabilities={vulnerabilities[release.major]} | ||
| /> | ||
| </td> | ||
|
|
||
| <td> | ||
| <LinkWithArrow | ||
| className="cursor-pointer" | ||
| onClick={() => setCurrentModal(release.version)} | ||
| > | ||
| {t('components.downloadReleasesTable.details')} | ||
| </LinkWithArrow> | ||
| </td> | ||
| </tr> | ||
|
|
||
| <EOLModal | ||
| release={release} | ||
| vulnerabilities={vulnerabilities[release.major]} | ||
| open={currentModal === release.version} | ||
| onOpenChange={open => open || setCurrentModal(undefined)} | ||
| /> | ||
| </Fragment> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default EOLReleaseTableClient; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| @reference "../../styles/index.css"; | ||
|
|
||
| .switch { | ||
| @apply inline-flex | ||
| justify-end | ||
| gap-3; | ||
|
|
||
| .label { | ||
| @apply cursor-pointer | ||
| select-none | ||
| text-sm | ||
| font-medium | ||
| text-neutral-800 | ||
| dark:text-neutral-200; | ||
| } | ||
|
|
||
| .root { | ||
| @apply w-10.5 | ||
| relative | ||
| inline-flex | ||
| h-6 | ||
| cursor-pointer | ||
| items-center | ||
| rounded-full | ||
| bg-black | ||
| focus:outline-none | ||
| focus-visible:ring-2 | ||
| focus-visible:ring-green-500 | ||
| focus-visible:ring-offset-2 | ||
| focus-visible:ring-offset-neutral-100 | ||
| motion-safe:transition-colors | ||
| motion-safe:duration-100 | ||
| motion-safe:ease-out | ||
| dark:bg-neutral-700 | ||
| dark:focus-visible:ring-green-400 | ||
| dark:focus-visible:ring-offset-neutral-900; | ||
| } | ||
|
|
||
| .root[data-state='checked'] { | ||
| @apply bg-green-600; | ||
| } | ||
|
|
||
| .thumb { | ||
| @apply pointer-events-none | ||
| block | ||
| size-5 | ||
| translate-x-0.5 | ||
| rounded-full | ||
| bg-white | ||
| ring-0 | ||
| motion-safe:transition-transform | ||
| motion-safe:duration-100 | ||
| motion-safe:ease-out; | ||
| } | ||
|
|
||
| .thumb[data-state='checked'] { | ||
| @apply translate-x-5; | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
packages/ui-components/src/Common/Switch/index.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { Meta as MetaObj, StoryObj } from '@storybook/react'; | ||
| import { useState } from 'react'; | ||
|
|
||
| import Switch from '#ui/Common/Switch'; | ||
|
|
||
| type Story = StoryObj<typeof Switch>; | ||
| type Meta = MetaObj<typeof Switch>; | ||
|
|
||
| export const Uncontrolled: Story = { | ||
| args: { | ||
| label: 'Enable Feature', | ||
| }, | ||
| }; | ||
|
|
||
| export const Controlled: Story = { | ||
| args: { | ||
| label: 'Enable Feature', | ||
| }, | ||
| render: args => { | ||
| const [checked, setChecked] = useState(false); | ||
|
|
||
| return <Switch {...args} checked={checked} onCheckedChange={setChecked} />; | ||
| }, | ||
| }; | ||
|
|
||
| export const WithoutLabel: Story = {}; | ||
|
|
||
| export default { | ||
| component: Switch, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| } as Meta; |
bmuenzenmeyer marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| 'use client'; | ||
|
|
||
| import * as SwitchPrimitive from '@radix-ui/react-switch'; | ||
| import classNames from 'classnames'; | ||
| import { useId } from 'react'; | ||
| import type { FC, PropsWithChildren } from 'react'; | ||
|
|
||
| import styles from './index.module.css'; | ||
|
|
||
| type SwitchProps = SwitchPrimitive.SwitchProps & { | ||
| label?: string; | ||
| checked?: boolean; | ||
| onCheckedChange?: (checked: boolean) => void; | ||
| thumbClassName?: string; | ||
| }; | ||
|
|
||
| const Switch: FC<PropsWithChildren<SwitchProps>> = ({ | ||
| label, | ||
| checked, | ||
| onCheckedChange, | ||
| className, | ||
| thumbClassName, | ||
| ...props | ||
| }) => { | ||
| const id = useId(); | ||
|
|
||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return ( | ||
| <div className={styles.switch}> | ||
| {label && ( | ||
| <label className={styles.label} htmlFor={id}> | ||
| {label} | ||
| </label> | ||
| )} | ||
| <SwitchPrimitive.Root | ||
| id={id} | ||
| className={classNames(styles.root, className)} | ||
| checked={checked} | ||
| onCheckedChange={onCheckedChange} | ||
| {...props} | ||
| > | ||
| <SwitchPrimitive.Thumb | ||
| className={classNames(styles.thumb, thumbClassName)} | ||
| /> | ||
| </SwitchPrimitive.Root> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Switch; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.