Files
doona/src/ui/styles/segmented.css
T
Zakk 5bdcc4e431 refactor(styles): move design tokens to foundations and split segmented
The :root tokens, their direction, pointer, phone and dark overrides move from
motion.css to the top of foundations.css, and the Segmented control rules move
to segmented.css, imported right after motion.css. Rules move verbatim; the
control size test follows the rules to their new file.
2026-10-04 01:33:16 +10:00

106 lines
3.3 KiB
CSS

/* Segmented control: the selection slides between items (200ms, ease-out). */
.rp-seg {
display: inline-flex;
/* Counts in segment labels tick without the neighbouring segments shifting. */
font-variant-numeric: tabular-nums;
gap: var(--rp-space-1);
max-width: 100%;
background: var(--rp-overlay);
border-radius: var(--rp-r-lg);
padding: var(--rp-control-block-inset) var(--rp-control-inset);
position: relative;
}
/* Always S2 size L (40px): every segmented control matches, in a page toolbar, a card or a panel alike. */
.rp-seg[data-size='L'] {
min-block-size: var(--rp-control-lg);
}
/* Flush with the track at L, so the items and the slider take the track's radius, as a tab does. */
.rp-seg[data-size='L'] > .rp-slider,
.rp-seg[data-size='L'] .rp-btn {
border-radius: var(--rp-r-lg);
}
.rp-seg[data-size='L'] .rp-btn {
height: var(--rp-control-lg);
padding-inline: var(--rp-lg-inset-compact);
font-size: var(--rp-lg-text);
}
/* Too narrow for its items, the track stays as a hidden placeholder and a picker sits over it at the same height. The
track hugs its items in a column or a grid too, where a flex or grid item would otherwise stretch. */
.rp-segfit {
position: relative;
display: inline-flex;
width: fit-content;
min-width: 0;
max-width: 100%;
}
.rp-segfit > .rp-seg {
flex: 1 1 auto;
min-width: 0;
}
/* Filling its line, the segments share the width equally and each label sits at the centre of its own segment. In a
flex row it grows far ahead of what sits beside it, which so keeps about its own width; alone on a line it fills it. */
.rp-segfit[data-fill] {
flex: 1000 1 auto;
}
.rp-segfit[data-fill] > .rp-seg .rp-btn {
flex: 1 1 0;
min-inline-size: 0;
justify-content: center;
text-align: center;
}
.rp-segfit[data-collapsed] > .rp-seg {
visibility: hidden;
overflow: hidden;
}
.rp-segpick {
position: absolute;
inset-block: 0;
inset-inline: 0 auto;
display: flex;
align-items: center;
max-width: 100%;
}
.rp-segpick > * {
min-width: 0;
max-width: 100%;
}
.rp-segpick .rp-selectbtn {
max-width: 100%;
}
.rp-slider {
position: absolute;
top: var(--rp-control-block-inset);
bottom: var(--rp-control-block-inset);
/* Physical on purpose: useSlider places it from offsetLeft, which counts from the left in either direction. */
left: 0;
border-radius: var(--rp-r-md);
background: var(--rp-surface);
border: 2px solid var(--rp-accent);
/* Animate layout to avoid text rasterisation flicker from a composited slider beneath the labels. */
transition:
left var(--rp-duration-panel) var(--rp-ease-out),
width var(--rp-duration-panel) var(--rp-ease-out);
pointer-events: none;
}
.rp-slider[data-still] {
transition: none;
}
.rp-seg .rp-btn {
flex: none;
padding: 0 var(--rp-space-2);
min-height: 0;
background: transparent;
color: var(--rp-text);
/* Regular labels keep small ideograph counters open at 1x rasterisation. */
font-weight: 400;
border-radius: var(--rp-r-md);
border: 2px solid transparent;
position: relative;
z-index: 1;
/* Like a tab: the label recolours as the slider arrives. */
transition:
color var(--rp-duration-tab) var(--rp-ease) var(--rp-delay-tab),
background-color var(--rp-duration) var(--rp-ease),
transform var(--rp-duration) var(--rp-ease);
}