Skip to content

Commit 8568662

Browse files
authored
feat: implement style api for tabs component (#4109)
1 parent 1bfc081 commit 8568662

File tree

14 files changed

+992
-201
lines changed

14 files changed

+992
-201
lines changed

build-tools/utils/custom-css-properties.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ const customCssPropertiesList = [
110110
'stylePlaceholderFontSize',
111111
'stylePlaceholderFontStyle',
112112
'stylePlaceholderFontWeight',
113+
// Tabs style properties
114+
'styleTabsActiveIndicatorColor',
115+
'styleTabsActiveIndicatorWidth',
116+
'styleTabsActiveIndicatorBorderRadius',
117+
'styleTabsSeparatorColor',
118+
'styleTabsSeparatorWidth',
113119
// Alert focus ring properties
114120
'alertFocusRingBorderColor',
115121
'alertFocusRingBorderRadius',
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import React from 'react';
4+
5+
import Tabs, { TabsProps } from '~components/tabs';
6+
7+
import createPermutations from '../utils/permutations';
8+
import PermutationsView from '../utils/permutations-view';
9+
import ScreenshotArea from '../utils/screenshot-area';
10+
11+
// Rounded with background
12+
const style1 = {
13+
container: {
14+
// container styling is tested in pages/container/style-custom.page.tsx
15+
root: {
16+
borderRadius: '0px',
17+
},
18+
},
19+
tab: {
20+
backgroundColor: {
21+
default: 'light-dark(#f1f5f9, #1e293b)',
22+
hover: 'light-dark(#dbeafe, #1e3a8a)',
23+
active: 'light-dark(#2563eb, #1d4ed8)',
24+
disabled: 'light-dark(#f8fafc, #1e293b)',
25+
},
26+
borderColor: {
27+
default: 'lightblue',
28+
hover: 'lightblue',
29+
active: 'lightblue',
30+
disabled: 'lightblue',
31+
},
32+
borderWidth: '2px',
33+
borderRadius: '40px',
34+
color: {
35+
default: 'light-dark(#475569, #94a3b8)',
36+
hover: 'light-dark(#1e3a8a, #dbeafe)',
37+
active: 'light-dark(#ffffff, #ffffff)',
38+
disabled: 'light-dark(#cbd5e1, #64748b)',
39+
},
40+
fontSize: '14px',
41+
fontWeight: '600',
42+
paddingBlock: '10px',
43+
paddingInline: '24px',
44+
focusRing: {
45+
borderColor: 'light-dark(#f97316, #fb923c)',
46+
borderRadius: '22px',
47+
borderWidth: '2px',
48+
},
49+
activeIndicator: {
50+
color: 'transparent',
51+
},
52+
},
53+
tabSeparator: {
54+
color: 'light-dark(#e2e8f0, #334155)',
55+
width: '1px',
56+
},
57+
header: {
58+
borderColor: 'light-dark(#cbd5e1, #475569)',
59+
borderWidth: '2px',
60+
},
61+
};
62+
63+
// Border colors with background
64+
const style2 = {
65+
tab: {
66+
backgroundColor: {
67+
default: 'light-dark(#fef3c7, #422006)',
68+
hover: 'light-dark(#fde68a, #713f12)',
69+
active: 'light-dark(#fbbf24, #d97706)',
70+
disabled: 'light-dark(#fef9e7, #78350f)',
71+
},
72+
borderColor: {
73+
default: 'transparent',
74+
hover: 'transparent',
75+
active: 'transparent',
76+
disabled: 'transparent',
77+
},
78+
borderWidth: '0px',
79+
borderRadius: '8px 8px 0 0',
80+
color: {
81+
default: 'light-dark(#92400e, #fef3c7)',
82+
hover: 'light-dark(#78350f, #fef9e7)',
83+
active: 'light-dark(#451a03, #ffffff)',
84+
disabled: 'light-dark(#cbd5e1, #b5b1a3ff)',
85+
},
86+
fontSize: '14px',
87+
fontWeight: '600',
88+
paddingBlock: '12px',
89+
paddingInline: '20px',
90+
focusRing: {
91+
borderColor: 'light-dark(#f59e0b, #fbbf24)',
92+
borderRadius: '8px',
93+
borderWidth: '2px',
94+
},
95+
activeIndicator: {
96+
color: 'light-dark(#f59e0b, #fbbf24)',
97+
width: '4px',
98+
borderRadius: '4px',
99+
},
100+
},
101+
tabSeparator: {
102+
color: 'light-dark(#fde68a, #78350f)',
103+
width: '2px',
104+
},
105+
};
106+
107+
const permutations = createPermutations<TabsProps>([
108+
{
109+
tabs: [
110+
[
111+
{ id: 'first', label: 'First tab', content: 'First tab content' },
112+
{ id: 'second', label: 'Second tab', content: 'Second tab content' },
113+
{ id: 'third', label: 'Third tab', content: 'Third tab content', disabled: true },
114+
],
115+
],
116+
activeTabId: ['first', 'second'],
117+
variant: ['default', 'container', 'stacked'],
118+
disableContentPaddings: [false, true],
119+
style: [style1, style2],
120+
},
121+
]);
122+
123+
export default function TabsStylePermutations() {
124+
return (
125+
<>
126+
<h1>Tabs Style Permutations</h1>
127+
128+
<ScreenshotArea disableAnimations={true}>
129+
<PermutationsView
130+
permutations={permutations}
131+
render={permutation => (
132+
<Tabs
133+
{...permutation}
134+
i18nStrings={{ scrollLeftAriaLabel: 'Scroll left', scrollRightAriaLabel: 'Scroll right' }}
135+
/>
136+
)}
137+
/>
138+
</ScreenshotArea>
139+
</>
140+
);
141+
}

0 commit comments

Comments
 (0)