mirror of
https://github.com/bitbaum/whenkit.git
synced 2026-12-03 19:27:33 +01:00
- line-height: normal (the font's own, like a native input) instead of 1.3, and an icon that fits a normal line: the box is now exactly a native input's height (38 vs 38; it was 40 vs 38, a visible step in form rows). - structure rules on span.wk-input so an app's own unlayered class with display:block on the same element cannot collapse the stacked layout. - codemod: an object spread inside onChange is no longer flagged as a JSX prop spread. Both browser checks were first run failing against the old CSS. Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
354 lines
7.8 KiB
CSS
354 lines
7.8 KiB
CSS
/*
|
|
* @bitbaum/whenkit — the look of picking a day and a time.
|
|
*
|
|
* Every colour, radius and face is a --wk-* variable. By default they read
|
|
* @bitbaum/design-tokens' HSL-triplet variables, so apps on those tokens match
|
|
* without doing anything; any other app sets --wk-* once. Same scheme as
|
|
* @bitbaum/chatkit.
|
|
*
|
|
* Non-negotiable, and why:
|
|
* - 44px touch targets on every chip (WCAG 2.5.8 — a thumb has to land on it).
|
|
* - 16px text in the date field: under 16px iOS zooms the page on focus.
|
|
* - The day strip scrolls inside itself; nothing is wider than its container
|
|
* at 320px (min-width: 0 on flex rows).
|
|
*/
|
|
|
|
:where(:root) {
|
|
--wk-bg: hsl(var(--surface-base, 0 0% 100%));
|
|
--wk-raised: hsl(var(--surface-raised, 0 0% 96%));
|
|
--wk-fg: hsl(var(--text-primary, 0 0% 10%));
|
|
--wk-fg-2: hsl(var(--text-secondary, 0 0% 30%));
|
|
--wk-muted: hsl(var(--text-muted, 0 0% 46%));
|
|
--wk-line: hsl(var(--border-subtle, 0 0% 90%));
|
|
--wk-line-2: hsl(var(--border-default, 0 0% 80%));
|
|
--wk-accent: var(--accent-primary, #ff5c00);
|
|
--wk-on-accent: hsl(var(--on-accent, 0 0% 8%));
|
|
--wk-accent-soft: color-mix(in srgb, var(--wk-accent) 14%, transparent);
|
|
--wk-radius: var(--radius-control, 0.625rem);
|
|
--wk-font: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
|
|
--wk-danger: hsl(var(--status-negative, 0 65% 50%));
|
|
--wk-text: 1rem;
|
|
--wk-small: 0.8125rem;
|
|
--wk-target: 2.75rem;
|
|
}
|
|
|
|
.wk-picker,
|
|
.wk-group,
|
|
.wk-field {
|
|
font-family: var(--wk-font);
|
|
color: var(--wk-fg);
|
|
min-width: 0;
|
|
}
|
|
|
|
.wk-picker *,
|
|
.wk-group *,
|
|
.wk-field * {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.wk-picker {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.wk-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.wk-label {
|
|
font-size: var(--wk-small);
|
|
font-weight: 600;
|
|
color: var(--wk-fg-2);
|
|
}
|
|
|
|
.wk-sr-only {
|
|
position: absolute;
|
|
width: 1px;
|
|
height: 1px;
|
|
margin: -1px;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
clip: rect(0 0 0 0);
|
|
white-space: nowrap;
|
|
border: 0;
|
|
}
|
|
|
|
.wk-hint {
|
|
margin: 0;
|
|
font-size: var(--wk-small);
|
|
color: var(--wk-muted);
|
|
}
|
|
|
|
/* ---- chips: times, lengths, modes ---- */
|
|
|
|
.wk-chips {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.5rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.wk-chip {
|
|
min-height: var(--wk-target);
|
|
min-width: var(--wk-target);
|
|
padding: 0 0.9rem;
|
|
border: 1px solid var(--wk-line-2);
|
|
border-radius: 999px;
|
|
background: var(--wk-bg);
|
|
color: var(--wk-fg);
|
|
font: inherit;
|
|
font-size: 0.9375rem;
|
|
font-variant-numeric: tabular-nums;
|
|
cursor: pointer;
|
|
transition:
|
|
background 120ms,
|
|
border-color 120ms;
|
|
}
|
|
|
|
.wk-chip:hover:not(:disabled) {
|
|
border-color: var(--wk-fg-2);
|
|
}
|
|
|
|
.wk-chip[data-selected] {
|
|
background: var(--wk-accent);
|
|
border-color: var(--wk-accent);
|
|
color: var(--wk-on-accent);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.wk-chip:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
/* ---- the day strip ---- */
|
|
|
|
.wk-strip {
|
|
/* Claim no width of its own: fourteen chips side by side must scroll inside
|
|
whatever space the strip is given, not prop open a grid or dialog column
|
|
(a CSS grid item's min-width is its content's). Found in OrangeCat's
|
|
booking dialog, where it pushed Send off-screen at 390px. */
|
|
contain: inline-size;
|
|
width: 100%;
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
overflow-x: auto;
|
|
overscroll-behavior-x: contain;
|
|
scroll-snap-type: x proximity;
|
|
padding-bottom: 0.25rem;
|
|
min-width: 0;
|
|
scrollbar-width: thin;
|
|
}
|
|
|
|
.wk-day {
|
|
flex: 0 0 auto;
|
|
scroll-snap-align: start;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.1rem;
|
|
min-width: 4.25rem;
|
|
min-height: 4.5rem;
|
|
padding: 0 0.625rem;
|
|
border: 1px solid var(--wk-line-2);
|
|
border-radius: var(--wk-radius);
|
|
background: var(--wk-bg);
|
|
color: var(--wk-fg);
|
|
font: inherit;
|
|
cursor: pointer;
|
|
line-height: 1.15;
|
|
}
|
|
|
|
.wk-day-top,
|
|
.wk-day-bottom {
|
|
font-size: 0.75rem;
|
|
color: var(--wk-fg-2);
|
|
max-width: 100%;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.wk-day-num {
|
|
font-size: 1.25rem;
|
|
font-weight: 650;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.wk-day:hover:not(:disabled) {
|
|
border-color: var(--wk-fg-2);
|
|
}
|
|
|
|
.wk-day[data-selected] {
|
|
background: var(--wk-accent-soft);
|
|
border-color: var(--wk-accent);
|
|
}
|
|
|
|
.wk-day[data-selected] .wk-day-top,
|
|
.wk-day[data-selected] .wk-day-bottom {
|
|
color: var(--wk-fg);
|
|
}
|
|
|
|
.wk-day[data-edge] {
|
|
background: var(--wk-accent);
|
|
color: var(--wk-on-accent);
|
|
}
|
|
|
|
.wk-day[data-edge] .wk-day-top,
|
|
.wk-day[data-edge] .wk-day-bottom {
|
|
color: var(--wk-on-accent);
|
|
}
|
|
|
|
.wk-day:disabled {
|
|
opacity: 0.35;
|
|
cursor: not-allowed;
|
|
text-decoration: line-through;
|
|
}
|
|
|
|
/* ---- the readable date input over the native picker ---- */
|
|
|
|
.wk-field {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.375rem;
|
|
}
|
|
|
|
/* The visible box, in two parts.
|
|
STRUCTURE (unlayered): what the stacked native input needs to work.
|
|
LOOK (@layer base): border, padding, colour, size. A named low layer, so an
|
|
app's own classes always win — Tailwind v4 utilities and component classes
|
|
sit in higher layers, plain app CSS is unlayered — and the date input then
|
|
looks like the app's other inputs, not like ours. (Unlayered defaults would
|
|
have beaten Tailwind's layered utilities.) No min-height: a compact input
|
|
stays compact; the picker sets its own 44px where it needs it. */
|
|
/* span.wk-input, not .wk-input: structure must hold even when an app's own
|
|
unlayered input class sets display:block on this same element. */
|
|
span.wk-input {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
box-sizing: border-box;
|
|
min-width: 0;
|
|
}
|
|
|
|
@layer base {
|
|
.wk-input {
|
|
width: 100%;
|
|
padding: 0.7rem 0.875rem;
|
|
border: 1px solid var(--wk-line-2);
|
|
border-radius: var(--wk-radius);
|
|
background: var(--wk-bg);
|
|
color: inherit;
|
|
font: inherit;
|
|
font-size: var(--wk-text);
|
|
/* The font's own line height, exactly like a native input — a fixed 1.3
|
|
made the date box a different height from its neighbours. */
|
|
line-height: normal;
|
|
}
|
|
}
|
|
|
|
.wk-field .wk-input,
|
|
.wk-other .wk-input {
|
|
min-height: var(--wk-target);
|
|
}
|
|
|
|
.wk-input:focus-within {
|
|
outline: 2px solid var(--wk-accent);
|
|
outline-offset: 1px;
|
|
}
|
|
|
|
.wk-input[data-invalid] {
|
|
border-color: var(--wk-danger, #dc2626);
|
|
}
|
|
|
|
.wk-input[data-disabled] {
|
|
opacity: 0.55;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.wk-input-text {
|
|
flex: 1;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
text-align: left;
|
|
}
|
|
|
|
.wk-input[data-empty] .wk-input-text {
|
|
opacity: 0.55;
|
|
}
|
|
|
|
.wk-input-icon {
|
|
/* em, not rem, and no taller than a normal line: the icon scales with the
|
|
field's own text, so neither a dense 12px input nor a serif-font one is made
|
|
taller than its neighbours by it. */
|
|
width: 1.1em;
|
|
height: 1.1em;
|
|
flex: 0 0 auto;
|
|
opacity: 0.7;
|
|
}
|
|
|
|
/* The real control: full-size, invisible, on top — taps open the native
|
|
picker, keyboard entry, autofill and validation keep working. 16px so iOS
|
|
does not zoom the page on focus. */
|
|
.wk-input-native {
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
opacity: 0;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
border: 0;
|
|
margin: 0;
|
|
padding: 0;
|
|
color-scheme: light dark;
|
|
}
|
|
|
|
.wk-input-native:disabled {
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
/* "Another date…" under the strip is a quiet secondary control. */
|
|
.wk-other .wk-label {
|
|
position: absolute;
|
|
width: 1px;
|
|
height: 1px;
|
|
overflow: hidden;
|
|
clip: rect(0 0 0 0);
|
|
}
|
|
|
|
.wk-other .wk-input {
|
|
align-self: flex-start;
|
|
width: auto;
|
|
border-style: dashed;
|
|
}
|
|
|
|
/* ---- the sentence the provider will read ---- */
|
|
|
|
.wk-summary {
|
|
margin: 0;
|
|
padding: 0.75rem 0.875rem;
|
|
border-radius: var(--wk-radius);
|
|
background: var(--wk-raised);
|
|
font-size: var(--wk-text);
|
|
font-weight: 600;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.wk-summary[data-empty] {
|
|
display: none;
|
|
}
|
|
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.wk-chip {
|
|
transition: none;
|
|
}
|
|
}
|