|
| 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 ToggleButton, { ToggleButtonProps } from '~components/toggle-button'; |
| 6 | + |
| 7 | +import createPermutations from '../utils/permutations'; |
| 8 | +import PermutationsView from '../utils/permutations-view'; |
| 9 | +import ScreenshotArea from '../utils/screenshot-area'; |
| 10 | + |
| 11 | +const permutations = createPermutations<ToggleButtonProps>([ |
| 12 | + { |
| 13 | + variant: ['normal'], |
| 14 | + children: ['Subscribe'], |
| 15 | + pressed: [false, true], |
| 16 | + disabled: [false, true], |
| 17 | + iconName: ['thumbs-up'], |
| 18 | + pressedIconName: ['thumbs-up-filled'], |
| 19 | + onChange: [() => {}], |
| 20 | + style: [ |
| 21 | + { |
| 22 | + root: { |
| 23 | + background: { |
| 24 | + default: '#2563eb', |
| 25 | + hover: '#1d4ed8', |
| 26 | + active: '#1e40af', |
| 27 | + disabled: '#bfdbfe', |
| 28 | + pressed: '#1e3a8a', |
| 29 | + }, |
| 30 | + borderColor: { |
| 31 | + default: '#2563eb', |
| 32 | + hover: '#1d4ed8', |
| 33 | + active: '#1e3a8a', |
| 34 | + disabled: '#60a5fa', |
| 35 | + pressed: '#1e3a8a', |
| 36 | + }, |
| 37 | + borderWidth: '2px', |
| 38 | + borderRadius: '0', |
| 39 | + boxShadow: { |
| 40 | + default: '0 1px 2px rgba(0, 0, 0, 0.05)', |
| 41 | + hover: '0 2px 4px rgba(59, 130, 246, 0.15)', |
| 42 | + active: '0 1px 2px rgba(0, 0, 0, 0.05)', |
| 43 | + disabled: 'none', |
| 44 | + pressed: '0 0 0 4px rgba(59, 130, 246, 0.2)', |
| 45 | + }, |
| 46 | + color: { |
| 47 | + default: '#ffffff', |
| 48 | + hover: '#ffffff', |
| 49 | + active: '#ffffff', |
| 50 | + disabled: '#0c4a6e', |
| 51 | + pressed: '#ffffff', |
| 52 | + }, |
| 53 | + paddingBlock: '10px', |
| 54 | + paddingInline: '16px', |
| 55 | + focusRing: { |
| 56 | + borderColor: '#3b82f6', |
| 57 | + borderRadius: '2px', |
| 58 | + borderWidth: '3px', |
| 59 | + }, |
| 60 | + }, |
| 61 | + }, |
| 62 | + { |
| 63 | + root: { |
| 64 | + background: { |
| 65 | + default: '#7c3aed', |
| 66 | + hover: '#6d28d9', |
| 67 | + active: '#5b21b6', |
| 68 | + disabled: '#ddd6fe', |
| 69 | + pressed: '#4c1d95', |
| 70 | + }, |
| 71 | + borderColor: { |
| 72 | + default: '#7c3aed', |
| 73 | + hover: '#6d28d9', |
| 74 | + active: '#5b21b6', |
| 75 | + disabled: '#c4b5fd', |
| 76 | + pressed: '#5b21b6', |
| 77 | + }, |
| 78 | + borderWidth: '2px', |
| 79 | + borderRadius: '12px', |
| 80 | + boxShadow: { |
| 81 | + default: '0 1px 3px rgba(0, 0, 0, 0.1)', |
| 82 | + hover: '0 4px 6px rgba(139, 92, 246, 0.2)', |
| 83 | + active: '0 2px 4px rgba(0, 0, 0, 0.1)', |
| 84 | + disabled: 'none', |
| 85 | + pressed: '0 0 0 4px rgba(139, 92, 246, 0.3)', |
| 86 | + }, |
| 87 | + color: { |
| 88 | + default: '#ffffff', |
| 89 | + hover: '#ffffff', |
| 90 | + active: '#ffffff', |
| 91 | + disabled: '#2e1065', |
| 92 | + pressed: '#ffffff', |
| 93 | + }, |
| 94 | + paddingBlock: '12px', |
| 95 | + paddingInline: '20px', |
| 96 | + focusRing: { |
| 97 | + borderColor: '#8b5cf6', |
| 98 | + borderRadius: '14px', |
| 99 | + borderWidth: '3px', |
| 100 | + }, |
| 101 | + }, |
| 102 | + }, |
| 103 | + ], |
| 104 | + }, |
| 105 | + { |
| 106 | + variant: ['icon'], |
| 107 | + pressed: [false, true], |
| 108 | + disabled: [false, true], |
| 109 | + iconName: ['thumbs-up'], |
| 110 | + pressedIconName: ['thumbs-up-filled'], |
| 111 | + onChange: [() => {}], |
| 112 | + ariaLabel: ['Toggle'], |
| 113 | + style: [ |
| 114 | + { |
| 115 | + root: { |
| 116 | + color: { |
| 117 | + default: 'light-dark(#3b82f6, #93c5fd)', |
| 118 | + hover: 'light-dark(#2563eb, #60a5fa)', |
| 119 | + active: 'light-dark(#1d4ed8, #3b82f6)', |
| 120 | + disabled: 'light-dark(#93c5fd, #94a3b8)', |
| 121 | + pressed: 'light-dark(#1e40af, #2563eb)', |
| 122 | + }, |
| 123 | + focusRing: { |
| 124 | + borderColor: '#3b82f6', |
| 125 | + borderRadius: '50%', |
| 126 | + borderWidth: '3px', |
| 127 | + }, |
| 128 | + }, |
| 129 | + }, |
| 130 | + { |
| 131 | + root: { |
| 132 | + color: { |
| 133 | + default: 'light-dark(#8b5cf6, #c4b5fd)', |
| 134 | + hover: 'light-dark(#7c3aed, #a78bfa)', |
| 135 | + active: 'light-dark(#6d28d9, #8b5cf6)', |
| 136 | + disabled: 'light-dark(#c4b5fd, #94a3b8)', |
| 137 | + pressed: 'light-dark(#5b21b6, #7c3aed)', |
| 138 | + }, |
| 139 | + focusRing: { |
| 140 | + borderColor: '#8b5cf6', |
| 141 | + borderRadius: '10px', |
| 142 | + borderWidth: '3px', |
| 143 | + }, |
| 144 | + }, |
| 145 | + }, |
| 146 | + ], |
| 147 | + }, |
| 148 | +]); |
| 149 | + |
| 150 | +export default function ToggleButtonStylePermutations() { |
| 151 | + return ( |
| 152 | + <> |
| 153 | + <h1>Toggle Button Style Permutations</h1> |
| 154 | + <ScreenshotArea disableAnimations={true}> |
| 155 | + <PermutationsView |
| 156 | + permutations={permutations} |
| 157 | + render={permutation => <ToggleButton ariaLabel="Toggle button" {...permutation} />} |
| 158 | + /> |
| 159 | + </ScreenshotArea> |
| 160 | + </> |
| 161 | + ); |
| 162 | +} |
0 commit comments