Files
stemengine_old/StemEngine UI Fix.md
T
translator eae0787725 fix: dark mode for form controls, lyric preview buttons, sidebar toggle
- theme-overrides.css: add !important to form control dark mode rules
  (background/color/border-color) — MetroUI's un-layered select rule
  was winning the cascade regardless of inline styles; color-scheme: dark
  forces OS-native chrome (dropdown arrow) to dark theme

- ProjectDetail.tsx: add fieldStyle const with CSS vars for all
  select/input/textarea elements; fix standalone inline-style selects
  and container divs (log body, ABC header, Sheet/Text toggles)

- Separator.tsx: update ctrl style to use var(--background/foreground)
  and colorScheme: inherit

- LyricsLivePreview.tsx: replace dark:bg-gray-800 / dark:text-gray-400
  Tailwind dark-mode classes with inline CSS var styles on tab bar
  container and all tab/icon buttons; add lp-btn hover rule

- Sidebar.tsx: fix toggle button clipped by aside overflow:hidden —
  change aside to overflow:visible, wrap collapsed strip in own
  overflow:hidden div

- ThemeContext.tsx: set root.style.colorScheme = r for OS chrome theming

- index.html: add <meta name="color-scheme" content="light dark">

- index.css: Phase 7 — replace @layer base + @apply and @layer utilities
  + theme() with plain CSS (height: 100%, rem values for sidebar widths)
2026-03-12 09:18:53 +09:00

11 KiB
Raw Blame History

StemEngine UI Fix Plan

Created: 2026-03-11

This document tracks remaining MetroUI optimisations plus the two active regressions (dark mode, mobile Settings layout). It is intentionally scoped — Separator.tsx, KaraokeEditor.tsx, LyricsLivePreview.tsx, and DynamicMixPlayer.tsx are NOT in scope here; they are still Tailwind-based by design and will be handled in a future plan.


Context: what was already fixed this session

Issue Fix
Sidebar backdrop blocking desktop clicks Restored className="sm:hidden" on backdrop div
Dark mode CSS vars not switching ThemeContext.apply() now calls root.style.setProperty() for all custom vars
VRAM tier card text overflow Button: width:100%, minWidth:0, overflow:hidden; span: overflowWrap:break-word

Active bugs still to fix

1 — Settings dark mode: MaintenanceCard icon props (iconBg / iconColor)

File: frontend/src/pages/Settings.tsx

Problem: MaintenanceCard accepts iconBg and iconColor props and the call-sites pass Tailwind strings ("bg-blue-100 dark:bg-blue-900/30" / "text-blue-600 dark:text-blue-400"). The component itself ignores those props (body is all inline-style), so the icon wrapper has no background in light mode and no tint in dark mode.

Lines: 1441–1509 (five <MaintenanceCard> call-sites), plus the MaintenanceCard definition above that shows the unused iconBg/iconColor parameters.

Fix plan:

  1. Remove iconBg and iconColor from MaintenanceCard's props interface and signature.
  2. Replace them with a single accent prop ('blue' | 'purple' | 'amber' | 'cyan' | 'green').
  3. Inside the component's icon wrapper <div>, derive background from accent using a map of MetroUI / plain CSS colour tokens (no Tailwind):
const ACCENT_CSS: Record<string, { bg: string; color: string }> = {
  blue:   { bg: 'rgba(14, 165, 233, 0.12)',  color: '#0ea5e9' },
  purple: { bg: 'rgba(168, 85, 247, 0.12)',  color: '#a855f7' },
  amber:  { bg: 'rgba(245, 158, 11, 0.12)',  color: '#f59e0b' },
  cyan:   { bg: 'rgba(6, 182, 212, 0.12)',   color: '#06b6d4' },
  green:  { bg: 'rgba(16, 185, 129, 0.12)',  color: '#10b981' },
}

// icon wrapper:
<div style={{
  width: 36, height: 36, borderRadius: 8, flexShrink: 0,
  display: 'flex', alignItems: 'center', justifyContent: 'center',
  background: ACCENT_CSS[accent].bg,
  color: ACCENT_CSS[accent].color,
}}>
  <Icon style={{ width: 18, height: 18 }} />
