|
| 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 | +// No background, underline |
| 12 | +const style1 = { |
| 13 | + tabs: { |
| 14 | + backgroundColor: { |
| 15 | + default: 'transparent', |
| 16 | + hover: 'light-dark(rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.15))', |
| 17 | + active: 'transparent', |
| 18 | + disabled: 'transparent', |
| 19 | + }, |
| 20 | + borderColor: { |
| 21 | + default: 'transparent', |
| 22 | + hover: 'transparent', |
| 23 | + active: 'transparent', |
| 24 | + disabled: 'transparent', |
| 25 | + }, |
| 26 | + borderWidth: '0px', |
| 27 | + borderRadius: '6px', |
| 28 | + color: { |
| 29 | + default: 'light-dark(#64748b, #94a3b8)', |
| 30 | + hover: 'light-dark(#1e293b, #e2e8f0)', |
| 31 | + active: 'light-dark(#0f172a, #ffffff)', |
| 32 | + disabled: 'light-dark(#cbd5e1, #475569)', |
| 33 | + }, |
| 34 | + fontSize: '14px', |
| 35 | + fontWeight: '500', |
| 36 | + paddingBlock: '12px', |
| 37 | + paddingInline: '20px', |
| 38 | + focusRing: { |
| 39 | + borderColor: 'light-dark(#3b82f6, #60a5fa)', |
| 40 | + borderRadius: '6px', |
| 41 | + borderWidth: '2px', |
| 42 | + }, |
| 43 | + }, |
| 44 | + underline: { |
| 45 | + color: 'light-dark(#3b82f6, #60a5fa)', |
| 46 | + width: '3px', |
| 47 | + borderRadius: '3px 3px 0 0', |
| 48 | + }, |
| 49 | + divider: { |
| 50 | + color: 'transparent', |
| 51 | + width: '0px', |
| 52 | + }, |
| 53 | + headerDivider: { |
| 54 | + color: 'light-dark(#e2e8f0, #334155)', |
| 55 | + width: '1px', |
| 56 | + }, |
| 57 | +}; |
| 58 | + |
| 59 | +// Rounded with background |
| 60 | +const style2 = { |
| 61 | + tabs: { |
| 62 | + backgroundColor: { |
| 63 | + default: 'light-dark(#f1f5f9, #1e293b)', |
| 64 | + hover: 'light-dark(#dbeafe, #1e3a8a)', |
| 65 | + active: 'light-dark(#2563eb, #1d4ed8)', |
| 66 | + disabled: 'light-dark(#f8fafc, #1e293b)', |
| 67 | + }, |
| 68 | + borderColor: { |
| 69 | + default: 'transparent', |
| 70 | + hover: 'transparent', |
| 71 | + active: 'transparent', |
| 72 | + disabled: 'transparent', |
| 73 | + }, |
| 74 | + borderWidth: '0px', |
| 75 | + borderRadius: '20px', |
| 76 | + color: { |
| 77 | + default: 'light-dark(#475569, #94a3b8)', |
| 78 | + hover: 'light-dark(#1e3a8a, #dbeafe)', |
| 79 | + active: 'light-dark(#ffffff, #ffffff)', |
| 80 | + disabled: 'light-dark(#cbd5e1, #64748b)', |
| 81 | + }, |
| 82 | + fontSize: '14px', |
| 83 | + fontWeight: '600', |
| 84 | + paddingBlock: '10px', |
| 85 | + paddingInline: '24px', |
| 86 | + focusRing: { |
| 87 | + borderColor: 'light-dark(#2563eb, #60a5fa)', |
| 88 | + borderRadius: '22px', |
| 89 | + borderWidth: '2px', |
| 90 | + }, |
| 91 | + }, |
| 92 | + underline: { |
| 93 | + color: 'transparent', |
| 94 | + width: '0px', |
| 95 | + borderRadius: '0px', |
| 96 | + }, |
| 97 | + divider: { |
| 98 | + color: 'light-dark(#e2e8f0, #334155)', |
| 99 | + width: '1px', |
| 100 | + }, |
| 101 | + headerDivider: { |
| 102 | + color: 'light-dark(#cbd5e1, #475569)', |
| 103 | + width: '1px', |
| 104 | + }, |
| 105 | +}; |
| 106 | + |
| 107 | +// Border colors with background |
| 108 | +const style3 = { |
| 109 | + tabs: { |
| 110 | + backgroundColor: { |
| 111 | + default: 'light-dark(#fef3c7, #422006)', |
| 112 | + hover: 'light-dark(#fde68a, #713f12)', |
| 113 | + active: 'light-dark(#fbbf24, #d97706)', |
| 114 | + disabled: 'light-dark(#fef9e7, #78350f)', |
| 115 | + }, |
| 116 | + borderColor: { |
| 117 | + default: 'transparent', |
| 118 | + hover: 'transparent', |
| 119 | + active: 'transparent', |
| 120 | + disabled: 'transparent', |
| 121 | + }, |
| 122 | + borderWidth: '0px', |
| 123 | + borderRadius: '8px 8px 0 0', |
| 124 | + color: { |
| 125 | + default: 'light-dark(#92400e, #fef3c7)', |
| 126 | + hover: 'light-dark(#78350f, #fef9e7)', |
| 127 | + active: 'light-dark(#451a03, #ffffff)', |
| 128 | + disabled: 'light-dark(#d1d5db, #78350f)', |
| 129 | + }, |
| 130 | + fontSize: '14px', |
| 131 | + fontWeight: '600', |
| 132 | + paddingBlock: '12px', |
| 133 | + paddingInline: '20px', |
| 134 | + focusRing: { |
| 135 | + borderColor: 'light-dark(#f59e0b, #fbbf24)', |
| 136 | + borderRadius: '8px', |
| 137 | + borderWidth: '2px', |
| 138 | + }, |
| 139 | + }, |
| 140 | + underline: { |
| 141 | + color: 'light-dark(#f59e0b, #fbbf24)', |
| 142 | + width: '4px', |
| 143 | + borderRadius: '4px 4px 0 0', |
| 144 | + }, |
| 145 | + divider: { |
| 146 | + color: 'light-dark(#fde68a, #78350f)', |
| 147 | + width: '1px', |
| 148 | + }, |
| 149 | + headerDivider: { |
| 150 | + color: 'light-dark(#fde047, #92400e)', |
| 151 | + width: '2px', |
| 152 | + }, |
| 153 | +}; |
| 154 | + |
| 155 | +const permutations = createPermutations<TabsProps>([ |
| 156 | + { |
| 157 | + tabs: [ |
| 158 | + [ |
| 159 | + { id: 'first', label: 'First tab', content: 'First tab content' }, |
| 160 | + { id: 'second', label: 'Second tab', content: 'Second tab content' }, |
| 161 | + { id: 'third', label: 'Third tab', content: 'Third tab content', disabled: true }, |
| 162 | + ], |
| 163 | + ], |
| 164 | + activeTabId: ['first', 'second'], |
| 165 | + variant: ['default', 'container', 'stacked'], |
| 166 | + disableContentPaddings: [false, true], |
| 167 | + style: [style1, style2, style3], |
| 168 | + }, |
| 169 | +]); |
| 170 | + |
| 171 | +export default function TabsStylePermutations() { |
| 172 | + return ( |
| 173 | + <> |
| 174 | + <h1>Tabs Style Permutations</h1> |
| 175 | + <ScreenshotArea disableAnimations={true}> |
| 176 | + <PermutationsView |
| 177 | + permutations={permutations} |
| 178 | + render={permutation => ( |
| 179 | + <Tabs |
| 180 | + {...permutation} |
| 181 | + i18nStrings={{ scrollLeftAriaLabel: 'Scroll left', scrollRightAriaLabel: 'Scroll right' }} |
| 182 | + /> |
| 183 | + )} |
| 184 | + /> |
| 185 | + </ScreenshotArea> |
| 186 | + </> |
| 187 | + ); |
| 188 | +} |
0 commit comments