Skip to content

AI media harness for planning, generating, and editing locally

TypeScript
11.1 KB
Raw Blame
/* ============================================================================
   controls.css — shared UI primitives used by every surface.
   Buttons, icon buttons, text fields, check boxes, radios and sliders: the
   WinUI control set, in CSS.
   ========================================================================== */

/* --- Buttons ---------------------------------------------------------------
   The three WinUI button styles, at 32px with 4px corners (tokens.css rules
   4 and 5):

     .primary-button    AccentButtonStyle — the one committed action
     .secondary-button  the standard Button — neutral fill, primary ink
     .icon-button       a subtle square icon button, transparent at rest

   A standard control's edge is a 1px stroke with a slightly darker bottom
   edge, which is the only "elevation" a Fluent control has. Hover and press
   change the fill and nothing else, over --motion-fast. */

.primary-button,
.secondary-button {
  min-height: var(--control-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  white-space: nowrap;
  transition: var(--transition-control);
}

.primary-button {
  border-color: var(--button-primary-stroke);
  border-bottom-color: var(--button-primary-stroke-bottom);
  color: var(--on-accent);
  background: var(--button-primary-bg);
  font-weight: var(--weight-semibold);
}

.primary-button:hover:not(:disabled) { background: var(--button-primary-hover); }
.primary-button:active:not(:disabled) { background: var(--button-primary-active); }

/* opacity on a saturated fill produces a hazy blue that reads as a rendering
   fault rather than as "off". Disabled is its own fill and ink. */
.primary-button:disabled {
  opacity: 1;
  border-color: transparent;
  color: var(--button-primary-off-ink);
  background: var(--button-primary-off-bg);
}

.secondary-button {
  border-color: var(--stroke-control);
  border-bottom-color: var(--stroke-control-bottom);
  color: var(--text-primary);
  background: var(--fill-control);
}

.secondary-button:hover:not(:disabled) {
  background: var(--fill-control-hover);
}

.secondary-button:active:not(:disabled) {
  color: var(--text-secondary);
  background: var(--fill-control-pressed);
}

.secondary-button:disabled {
  border-color: var(--stroke-control);
  color: var(--text-disabled);
  background: var(--fill-control-disabled);
}

/* --- Icon buttons ---------------------------------------------------------- */

.icon-button {
  width: var(--icon-button);
  height: var(--icon-button);
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background: transparent;
  transition: var(--transition-control);
}

.icon-button:hover:not(:disabled) {
  background: var(--fill-subtle-hover);
}

.icon-button:active:not(:disabled) {
  color: var(--text-secondary);
  background: var(--fill-subtle-pressed);
}

.icon-button:disabled {
  color: var(--text-disabled);
}

/* An icon button whose work is under way (the Work queue while a job runs,
   the Agent toggle during a turn): an accent arc turns around the glyph,
   the indeterminate ProgressRing's motion at the button's size. */
.icon-button--busy {
  position: relative;
}

.icon-button--busy::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  pointer-events: none;
}

/* A toggle icon button that is on (.icon-button--checked / aria-pressed)
   takes the shared on-state in ui.css ("Toggle on-state"). */

/* --- Text fields ------------------------------------------------------------
   The Fluent TextBox: 32px, 4px corners, a hairline edge whose BOTTOM is the
   strong stroke, and — while typing — a 2px accent underline and a slightly
   lifted fill. No outline and no halo; base.css keeps the keyboard ring off
   text inputs for exactly this reason.

   The underline below applies to every text input and textarea in the app at
   zero specificity (:where), so any screen's own field rule still wins on the
   properties it sets. It is drawn as a border colour plus a 1px inset shadow
   so the field does not grow a pixel on focus. A composite field — a bordered
   wrapper around a borderless input, like .ui-textfield — draws the underline
   on the wrapper instead and sets `box-shadow: none` on the inner input so
   the two never stack. */

.text-field {
  height: var(--field-height);
  min-width: 0;
  padding: 0 var(--space-3);
  border: 1px solid var(--stroke-control);
  border-bottom-color: var(--stroke-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background: var(--fill-control);
  font-size: var(--text-base);
  transition: var(--transition-control);
}

.text-field:hover:not(:focus, :disabled) {
  background: var(--fill-control-hover);
}

:where(
  input:not([type]),
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="password"],
  input[type="url"],
  input[type="email"],
  textarea
):focus {
  outline: none;
  border-bottom-color: var(--field-focus-line);
  box-shadow: inset 0 -1px 0 var(--field-focus-line);
}

.text-field:focus {
  background: var(--fill-input-focus);
}

