fix(ui): unify colored-control text — white on all filled, both themes

The text color on filled colored controls was inconsistent: contained
primary resolved to white in both schemes, but error/success/warning/info
used a per-scheme contrastText (#fff light, #1a1a1a dark). So in DARK mode
a primary (red) button showed white text while an error (red) button —
e.g. every ConfirmDialog delete confirm, the contained "Smazat", and the
dashboard quick-action tiles — showed near-black text. "Black text on one
red button, white on another."

Unify on a single rule: every FILLED colored surface gets WHITE text/glyph
in BOTH themes. The palette .main stays bright in dark mode (it drives text,
outlined buttons and row tints), but a bright fill makes white illegible, so
filled surfaces drop to a darker fill in dark mode (new FILLED_DARK_BG, ≈ the
light-scheme shades; all ≥4.5:1 with white):
- theme MuiButton: contained error/success/warning/info -> white text +
  darker dark-mode fill (disabled state preserved).
- theme MuiChip: filled error/success/warning/info -> white label + darker
  dark-mode fill (covers StatusChip + status pills).
- StatCard icon badges: white glyph + darker dark-mode tile.

Plus two consistency cleanups:
- Detail-page "Smazat" unified to variant=outlined color=error (Offer +
  Invoice now match Order/Project/Warehouse; the contained->confirm pattern
  stays: subtle trigger, strong contained confirm dialog).
- "Zrušit filtry" reset buttons -> color=inherit (neutral), matching the
  rest of the secondary-button family (were default outlined-primary).

Neutral (color=inherit) text/outlined buttons were already correct (label =
ambient text color) and are untouched. tsc -b --noEmit, npm run build and
vitest 152/152 all clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-07 20:41:50 +02:00
parent c7f9d9aa36
commit ca092c6166
8 changed files with 133 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Card from "./Card";
import { FILLED_DARK_BG } from "../theme";
export type StatCardColor =
| "default"
@@ -31,16 +32,19 @@ export default function StatCard({
footer,
}: StatCardProps) {
// Solid tile + white glyph: high-contrast in both themes (the old light tint
// left the icon dark/low-visibility, esp. for the default variant).
// left the icon dark/low-visibility, esp. for the default variant). In dark
// mode the bright .main fill is darkened (same rule as filled buttons/chips)
// so the white glyph stays legible on success/warning/info/error tiles.
const iconBg = color === "default" ? "grey.600" : `${color}.main`;
const iconColor = "common.white";
const iconDarkBg = (FILLED_DARK_BG as Record<string, { bg: string }>)[color]
?.bg;
return (
<Card>
<Box sx={{ display: "flex", alignItems: "flex-start", gap: 1.5 }}>
{icon && (
<Box
sx={{
sx={(theme) => ({
display: "flex",
alignItems: "center",
justifyContent: "center",
@@ -48,9 +52,12 @@ export default function StatCard({
height: 40,
borderRadius: 2,
bgcolor: iconBg,
color: iconColor,
color: "common.white",
flexShrink: 0,
}}
...(iconDarkBg
? theme.applyStyles("dark", { backgroundColor: iconDarkBg })
: {}),
})}
>
{icon}
</Box>