</div>
  1. Update the five call-sites to pass accent="blue" / "purple" / "amber" / "cyan" / "green".

These RGBA tints are theme-neutral (same opacity on dark or light backgrounds) so no dark-mode conditional is needed.


2 — Settings mobile: vertical nav breaks at narrow widths

File: frontend/src/pages/Settings.tsx, main Settings export (≈ lines 1955–2015)

Problem: The layout is display: flex, gap: 24 with a fixed-width 176px nav column and flex: 1 content. On mobile (< 640 px) the nav column eats one-third of the screen, labels wrap, and the content panel is too narrow to be usable.

Fix plan: Make the layout responsive without Tailwind by checking window.innerWidth at mount time and updating on resize.

// Add near the top of the Settings component:
const [isMobile, setIsMobile] = React.useState(() => window.innerWidth < 640)
React.useEffect(() => {
  const handler = () => setIsMobile(window.innerWidth < 640)
  window.addEventListener('resize', handler)
  return () => window.removeEventListener('resize', handler)
}, [])

Then split the JSX into two layouts:

Mobile layout — horizontal scrolling tab strip above the content panel:

// Outer wrapper: flex-col
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>

  {/* Horizontal scrollable nav strip */}
  <div style={{
    display: 'flex', overflowX: 'auto', gap: 2, padding: '4px 0 8px',
    borderBottom: '1px solid var(--border-color)',
    scrollbarWidth: 'none',   // hide scrollbar on Firefox
    // WebkitOverflowScrolling: 'touch',
  }}>
    {TABS.map(({ id, label, Icon: TabIcon }) => {
      const isActive = activeTab === id
      return (
        <button key={id} onClick={() => setActiveTab(id)} style={{
          display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 3,
          padding: '6px 12px', borderRadius: 8, flexShrink: 0, border: 'none',
          background: isActive ? 'rgba(var(--brand-500, 59 130 246), 0.1)' : 'transparent',
          color: isActive ? 'rgb(var(--brand-500, 59 130 246))' : 'inherit',
          cursor: 'pointer', fontSize: 11, fontWeight: isActive ? 600 : 400,
        }}>
          <TabIcon style={{ width: 16, height: 16 }} />
          {label}
        </button>
      )
    })}
  </div>

  {/* Content panel: no border/rounded on mobile to use full width */}
  <div style={{ padding: '16px 0' }}>
    {/* active component */}
  </div>
</div>

Desktop layout — the existing two-column flex (unchanged).

The TABS array should be defined once above the return, replacing the two places where the nav items are currently rendered inline.


3 — index.css: replace @apply dark:* with plain CSS

File: frontend/src/index.css

Problem: Scrollbar styles and range input styles use @apply dark:bg-* which requires Tailwind dark-mode processing. As we remove Tailwind these will break. Also, appearance: none on range inputs conflicts with accent-color inline styles set in components (accentColor is ignored when appearance is none).

Fix plan: Replace the relevant blocks with plain CSS that reads from our custom properties defined by ThemeContext:

/* Remove these @apply blocks and replace with: */

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--border-color) 80%, black);
}

/* Range inputs: keep appearance-none (so we control the thumb), but
   also set a height so the track is visible. */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  background: var(--border-color);
  height: 6px;
  border-radius: 9999px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgb(var(--brand-500, 59 130 246));
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgb(var(--brand-500, 59 130 246));
  cursor: pointer;
  border: none;
}

Note: With appearance: none active on all range inputs, any accentColor set via inline style has no effect. Either keep appearance: none (use the CSS thumb styling above) or remove appearance: none (use accentColor inline). Do not use both. The plan is to keep appearance: none with the explicit thumb CSS since it gives better cross-browser control and doesn't require per-element inline styles.

Remove the accentColor property from any inline styles in GlobalAudioBar.tsx and DynamicMixPlayer.tsx if it was added there.


