|
1 | 1 | import { styled, ToggleButton, ToggleButtonProps } from '@mui/material'; |
2 | | -import React from 'react'; |
3 | 2 | import { figVars } from 'src/utils/figmaColors'; |
| 3 | +import { darkScheme } from 'src/utils/theme'; |
| 4 | + |
| 5 | +// Dimmed inactive label: fg-max at 0.3 opacity in light, full opacity in dark. Shared by the |
| 6 | +// resting state and the disabled-not-selected state (which must re-assert it over MUI's default). |
| 7 | +const dimmedInactive = { |
| 8 | + color: figVars['fg-max'], |
| 9 | + opacity: 0.3, |
| 10 | + ...darkScheme({ opacity: 1 }), |
| 11 | +}; |
| 12 | + |
| 13 | +// Active pill: a bg-max fill with a border-1 ring in light; a bg-5 fill and no ring in dark, fg-max |
| 14 | +// label at full opacity. Shared by Mui-selected/focus and disabled-selected (some consumers disable |
| 15 | +// the active tab). |
| 16 | +const activeFill = { |
| 17 | + opacity: 1, |
| 18 | + color: figVars['fg-max'], |
| 19 | + backgroundColor: figVars['bg-max'], |
| 20 | + boxShadow: `inset 0 0 0 1px ${figVars['border-1']}`, |
| 21 | + ...darkScheme({ |
| 22 | + backgroundColor: figVars['bg-5'], |
| 23 | + boxShadow: 'none', |
| 24 | + }), |
| 25 | +}; |
4 | 26 |
|
5 | 27 | const CustomTxModalToggleButton = styled(ToggleButton)<ToggleButtonProps>({ |
6 | 28 | border: 0, |
7 | 29 | flex: 1, |
8 | 30 | height: '100%', |
9 | | - color: figVars['fg-3'], |
| 31 | + // Label typography (H5) is owned by each consumer's <Typography variant="h5">. |
| 32 | + ...dimmedInactive, |
10 | 33 |
|
11 | | - // Inactive hover: brighten the label only (fg-3 → fg-2), never a background. |
| 34 | + // Inactive hover: nudge the opacity up in light; unchanged in dark. Never a background. |
12 | 35 | '&:hover': { |
13 | 36 | backgroundColor: 'transparent', |
14 | | - color: figVars['fg-2'], |
| 37 | + opacity: 0.5, |
| 38 | + ...darkScheme({ opacity: 1 }), |
15 | 39 | }, |
16 | 40 |
|
17 | | - // Active — and keyboard focus (Mui-focusVisible): a solid fill one step darker than the |
18 | | - // `bg-1` track (no shadow; the group carries the only ring) with primary text. |
19 | | - '&.Mui-selected, &.Mui-selected:hover, &.Mui-focusVisible': { |
20 | | - backgroundColor: figVars['bg-4'], |
21 | | - color: figVars['fg-1'], |
22 | | - }, |
| 41 | + '&.Mui-selected, &.Mui-focusVisible': activeFill, |
23 | 42 |
|
24 | | - // Disabled but NOT selected: muted, still readable. |
25 | | - '&.Mui-disabled:not(.Mui-selected)': { |
26 | | - color: figVars['fg-3'], |
27 | | - opacity: 0.5, |
| 43 | + // Active hover: step the fill one shade (bg-max → bg-1 light, bg-5 → bg-6 dark); the ring persists. |
| 44 | + '&.Mui-selected:hover': { |
| 45 | + backgroundColor: figVars['bg-1'], |
| 46 | + ...darkScheme({ backgroundColor: figVars['bg-6'] }), |
28 | 47 | }, |
29 | 48 |
|
30 | | - // Disabled + selected: preserve the selected look (some consumers disable the active tab). |
31 | | - '&.Mui-disabled.Mui-selected': { |
32 | | - backgroundColor: figVars['bg-4'], |
33 | | - color: figVars['fg-1'], |
34 | | - opacity: 1, |
35 | | - }, |
| 49 | + '&.Mui-disabled:not(.Mui-selected)': dimmedInactive, |
| 50 | + '&.Mui-disabled.Mui-selected': activeFill, |
36 | 51 | }) as typeof ToggleButton; |
37 | 52 |
|
38 | 53 | export function StyledTxModalToggleButton(props: ToggleButtonProps) { |
|
0 commit comments