Skip to content

Commit 51388a1

Browse files
committed
Use Badges for release status in version dropdown
1 parent 5b828c9 commit 51388a1

File tree

5 files changed

+67
-10
lines changed

5 files changed

+67
-10
lines changed

apps/site/components/Downloads/Release/VersionDropdown.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,27 @@ import {
1313
import type { NodeReleaseStatus } from '#site/types/releases.js';
1414
import type { FC } from 'react';
1515

16-
const getDropDownStatus = (version: string, status: NodeReleaseStatus) => {
16+
const getDropDownStatus = (status: NodeReleaseStatus) => {
1717
if (status === 'LTS') {
18-
return `${version} (LTS)`;
18+
return {
19+
label: 'LTS',
20+
kind: 'info' as const,
21+
};
1922
}
2023

2124
if (status === 'Current') {
22-
return `${version} (Current)`;
25+
return {
26+
label: 'Current',
27+
kind: 'default' as const,
28+
};
2329
}
2430

2531
if (status === 'End-of-life') {
26-
return `${version} (EoL)`;
32+
return {
33+
label: 'EoL',
34+
kind: 'warning' as const,
35+
};
2736
}
28-
29-
return version;
3037
};
3138

3239
const VersionDropdown: FC = () => {
@@ -61,7 +68,8 @@ const VersionDropdown: FC = () => {
6168
ariaLabel={t('layouts.download.dropdown.version')}
6269
values={releases.map(({ status, versionWithPrefix }) => ({
6370
value: versionWithPrefix,
64-
label: getDropDownStatus(versionWithPrefix, status),
71+
label: versionWithPrefix,
72+
badge: getDropDownStatus(status),
6573
}))}
6674
defaultValue={release.versionWithPrefix}
6775
onChange={setVersionOrNavigate}

apps/site/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
33
/// <reference types="next/navigation-types/compat/navigation" />
4-
import './.next/types/routes.d.ts';
4+
import './.next/dev/types/routes.d.ts';
55

66
// NOTE: This file should not be edited
77
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

packages/ui-components/src/Common/Select/StatelessSelect/index.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ChevronDownIcon } from '@heroicons/react/24/solid';
22
import classNames from 'classnames';
33
import { useId, useMemo } from 'react';
44

5+
import Badge from '#ui/Common/Badge';
6+
57
import type { SelectGroup, SelectProps } from '#ui/Common/Select';
68
import type { LinkLike } from '#ui/types';
79

@@ -66,6 +68,15 @@ const StatelessSelect = <T extends string>({
6668
<span className={styles.selectedValue}>
6769
{currentItem.iconImage}
6870
<span>{currentItem.label}</span>
71+
{currentItem.badge && (
72+
<Badge
73+
size="small"
74+
kind={currentItem.badge.kind}
75+
className={styles.badge}
76+
>
77+
{currentItem.badge.label}
78+
</Badge>
79+
)}
6980
</span>
7081
)}
7182
{!currentItem && (
@@ -89,7 +100,13 @@ const StatelessSelect = <T extends string>({
89100
)}
90101

91102
{items.map(
92-
({ value, label, iconImage, disabled: itemDisabled }) => (
103+
({
104+
value,
105+
label,
106+
iconImage,
107+
badge,
108+
disabled: itemDisabled,
109+
}) => (
93110
<Component
94111
key={value}
95112
href={value}
@@ -101,6 +118,15 @@ const StatelessSelect = <T extends string>({
101118
>
102119
{iconImage}
103120
<span>{label}</span>
121+
{badge && (
122+
<Badge
123+
size="small"
124+
kind={badge.kind}
125+
className={styles.badge}
126+
>
127+
{badge.label}
128+
</Badge>
129+
)}
104130
</Component>
105131
)
106132
)}

packages/ui-components/src/Common/Select/index.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@
109109
@apply text-neutral-600
110110
dark:text-neutral-400;
111111
}
112+
113+
.badge {
114+
@apply ml-auto;
115+
}
112116
}
113117

114118
.dropdown:has(.label) .text > span {

packages/ui-components/src/Common/Select/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
55
import classNames from 'classnames';
66
import { useId, useMemo, useState } from 'react';
77

8+
import Badge, { type BadgeKind } from '#ui/Common/Badge';
89
import Skeleton from '#ui/Common/Skeleton';
910

1011
import type { FormattedMessage, LinkLike } from '#ui/types';
@@ -18,6 +19,10 @@ export type SelectValue<T extends string> = {
1819
label: FormattedMessage | string;
1920
value: T;
2021
iconImage?: ReactElement<SVGSVGElement>;
22+
badge?: {
23+
label: FormattedMessage | string;
24+
kind?: BadgeKind;
25+
};
2126
disabled?: boolean;
2227
};
2328

@@ -89,7 +94,7 @@ const Select = <T extends string>({
8994
</SelectPrimitive.Label>
9095
)}
9196

92-
{items.map(({ value, label, iconImage, disabled }) => (
97+
{items.map(({ value, label, iconImage, badge, disabled }) => (
9398
<SelectPrimitive.Item
9499
key={value}
95100
value={value}
@@ -99,6 +104,11 @@ const Select = <T extends string>({
99104
<SelectPrimitive.ItemText>
100105
{iconImage}
101106
<span>{label}</span>
107+
{badge && (
108+
<Badge size="small" kind={badge.kind} className={styles.badge}>
109+
{badge.label}
110+
</Badge>
111+
)}
102112
</SelectPrimitive.ItemText>
103113
</SelectPrimitive.Item>
104114
))}
@@ -149,6 +159,15 @@ const Select = <T extends string>({
149159
<>
150160
{currentItem.iconImage}
151161
<span>{currentItem.label}</span>
162+
{currentItem.badge && (
163+
<Badge
164+
size="small"
165+
kind={currentItem.badge.kind}
166+
className={styles.badge}
167+
>
168+
{currentItem.badge.label}
169+
</Badge>
170+
)}
152171
</>
153172
)}
154173
</SelectPrimitive.Value>

0 commit comments

Comments
 (0)