4 — GlobalAudioBar: dark mode background

File: frontend/src/components/GlobalAudioBar.tsx

Problem: The bar uses backdropFilter: blur(8px) but the background colour is unset (transparent or inherited). In dark mode the blur has nothing to tint, so the bar reads light text on a potentially light-coloured backdrop.

Fix plan: Add a semi-transparent --body-background background that reads from our ThemeContext vars:

// outer fixed div — change background property:
background: 'color-mix(in srgb, var(--body-background) 85%, transparent)',
// or a safe fallback:
background: 'rgba(var(--body-background-raw, 255 255 255), 0.85)',

Alternatively — the simplest approach without new CSS vars:

background: 'var(--body-background)',
opacity: undefined,  // remove any opacity
// add a top border instead of backdrop blur for a cleaner look:
borderTop: '1px solid var(--border-color)',
backdropFilter: 'blur(8px)',

Also add --body-background with a small alpha (e.g. rgba(15,23,42,0.92) in dark, rgba(255,255,255,0.92) in light) to ThemeContext so backdrop-filter can work as a frosted-glass effect rather than a full opaque bar.


Future phases (out of scope for this plan)

Phase Scope Key files
Phase 7 Sidebar.tsx full MetroUI migration Sidebar.tsx — already uses only MetroUI button cycle flat / sidebar-open / sidebar-closed; internal layout cards/badges still need inline-style conversion
Phase 8 Separator.tsx Heavy Tailwind; job submission form, file upload, model select
Phase 9 KaraokeEditor + LyricsLivePreview Hardcoded hex colour palette; canvas-based editor has special requirements
Phase 10 DynamicMixPlayer Range inputs, stem volume sliders, waveform vis
Phase 11 Remove Tailwind entirely Delete tailwind.config.js, postcss.config.js, remove devDep; replace remaining @tailwind directives and @apply in index.css

CSS variable reference (ThemeContext)

All vars are set on document.documentElement by ThemeContext.apply():

Variable Light Dark
--body-background #ffffff #0f172a
--background #f8fafc #1e293b
--border-color #e2e8f0 #334155
--sidebar-background #f1f5f9 #0f172a
--color-green #22c55e #22c55e
--color-red #ef4444 #ef4444
--color-amber #f59e0b #f59e0b
--color-blue #0ea5e9 #0ea5e9
--color-violet #8b5cf6 #8b5cf6
--color-teal #14b8a6 #14b8a6
--brand-500 (raw) 59 130 246 (unchanged, set in index.css)

Usage pattern in inline styles:

// Solid brand colour:
rgb(var(--brand-500, 59 130 246))

// Brand with opacity:
rgba(var(--brand-500, 59 130 246), 0.12)

// Semantic colours:
var(--color-green)
var(--border-color)
var(--body-background)

Shared style constants already in Settings.tsx

const sHdr: CSSProperties = {
  display: 'flex', alignItems: 'center', gap: 12,
  paddingBottom: 16, borderBottom: '1px solid var(--border-color)',
}
const sFieldLabel: CSSProperties = {
  display: 'block', fontSize: 13, fontWeight: 500, marginBottom: 6,
}
const sCtrl: CSSProperties = {
  width: '100%', padding: '7px 10px', fontSize: 13, borderRadius: 6,
  border: '1px solid var(--border-color)',
  background: 'var(--body-background)', color: 'inherit',
  boxSizing: 'border-box',
}
const sCard: CSSProperties = {
  border: '1px solid var(--border-color)',
  borderRadius: 10, padding: 16, background: 'var(--background)',
}

These should be reused everywhere in Settings.tsx rather than duplicated.


Implementation order

  1. Fix #1 — MaintenanceCard accent props (small, safe, no layout change)
  2. Fix #3 — index.css range + scrollbar CSS (no JSX change, fixes slider rendering)
  3. Fix #4 — GlobalAudioBar dark background (2-line change in one file)
  4. Fix #2 — Settings mobile nav (larger change; test on narrow viewport first)