/* --- Check box, radio button, slider ----------------------------------------
   Global element styling, so every screen gets the Fluent controls without a
   class. The platform's own check box is a web control in a Windows frame.

   Check boxes and radios are 20px with a strong 1px stroke at rest and an
   accent fill when on; the check and the dash are masks (--glyph-check,
   --glyph-dash in tokens.css) painted in --on-accent. The geometry is written
   at doubled attribute specificity on purpose: several screens size EVERY
   input in a form row (`.reference-dialog input { width: 100% }`), which a
   native check box survived by drawing itself centred and a styled one would
   not. A rule that really means to size a check box still can, with a class
   and an attribute. Hidden inputs behind custom cards (theme choice, project
   type) stay hidden: they are absolutely positioned and clipped or
   transparent, whatever their box. */

input[type="checkbox"][type="checkbox"],
input[type="radio"][type="radio"] {
  appearance: none;
  width: var(--check-size);
  height: var(--check-size);
  min-width: var(--check-size);
  min-height: 0;
  flex: none;
  display: inline-grid;
  place-content: center;
  margin: 0;
  padding: 0;
  vertical-align: middle;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-sm);
  background: var(--fill-control-alt);
  transition: var(--transition-control);
}

input[type="radio"][type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  background-color: var(--on-accent);
  -webkit-mask: var(--glyph-check) center / contain no-repeat;
  mask: var(--glyph-check) center / contain no-repeat;
  visibility: hidden;
}

input[type="checkbox"]:indeterminate::before {
  -webkit-mask-image: var(--glyph-dash);
  mask-image: var(--glyph-dash);
}

input[type="radio"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--on-accent);
  visibility: hidden;
  transition: width var(--motion-fast) linear, height var(--motion-fast) linear;
}

input:is([type="checkbox"], [type="radio"]):hover:not(:disabled) {
  background-color: var(--fill-subtle-hover);
}

input:is([type="checkbox"], [type="radio"]):active:not(:disabled) {
  background-color: var(--fill-subtle-pressed);
}

input:is([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked) {
  border-color: var(--accent-fill);
  background-color: var(--accent-fill);
}

input:is([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked):hover:not(:disabled) {
  border-color: var(--button-primary-hover);
  background-color: var(--button-primary-hover);
}

input:is([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked):active:not(:disabled) {
  border-color: var(--button-primary-active);
  background-color: var(--button-primary-active);
}

input:is([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked)::before {
  visibility: visible;
}

/* The radio's dot answers the pointer the way WinUI's does: it grows under
   the mouse and shrinks while pressed. */
input[type="radio"]:checked:hover:not(:disabled)::before { width: 14px; height: 14px; }
input[type="radio"]:checked:active:not(:disabled)::before { width: 10px; height: 10px; }

input:is([type="checkbox"], [type="radio"]):disabled {
  border-color: var(--text-disabled);
  background-color: transparent;
}

input:is([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked):disabled {
  border-color: transparent;
  background-color: var(--accent-disabled);
}

input:is([type="checkbox"], [type="radio"]):disabled::before {
  background-color: var(--on-accent-disabled);
}

/* The slider: a 4px track, filled with the accent up to the value, and a
   20px disc with an accent dot that grows under the mouse and shrinks while
   dragged. CSS cannot read an input's value, so the filled part comes from
   `--p` (a percentage) set inline by whoever renders the slider, e.g.
   style={{ "--p": "40%" }}. Unset, the track shows unfilled. The export
   scrubber keeps its own look (export.css), which overrides this at higher
   specificity. */
input[type="range"] {
  --p: 0%;                             /* the value as a percentage; set it inline on the input */
  --thumb-dot: 6px;                    /* radius of the accent dot */
  appearance: none;
  height: var(--control-md);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent-fill) 0 var(--p),
    var(--stroke-strong) var(--p) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: var(--slider-thumb);
  height: var(--slider-thumb);
  margin-top: calc((4px - var(--slider-thumb)) / 2);
  border: 1px solid var(--stroke-control);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--accent-fill) 0 var(--thumb-dot),
    var(--thumb-bg) calc(var(--thumb-dot) + 0.5px)
  );
}

input[type="range"]:hover:not(:disabled) { --thumb-dot: 7px; }
input[type="range"]:active:not(:disabled) { --thumb-dot: 5px; }

input[type="range"]:disabled::-webkit-slider-runnable-track {
  background: var(--accent-disabled);
}

input[type="range"]:disabled::-webkit-slider-thumb {
  background: radial-gradient(
    circle,
    var(--accent-disabled) 0 var(--thumb-dot),
    var(--thumb-bg) calc(var(--thumb-dot) + 0.5px)
  );
}

/* Toasts are gone: errors and notices are InfoBars placed inline under the
   command bar or title bar (src/components/ui/InfoBar.tsx). */