Skip to content

Commit 636b10d

Browse files
authored
feat(tabs): Add new variant to be used on issue details (#75029)
this pr adds a new variant of tabs - "floating" , which will be used on the updated issue details page
1 parent dede3f9 commit 636b10d

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

static/app/components/tabs/index.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ export default storyBook(Tabs, story => {
209209
</TabPanels>
210210
</Tabs>
211211
</SizingWindow>
212+
<br />
213+
<p>You can also use the "floating" variant, which is used below</p>
214+
<SizingWindow>
215+
<Tabs>
216+
<TabList variant="floating" hideBorder>
217+
{TABS.map(tab => (
218+
<TabList.Item key={tab.key}>{tab.label}</TabList.Item>
219+
))}
220+
</TabList>
221+
<TabPanels>
222+
{TABS.map(tab => (
223+
<TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
224+
))}
225+
</TabPanels>
226+
</Tabs>
227+
</SizingWindow>
212228
</div>
213229
));
214230
});

static/app/components/tabs/tab.tsx

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface BaseTabProps {
5656
*/
5757
borderStyle?: 'solid' | 'dashed';
5858
to?: string;
59-
variant?: 'flat' | 'filled';
59+
variant?: 'flat' | 'filled' | 'floating';
6060
}
6161

6262
export const BaseTab = forwardRef(
@@ -99,13 +99,28 @@ export const BaseTab = forwardRef(
9999
borderStyle={borderStyle}
100100
ref={ref}
101101
>
102-
<FilledStyledInteractionStateLayer hasSelectedBackground={false} />
103-
<FilledFocusLayer />
102+
<VariantStyledInteractionStateLayer hasSelectedBackground={false} />
103+
<VariantFocusLayer />
104104
{props.children}
105105
</FilledTabWrap>
106106
);
107107
}
108108

109+
if (variant === 'floating') {
110+
return (
111+
<FloatingTabWrap
112+
{...tabProps}
113+
hidden={hidden}
114+
overflowing={overflowing}
115+
ref={ref}
116+
>
117+
<VariantStyledInteractionStateLayer hasSelectedBackground={false} />
118+
<VariantFocusLayer />
119+
{props.children}
120+
</FloatingTabWrap>
121+
);
122+
}
123+
109124
return (
110125
<TabWrap
111126
{...tabProps}
@@ -164,6 +179,36 @@ export const Tab = forwardRef(
164179
}
165180
);
166181

182+
const FloatingTabWrap = styled('li', {shouldForwardProp: tabsShouldForwardProp})<{
183+
overflowing: boolean;
184+
}>`
185+
&[aria-selected='true'] {
186+
${p =>
187+
`
188+
color: ${p.theme.purple400};
189+
font-weight: ${p.theme.fontWeightBold};
190+
background-color: ${p.theme.purple100};
191+
`}
192+
}
193+
&[aria-selected='false'] {
194+
border-top: 1px solid transparent;
195+
}
196+
color: ${p => p.theme.gray300};
197+
border-radius: 6px;
198+
padding: ${space(0.5)} ${space(1)};
199+
transform: translateY(1px);
200+
cursor: pointer;
201+
&:focus {
202+
outline: none;
203+
}
204+
${p =>
205+
p.overflowing &&
206+
`
207+
opacity: 0;
208+
pointer-events: none;
209+
`}
210+
`;
211+
167212
const FilledTabWrap = styled('li', {shouldForwardProp: tabsShouldForwardProp})<{
168213
borderStyle: 'dashed' | 'solid';
169214
overflowing: boolean;
@@ -289,7 +334,7 @@ const StyledInteractionStateLayer = styled(InteractionStateLayer)<{
289334
bottom: ${p => (p.orientation === 'horizontal' ? space(0.75) : 0)};
290335
`;
291336

292-
const FilledStyledInteractionStateLayer = styled(InteractionStateLayer)`
337+
const VariantStyledInteractionStateLayer = styled(InteractionStateLayer)`
293338
position: absolute;
294339
width: auto;
295340
height: auto;
@@ -319,7 +364,7 @@ const FocusLayer = styled('div')<{orientation: Orientation}>`
319364
}
320365
`;
321366

322-
const FilledFocusLayer = styled('div')`
367+
const VariantFocusLayer = styled('div')`
323368
position: absolute;
324369
left: 0;
325370
right: 0;

static/app/components/tabs/tabList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const TabListWrap = styled('ul', {shouldForwardProp: tabsShouldForwardProp})<{
297297
? `
298298
grid-auto-flow: column;
299299
justify-content: start;
300-
gap: ${p.variant === 'filled' ? space(0) : space(2)};
300+
gap: ${p.variant === 'filled' || p.variant === 'floating' ? space(0) : space(2)};
301301
${!p.hideBorder && `border-bottom: solid 1px ${p.theme.border};`}
302302
`
303303
: `

0 commit comments

Comments
 (0)