Files
whenkit/styles.css
T
CatoandClaude Opus 5.5 ad4c1ed6f6 fix: the day strip never props open a dialog or grid column (0.2.1) (#3)
Fourteen chips side by side gave the strip a wide min-content width, and a
CSS grid item (a modal dialog's content) grows to that: in OrangeCat's
booking dialog it pushed Send off-screen at 390px. The strip now claims no
inline size of its own (contain: inline-size) and scrolls inside whatever
it is given.

The browser check could not see this: the demo gave its grid cells
min-width: 0. It now has a dialog-shaped container and checks the dialog's
button stays on screen — verified to FAIL without the fix.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 03:05:22 -07:00

308 lines
6.3 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-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 field over the native picker ---- */
.wk-field {
display: flex;
flex-direction: column;
gap: 0.375rem;
}
.wk-field-box {
position: relative;
display: flex;
align-items: center;
gap: 0.5rem;
min-height: var(--wk-target);
padding: 0 0.875rem;
border: 1px solid var(--wk-line-2);
border-radius: var(--wk-radius);
background: var(--wk-bg);
}
.wk-field-box:focus-within {
outline: 2px solid var(--wk-accent);
outline-offset: 1px;
border-color: var(--wk-accent);
}
.wk-field-text {
flex: 1;
min-width: 0;
font-size: var(--wk-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wk-field-box[data-empty] .wk-field-text {
color: var(--wk-muted);
}
.wk-field-icon {
width: 1.25rem;
height: 1.25rem;
flex: 0 0 auto;
color: var(--wk-fg-2);
}
/* The real control: full-size, invisible, on top — taps open the native
picker, keyboard entry and autofill keep working. 16px so iOS does not zoom. */
.wk-field-input {
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;
}
/* "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-field-box {
align-self: flex-start;
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;
}
}