Skip to content

Commit c4fa4a1

Browse files
authored
Fix cutoff tab text by providing a ReactNode (#6505)
1 parent 1d43b24 commit c4fa4a1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/web/docs/src/app/gateway/gateway-feature-tabs.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export function GatewayFeatureTabs(props: { className?: string }) {
6161
'border-blue-200 [--tab-bg-dark:theme(colors.blue.300)] [--tab-bg:theme(colors.blue.200)]',
6262
props.className,
6363
)}
64+
tabTexts={{
65+
'Observability & Performance Monitoring': (
66+
<span>
67+
Observability & Performance{' '}
68+
<span className="[@media(width<420px)]:hidden">Monitoring</span>
69+
</span>
70+
),
71+
}}
6472
>
6573
<FeatureTab
6674
title="Observability & Performance Monitoring"

packages/web/docs/src/components/feature-tabs.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { createContext, useContext, useState } from 'react';
3+
import { createContext, ReactNode, useContext, useState } from 'react';
44
import Image, { StaticImageData } from 'next/image';
55
import NextLink from 'next/link';
66
import { ChevronDownIcon } from '@radix-ui/react-icons';
@@ -20,13 +20,18 @@ export interface FeatureTabsProps<T extends string> {
2020
highlights: Record<T, Highlight[]>;
2121
icons: React.ReactNode[];
2222
children: React.ReactNode;
23+
/**
24+
* On very narrow screens, we shorten the tab names.
25+
*/
26+
tabTexts?: Partial<Record<T, ReactNode>>;
2327
}
2428

2529
export function FeatureTabs<T extends string>({
2630
className,
2731
highlights,
2832
icons,
2933
children,
34+
tabTexts = {},
3035
}: FeatureTabsProps<T>) {
3136
const tabs = Object.keys(highlights) as T[];
3237
const [currentTab, setCurrentTab] = useState<T>(tabs[0]);
@@ -64,7 +69,7 @@ export function FeatureTabs<T extends string>({
6469
className='hive-focus rdx-state-active:text-green-1000 rdx-state-active:border-[--tab-bg-dark] rdx-state-active:bg-white max-sm:rdx-state-inactive:hidden group-focus-within:rdx-state-inactive:flex max-sm:rdx-state-inactive:rounded-none max-sm:group-focus-within:rdx-state-inactive:border-y-[--tab-bg] max-sm:group-focus-within:[&:nth-child(2)]:rdx-state-active:rounded-none max-sm:group-focus-within:[&:nth-child(2)]:rdx-state-active:border-y-[--tab-bg] max-sm:group-focus-within:first:rdx-state-active:border-b-[--tab-bg] max-sm:group-focus-within:first:rdx-state-active:rounded-b-none max-sm:rdx-state-inactive:pointer-events-none max-sm:rdx-state-inactive:group-focus-within:pointer-events-auto z-10 flex flex-1 items-center justify-center gap-2.5 rounded-lg border-transparent p-4 text-base font-medium leading-6 text-green-800 max-sm:border max-sm:border-[--tab-bg-dark] max-sm:bg-[--tab-bg] max-sm:group-focus-within:aria-selected:z-20 max-sm:group-focus-within:aria-selected:ring-4 sm:rounded-[15px] sm:border sm:text-xs sm:max-lg:p-3 sm:max-[721px]:p-2 md:text-sm lg:text-base max-sm:group-focus-within:[&:last-child]:border-t-[--tab-bg] max-sm:group-focus-within:[&:nth-child(3)]:rounded-t-none [&>svg]:shrink-0 max-sm:group-focus-within:[&[data-state="inactive"]:first-child]:rounded-t-lg max-sm:group-focus-within:[&[data-state="inactive"]:first-child]:border-t-[--tab-bg-dark] [&[data-state="inactive"]>:last-child]:invisible max-sm:group-focus-within:[[data-state="active"]+&:last-child]:rounded-b-lg max-sm:group-focus-within:[[data-state="active"]+&:last-child]:border-b-[--tab-bg-dark] max-sm:group-focus-within:[[data-state="inactive"]+&:last-child[data-state="inactive"]]:rounded-b-lg max-sm:group-focus-within:[[data-state="inactive"]+&:last-child[data-state="inactive"]]:border-b-[--tab-bg-dark]'
6570
>
6671
{icons[i]}
67-
{tab}
72+
{tabTexts[tab] || tab}
6873
<ChevronDownIcon className="ml-auto size-6 text-green-800 transition group-focus-within:rotate-90 sm:hidden" />
6974
</Tabs.Trigger>
7075
);

0 commit comments

Comments
 (0)