Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

13.0 KB
Raw Blame
@import "../styles/theme.css";

:root {
  --s-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Near-opaque app surface (theme.css --color-background at 98%). Auto-flips
     light/dark with --color-background, so no dark-mode override is needed. */
  --s-surface: color-mix(in srgb, var(--color-background) 98%, transparent);
  /* Accent = logo pink; flips automatically via --color-logo-primary. */
  --s-accent: var(--color-logo-primary);
  /* The rest come from theme.css, which already follows the theme setting. */
  --s-accent-soft: color-mix(
    in srgb,
    var(--color-logo-primary) 20%,
    transparent
  );
  --s-muted: var(--color-ink-2);
  --s-faint: var(--color-ink-3);
  --s-border: var(--color-line);
  --s-hair: var(--color-wash);

  /* Card geometry — single source of truth for the visible overlay sizes. The
     native overlay window (overlay.rs) is sized from these: it must be at least
     the card's max footprint (--ov-work-w for compact, --ov-open-w for Live),
     since the card is anchored flush to the screen edge in CSS. Keep overlay.rs
     in sync when these change. */
  --ov-rest-w: 172px; /* resting compact pill (minimal, recording) -- roomy enough
                         for the English working label before the grow starts */
  --ov-pill-w: 184px; /* base width / Live pill before it opens or collapses */
  --ov-work-w: 216px; /* working pill (transcribing / polishing) -- wide enough to
                         center longer labels; shared by Live (collapsed) + minimal */
  --ov-open-w: 392px; /* Live panel, expanded */
  --ov-base-h: 40px; /* control-row height (.sbase) */
  --ov-cap-max-h: 64px; /* max height of the scrolling live-text region */
}
/* ============================================================
   Unified overlay stage — one fixed, transparent container shared by the compact
   pill and the Live panel (both render the same `.scard` base). The card is
   anchored flush to the screen-edge side (bottom by default, top when placed up
   top) and centered horizontally, so the visible card sits exactly
   OVERLAY_*_OFFSET from the screen edge regardless of window height — only the
   offsets in overlay.rs move it. Pops scale from that edge, so the card is never
   drawn past it (matters for the 4px top offset on Windows/Linux).
   ============================================================ */
.ov-stage {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center; /* horizontal centering, kept for both forms */
  align-items: flex-end; /* bottom placement: flush to the bottom edge */
  font-family: var(--s-font);
}
.ov-stage.top {
  align-items: flex-start; /* top placement: flush to the top edge */
}

/* Compact pill: fade the whole container in/out (the pill itself never pops or
   morphs). */
