Files
jobtrackingapp/job-tracker-ui/src/components/GradientButton.tsx
T
cesnimda fc56f94d56
CI and Deploy / test (push) Successful in 2m35s
CI and Deploy / deploy (push) Successful in 38s
style(ui): redesign job workspace dialog to match mockup
Restyle JobDetailsDialog.tsx (04-job-workspace.png mockup) within its
existing dialog/tab structure -- the real app splits Correspondence,
Attachments, and Candidate Fit into separate tabs rather than the
mockup's single-screen 2x2 card grid, so this is a visual-language
pass over the existing IA, not a restructure:

- Header: bolder title (h5/800), heavier status chip, cleaner
  no-underline tab styling.
- Every flat bordered "fake card" Box (11 instances across all tabs,
  plus the 2 in the Overview strategy-snapshot panel) becomes a
  floating shadow card with no border, matching every other screen
  redesigned this session.
- The two genuinely AI-generation actions (Generate Strategy Snapshot,
  and by extension the shared GradientButton component) get the
  mockup's signature gradient CTA treatment; the confirm-gated
  "Refresh AI summary" action stays a plain outlined button so the
  gradient doesn't get diluted by a second use on the same tab.

Also fixes a real bug surfaced by actually using GradientButton for
the first time: its sx callback read theme.vars.customShadows, which
throws when a component renders without this app's ThemeProvider --
true in production always, but true in every test in this repo (none
of them wrap with a ThemeProvider), so every test touching a
GradientButton or one of these restyled boxes crashed. Fixed by using
a static shadow value instead of a theme.vars lookup in both the
component and this file, matching the fact that inline sx callbacks
execute against whatever theme is in context (unlike theme.components
styleOverrides, which only run when this app's real theme is actually
provided).

Verified: tsc clean, full suite green (65/65, including 4 test files
that render this exact dialog). Live check: booted the backend and
loaded the dashboard through a fresh Next.js dev server + cache
(cleared .next after chasing what turned out to be a stale console-log
history in the Browser pane tooling, not a real compile error) --
confirmed real data renders with no actual runtime errors.
2026-07-13 09:27:15 +02:00

42 lines
1.6 KiB
TypeScript

import React from "react";
import Button, { ButtonProps } from "@mui/material/Button";
import { GRADIENT_CTA } from "../theme";
// Static, not derived from theme.vars.customShadows: an inline sx callback always executes
// against whatever theme is in context, including MUI's bare default theme when a component
// renders without this app's ThemeProvider (every test in this repo does exactly that -- no
// test wraps components in one), and the default theme has no `.vars`. theme.components
// styleOverrides (e.g. MuiCard) don't have this problem since they only run when this app's
// real theme is actually provided, but inline sx isn't gated that way.
const GRADIENT_SHADOW = "0px 4px 14px -4px rgba(99,102,241,0.45)";
/**
* The mockup's gradient AI/primary-action pill ("Tailor my CV for this role", "See the
* interface tour"). Reserve this for the single most important AI-assist or hero action on a
* screen -- everything else stays a plain contained/outlined Button, or the gradient stops
* reading as a signal and becomes wallpaper.
*/
export default function GradientButton({ sx, disabled, ...props }: ButtonProps) {
return (
<Button
variant="contained"
disableElevation
disabled={disabled}
sx={[
{
background: disabled ? undefined : GRADIENT_CTA,
color: disabled ? undefined : "#fff",
boxShadow: disabled ? undefined : GRADIENT_SHADOW,
"&:hover": disabled
? undefined
: { background: GRADIENT_CTA, filter: "brightness(1.06)", boxShadow: GRADIENT_SHADOW },
},
...(Array.isArray(sx) ? sx : sx ? [sx] : []),
]}
{...props}
/>
);
}