Some checks failed
Build pull request / Build pull request (pull_request) Failing after 6m8s
Soul: selected and hover shared one 80% value and the press state lost to hover on specificity. Now hover 74%, selected 84%, pressed 92%. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
152 lines
4.3 KiB
TypeScript
152 lines
4.3 KiB
TypeScript
import { ComplexStyleRule, createVar, style } from '@vanilla-extract/css';
|
|
import { RecipeVariants, recipe } from '@vanilla-extract/recipes';
|
|
import { ContainerColor, DefaultReset, Disabled, RadiiVariant, color, config, toRem } from 'folds';
|
|
import { surfaceInk } from '../../features/scene/sceneShell.css';
|
|
|
|
export const NavCategory = style([
|
|
DefaultReset,
|
|
{
|
|
position: 'relative',
|
|
},
|
|
]);
|
|
|
|
export const NavCategoryHeader = style({
|
|
gap: config.space.S100,
|
|
selectors: {
|
|
// Category labels sit on the scene like the rows do, and need the same scrim to be read.
|
|
':root[data-scene] &': {
|
|
backgroundColor: `color-mix(in srgb, ${surfaceInk} 62%, transparent)`,
|
|
borderRadius: config.radii.R400,
|
|
},
|
|
},
|
|
});
|
|
|
|
export const NavLink = style({
|
|
color: 'inherit',
|
|
minWidth: 0,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
cursor: 'pointer',
|
|
flexGrow: 1,
|
|
':hover': {
|
|
textDecoration: 'unset',
|
|
},
|
|
':focus': {
|
|
outline: 'none',
|
|
},
|
|
});
|
|
|
|
const Container = createVar();
|
|
const ContainerHover = createVar();
|
|
const ContainerActive = createVar();
|
|
const ContainerLine = createVar();
|
|
const OnContainer = createVar();
|
|
|
|
const getVariant = (variant: ContainerColor): ComplexStyleRule => ({
|
|
vars: {
|
|
[Container]: color[variant].Container,
|
|
[ContainerHover]: color[variant].ContainerHover,
|
|
[ContainerActive]: color[variant].ContainerActive,
|
|
[ContainerLine]: color[variant].ContainerLine,
|
|
[OnContainer]: color[variant].OnContainer,
|
|
},
|
|
});
|
|
|
|
const NavItemBase = style({
|
|
width: '100%',
|
|
display: 'flex',
|
|
justifyContent: 'start',
|
|
cursor: 'pointer',
|
|
backgroundColor: Container,
|
|
color: OnContainer,
|
|
outline: 'none',
|
|
minHeight: toRem(36),
|
|
|
|
selectors: {
|
|
'&:hover, &:focus-visible': {
|
|
backgroundColor: ContainerHover,
|
|
},
|
|
'&[data-hover=true]': {
|
|
backgroundColor: ContainerHover,
|
|
},
|
|
// While the background scene runs the shell is clear (sceneShell.css.ts); a row is a steady
|
|
// scrim of the theme's own surface, so ridges never show through its text. Hover, the selected row and a
|
|
// press each strengthen it a step.
|
|
':root[data-scene] &': {
|
|
backgroundColor: `color-mix(in srgb, ${surfaceInk} 62%, transparent)`,
|
|
},
|
|
':root[data-scene] &:hover, :root[data-scene] &:focus-visible, :root[data-scene] &[data-hover=true]':
|
|
{
|
|
backgroundColor: `color-mix(in srgb, ${surfaceInk} 74%, transparent)`,
|
|
},
|
|
':root[data-scene] &[aria-selected=true]': {
|
|
backgroundColor: `color-mix(in srgb, ${surfaceInk} 84%, transparent)`,
|
|
},
|
|
[`:root[data-scene] &:has(.${NavLink}:active)`]: {
|
|
backgroundColor: `color-mix(in srgb, ${surfaceInk} 92%, transparent)`,
|
|
},
|
|
[`&:has(.${NavLink}:active)`]: {
|
|
backgroundColor: ContainerActive,
|
|
},
|
|
'&[aria-selected=true]': {
|
|
backgroundColor: ContainerActive,
|
|
},
|
|
[`&:has(.${NavLink}:focus-visible)`]: {
|
|
outline: `${config.borderWidth.B600} solid ${ContainerLine}`,
|
|
outlineOffset: `calc(-1 * ${config.borderWidth.B600})`,
|
|
},
|
|
},
|
|
'@supports': {
|
|
[`not selector(:has(.${NavLink}:focus-visible))`]: {
|
|
':focus-within': {
|
|
outline: `${config.borderWidth.B600} solid ${ContainerLine}`,
|
|
outlineOffset: `calc(-1 * ${config.borderWidth.B600})`,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
export const NavItem = recipe({
|
|
base: [DefaultReset, NavItemBase, Disabled],
|
|
variants: {
|
|
variant: {
|
|
Background: getVariant('Background'),
|
|
Surface: getVariant('Surface'),
|
|
SurfaceVariant: getVariant('SurfaceVariant'),
|
|
Primary: getVariant('Primary'),
|
|
Secondary: getVariant('Secondary'),
|
|
Success: getVariant('Success'),
|
|
Warning: getVariant('Warning'),
|
|
Critical: getVariant('Critical'),
|
|
},
|
|
radii: RadiiVariant,
|
|
},
|
|
defaultVariants: {
|
|
variant: 'Surface',
|
|
radii: '400',
|
|
},
|
|
});
|
|
|
|
export type RoomSelectorVariants = RecipeVariants<typeof NavItem>;
|
|
export const NavItemContent = style({
|
|
paddingLeft: config.space.S200,
|
|
paddingRight: config.space.S300,
|
|
height: 'inherit',
|
|
minWidth: 0,
|
|
flexGrow: 1,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
fontWeight: config.fontWeight.W500,
|
|
|
|
selectors: {
|
|
'&:hover': {
|
|
textDecoration: 'unset',
|
|
},
|
|
[`.${NavItemBase}[data-highlight=true] &`]: {
|
|
fontWeight: config.fontWeight.W600,
|
|
},
|
|
},
|
|
});
|
|
|
|
export const NavItemOptions = style({
|
|
paddingRight: config.space.S200,
|
|
});
|