.ov-fade {
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.ov-fade.show {
  opacity: 1;
}

/* Top placement, Live panel: stack the control pill above the text region so the
   card grows downward from its top edge (oldest line under the pill, newest at
   the bottom) — mirroring the bottom overlay's upward flow. The compact pill has
   no flowing text, so this only affects the Live panel. The text region keeps the
   same fade + scroll-pin; older lines dissolve up under the pill. */
.ov-stage.top .scard {
  /* column-reverse stacks the control pill above the text region. */
  flex-direction: column-reverse;
  transform-origin: top center;
}
.ov-stage.top .stext-cap {
  /* Mirror of the bottom overlay (top: 12 / bottom: 0): the first line sits flush
     under the pill and the breathing room moves below the text. The top fade is
     off at rest — at zero top padding it would dim the resting first line — and
     switches on (below) only once text overflows. */
  padding-top: 0;
  padding-bottom: 12px;
  -webkit-mask-image: none;
  mask-image: none;
}
/* Once live text overflows, fade older lines up under the pill, matching the
   bottom overlay's top fade. Gated on `.overflowing` so a short resting line
   (sitting at the very top) is never dimmed. */
.ov-stage.top .stext-cap.overflowing {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
}
.ov-stage.top .stext-cap p {
  /* Top-anchor short text just under the pill; on overflow the cap still pins to
     the bottom (newest visible) and older lines fade off the top, same as bottom. */
  margin: 0;
}

/* Shared base card. Flat: theme surface + hairline border, no shadow or blur. */
.scard {
  width: var(--ov-pill-w);
  /* Never wider than the window: an unaccounted content zoom degrades to a
     narrower card instead of clipping. 2px = our border (no border-box reset). */
  max-width: calc(100vw - 2px);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: none; /* hold our own width; never let the stage flex shrink the card */
  transform-origin: bottom center;
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  /* Flat: no drop shadow, no backdrop blur/saturate (was a glassy gradient look). */
  /* pop-in plays on mount; morph (width/radius) is a transition */
  animation: scard-pop 460ms cubic-bezier(0.22, 1, 0.36, 1);
  transition:
    width 460ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 460ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, width, opacity;
}
@keyframes scard-pop {
  from {
    opacity: 0;
    /* Scale from the anchored edge (transform-origin) — never translate past it. */
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.scard.leaving {
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 240ms ease,
    transform 300ms ease;
}
.scard.open {
  width: var(--ov-open-w);
  border-radius: 16px;
}
.scard.working {
  width: var(--ov-work-w);
  border-radius: 18px;
}

/* Compact form: two fixed widths so the recording→working change is an animatable
   width transition (intrinsic max-content can't be transitioned, and every label
   is short enough to fit the resting pill, so content-sizing produced no visible
   grow). The resting pill hugs the waveform; the working pill is roomy enough to
   center the longest label — the .swork-label ellipsis is only a safety net past it.
   A notice hugs its title instead, so RecordingOverlay.tsx measures that width and
   sets it inline, which keeps it animatable. */
.scard.compact {
  animation: none;
  width: var(--ov-rest-w);
}
.scard.compact.cworking {
  width: var(--ov-work-w);
}

/* Notice: badge and title, in the pill and the Live panel. */
.scard.cnotice {
  cursor: pointer;
}
.scard.cnotice:not(.open) {
  border-radius: 24px;
}
.scard.level-error {
  --notice: var(--color-error);
}
.scard.level-warning {
  --notice: var(--color-warning);
}
.sbase.snotice {
  grid-template-columns: auto minmax(0, max-content);
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
}
.nglyph {
  display: block;
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--notice);
}
.nlabel {
  font-size: 12px;
  color: var(--color-text);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Measures the full title, since the visible one can be cut off. */
.nlabel.nprobe {
  position: absolute;
  visibility: hidden;
  overflow: visible;
}
.stext-cap .ndetail {
  display: block;
  color: var(--s-muted);
  font-style: normal;
  font-size: 13px;
  line-height: 1.4;
}

/* text region — auto-height open via grid-rows trick; region fades as a whole */
.stext {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 440ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 260ms ease;
}
.scard.open .stext {
  grid-template-rows: 1fr;
  opacity: 1;
}
.stext-clip {
  overflow: hidden;
  min-height: 0;
}
.stext-cap {
  /* Vertical counterpart of the .scard clamp: show fewer lines rather than clip.
     20px = cap padding (12) + card borders (2) + 6px slack for zoom rounding. */
  max-height: min(var(--ov-cap-max-h), calc(100vh - var(--ov-base-h) - 20px));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-top: 12px;
  padding-bottom: 0px;
  padding-left: 14px;
  padding-right: 14px;
  font-size: 15px;
  font-style: italic;
  line-height: 1.35;
  letter-spacing: -0.003em;
  color: var(--color-text);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}
/* Hide the scrollbar (WebKit/Chromium) — scroll-back is signalled by the fade. */
.stext-cap::-webkit-scrollbar {
  display: none;
}
.stext-cap p {
  /* Bottom-anchor the text when it's shorter than the viewport, avoiding the
     justify-content:flex-end overflow bug that makes the top unscrollable. */
  margin: auto 0 0;
}
.stext-cap .tentative {
  color: inherit;
}
.stext-cap .sloading {
  color: var(--s-muted);
}
.scaret {
  display: inline-block;
  width: 2px;
  height: 1.02em;
  translate: 0 3px;
  margin-left: 1px;
  background: var(--s-accent);
  border-radius: 2px;
  animation: scaret-blink 1.05s steps(1) infinite;
}
@keyframes scaret-blink {
  50% {
    opacity: 0;
  }
}

/* base row — dot (left) | waveform (center) | timer + cancel (right).
   Same structure for pill & panel; the dot stays anchored left in both. */
.sbase {
  height: var(--ov-base-h);
  flex: none; /* the control row never squashes; only the text region gives */
  padding: 0 10px;
  display: grid;
  /* Equal side columns (min 22px to hold the cancel button) keep the center item
     — waveform or label — centered whether the pill is at min width or content-
     sized. */
  grid-template-columns: minmax(22px, 1fr) auto minmax(22px, 1fr);
  align-items: center;
}
.sbase-l {
  display: flex;
  padding-left: 5px;
  align-items: center;
  justify-self: start;
}
.sbase-r {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}
.sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  box-sizing: border-box;
  transition:
    background-color 180ms ease,
    opacity 180ms ease;
}
.sdot.ready {
  background: var(--s-accent);
  opacity: 1;
  animation: sdot-pulse 1.9s infinite;
}
/* A quiet neutral dot while the host has not delivered its first sample yet. */
.sdot.arming {
  background: var(--s-muted);
  opacity: 0.45;
  animation: none;
}
@keyframes sdot-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--s-accent-soft);
  }
  70% {
    box-shadow: 0 0 0 7px transparent;
  }
}
.stimer {
  font-size: 12px;
  color: var(--s-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 240ms ease 80ms;
}
.scard.open .stimer {
  opacity: 1;
}

/* Waveform — reactive only after the first microphone callback. While arming,
   a muted travelling pulse acknowledges the shortcut without pretending that
   audio levels are already being received. */
.swave {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-right: 8px;
  height: 18px;
  flex: none;
}
.swave i {
  width: 4px;
  min-height: 3px;
  max-height: 18px;
  border-radius: 2px;
  background: var(--s-accent);
  transition:
    height 80ms linear,
    background-color 180ms ease,
    opacity 180ms ease;
}
.swave.arming i {
  height: 6px !important;
  background: var(--s-muted);
  opacity: 0.35;
  animation: swave-arming 900ms ease-in-out infinite;
}
.swave.arming i:nth-child(2),
.swave.arming i:nth-child(8) {
  animation-delay: 75ms;
}
.swave.arming i:nth-child(3),
.swave.arming i:nth-child(7) {
  animation-delay: 150ms;
}
.swave.arming i:nth-child(4),
.swave.arming i:nth-child(6) {
  animation-delay: 225ms;
}
.swave.arming i:nth-child(5) {
  animation-delay: 300ms;
}
@keyframes swave-arming {
  0%,
  100% {
    transform: scaleY(0.55);
    opacity: 0.25;
  }
  50% {
    transform: scaleY(1.5);
    opacity: 0.7;
  }
}
.sx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: none;
  padding: 0;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--s-muted);
  background: var(--s-hair);
  cursor: pointer;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 100ms ease;
}
.sx svg {
  width: 9px;
  height: 9px;
  display: block;
}
.sx:hover {
  background: var(--s-accent-soft);
  color: var(--color-text);
  transform: scale(1.05);
}
.sx:active {
  transform: scale(0.95);
}

/* working state (transcribing / polishing) — spinner + label */
.sspinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--s-hair);
  border-top-color: var(--s-accent);
  animation: sspin 0.7s linear infinite;
  flex: none;
}
@keyframes sspin {
  to {
    transform: rotate(1turn);
  }
}
.swork-label {
  font-size: 12px;
  color: var(--s-muted);
  white-space: nowrap;
  padding: 0 8px; /* breathing room from the spinner / cancel when content-sized */
  /* Safety net: ellipsize rather than clip if a label exceeds the max pill width. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}