Skip to content

Commit 046cfb4

Browse files
feat: Improve CodeTabs tab naming (nodejs#8552)
* feat(style): update code tab badge styling (nodejs#8549) * feat(tabs): enhance tab structure by replacing secondaryLabel with extension * feat(tabs): update tab extension rendering and style adjustments * feat(tabs): separate tab extension configuration into a new story * feat(tabs): update tab labels to reflect correct file extensions
1 parent f578190 commit 046cfb4

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

packages/ui-components/src/Common/CodeTabs/index.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ const TabsContent: FC = () => (
6161

6262
export const Default: Story = {};
6363

64+
export const WithExtension: Story = {
65+
args: {
66+
tabs: [
67+
{ key: 'mjs', label: 'Example', extension: 'MJS' },
68+
{ key: 'cjs', label: 'Example', extension: 'CJS' },
69+
],
70+
},
71+
};
72+
6473
export default {
6574
component: CodeTabs,
6675
args: {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
text-neutral-800
2323
dark:text-neutral-200;
2424

25+
.tabExtension {
26+
@apply ml-1
27+
rounded-xs
28+
border
29+
border-neutral-200
30+
px-1
31+
py-0.5
32+
text-xs
33+
font-normal
34+
text-neutral-200;
35+
}
36+
2537
.tabSecondaryLabel {
2638
@apply pl-1
2739
text-neutral-500
@@ -34,6 +46,11 @@
3446
dark:border-b-green-400
3547
dark:text-green-400;
3648

49+
.tabExtension {
50+
@apply border-green-400
51+
text-green-400;
52+
}
53+
3754
.tabSecondaryLabel {
3855
@apply text-green-800
3956
dark:text-green-600;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Tab = {
1010
label: string;
1111
secondaryLabel?: string;
1212
value?: string;
13+
extension?: string;
1314
};
1415

1516
type TabsProps = TabsPrimitive.TabsProps & {
@@ -37,6 +38,9 @@ const Tabs: FC<PropsWithChildren<TabsProps>> = ({
3738
className={classNames(styles.tabsTrigger, triggerClassName)}
3839
>
3940
{tab.label}
41+
{tab.extension && (
42+
<span className={styles.tabExtension}>{tab.extension}</span>
43+
)}
4044
{tab.secondaryLabel ? (
4145
<span className={styles.tabSecondaryLabel}>
4246
{tab.secondaryLabel}

0 commit comments

Comments
 (0)