Closes the migrate-button-input-mobilenav-to-glass-primitive convoy (seeded by PR #127). All 3 residual handrolled var(--glass-surface-*) inline-style usages migrated to either purpose-built utility classes or the <GlassSurface> primitive. CI allowlist reduced from 6 entries to 3 (chrome only). Architect decisions (D1-D3, ratified): D1 — Button.secondary → new .btn-glass-secondary utility class. NOT <GlassSurface>: the primitive sets `background` inline via composedStyle, which CSS :hover rules can't override without !important. The new class composes the same high-tint gradient-border that .glass-panel-strong uses, plus a pure-CSS :hover swap (high → mid fill on the padding-box layer). Identical visual contract; the hover behavior is now driven by CSS, not Tailwind's `hover:bg-[var(...)]` arbitrary class. D2 — Input → new .glass-input utility class. NOT <GlassSurface as="input"> and NOT <GlassSurface as="div"> wrap. Reason: <GlassSurface>'s gradient-border trick requires `border: 1px solid transparent` to expose the border-box layers, which conflicts with <Input>'s conditional error-state `1px solid #dc2626` red border. The new class adopts only the tint + blur layer; the visible 1px border + focus ring stay in JSX (class-controlled, not inline). Same visual contract as before for both normal AND error states. D3 — MobileNavigation → <GlassSurface as="div" tint="mid" blur="mid" rim="subtle" elevation="flat" cornerLights="chrome">. NOT .page-header-glass (the seed's first recommendation): .page-header-glass uses var(--glass-surface-high) (wrong tint — MobileNav uses mid) and sets a bottom-border separator (wrong for a fixed-bottom-nav where the bottom edge is the viewport edge). <GlassSurface> is the better fit AND brings the chrome-tier corner-light bleed that the parent convoy is unifying across all chrome surfaces. Implementation choice — single PR (not 3 parallel briefs): The seed recommended 3 small parallel-safe briefs (one per file). D1 and D2 both need styles/globals.css to gain new utility classes, so those 2 changes can't run truly in parallel without merge conflicts. Single PR is faster, simpler to review end-to-end, and the natural shape for a 2-3 hour convoy with tightly-coupled artifacts. Files changed (4): styles/globals.css (+50 / -1): - Adds .btn-glass-secondary (with :hover variant) — D1. - Adds .glass-input — D2. - Both classes documented inline with architect-decision references. components/ui/Button.js (+2 / -10): - Replaces inline variantStyle + Tailwind hover arbitrary class for `variant === 'secondary'` with `variantClass = 'btn-glass-secondary font-medium'`. variantStyle now `{}`. - Other variants (primary, danger, ghost) UNCHANGED. components/ui/Input.js (+1 / -7): - Adds `glass-input` to the className list. - Removes inline `background` + `backdropFilter` + `WebkitBackdropFilter` from the input's style block. - Conditional `border: inputBorder` stays in JSX (error swap). - All other props/behavior preserved. components/MobileNavigation.js (+11 / -8): - Adds `import { GlassSurface } from './ui'`. - Replaces the inline-styled backdrop <div> with <GlassSurface as="div" ...>. Same className ("absolute inset-0"), same visible behavior, plus the chrome-tier corner-light bleed. - Comment block updated to reference the convoy + decision. .github/workflows/ci.yml (+8 / -22): - forbidden-patterns Check 7/7 GLASS_ALLOWLIST reduced from 6 entries to 3 (chrome only). The TODO comments referencing this convoy are deleted (work is done). .convoys/migrate-button-input-mobilenav-to-glass-primitive.md (+74 / -3): - status: queued → closed, closed: 2026-06-05, prs: [131]. - Architect ratifications D1-D3 written into front-matter docs. - Closeout checklist with all acceptance criteria checked. - Note that parent convoy unify-glass-panel-surfaces is now fully closed — no residual handrolled glass-surface usage outside the 3 chrome blocks. Verification: - POSITIVE TEST: post-migration grep with the reduced 3-entry allowlist returns 0 violations. ✅ - grep on raw files: only Layout.js + TopSearchBar.js still match the literal regex (GlassSurface.js uses template literal which doesn't match — intentional, allowlist is forward-compat). - YAML parses (python3 yaml.safe_load). - npm run lint passes (1 pre-existing unrelated warning). - npm run test:run: 118/118 tests pass. Visual diff to be verified by reviewer in light + dark mode for: - <Button variant="secondary"> default + hover state. - <Input> default + error state. - Mobile bottom-nav backdrop. Co-authored-by: Cursor <cursoragent@cursor.com>
98 lines
2.7 KiB
JavaScript
98 lines
2.7 KiB
JavaScript
import { forwardRef } from 'react';
|
|
|
|
const SIZE_CLASSES = {
|
|
sm: 'px-3 py-1.5 text-sm rounded-lg',
|
|
md: 'px-4 py-2 text-base rounded-xl',
|
|
lg: 'px-5 py-3 text-base rounded-xl',
|
|
};
|
|
|
|
const Button = forwardRef(function Button(
|
|
{
|
|
variant = 'primary',
|
|
size = 'md',
|
|
type = 'button',
|
|
loading = false,
|
|
leadingIcon,
|
|
trailingIcon,
|
|
disabled,
|
|
className = '',
|
|
style,
|
|
children,
|
|
...rest
|
|
},
|
|
ref
|
|
) {
|
|
const isDisabled = disabled || loading;
|
|
const sizeCls = SIZE_CLASSES[size] ?? SIZE_CLASSES.md;
|
|
|
|
let variantStyle = {};
|
|
let variantClass = '';
|
|
|
|
if (variant === 'primary') {
|
|
variantStyle = {
|
|
background:
|
|
'linear-gradient(135deg, var(--accent-ember) 0%, var(--accent-flame) 100%)',
|
|
color: '#ffffff',
|
|
boxShadow: 'var(--rim-light-inner), var(--ember-rim-pronounced)',
|
|
};
|
|
variantClass = 'font-medium transition-transform duration-200 hover:scale-[1.02] active:scale-[0.98]';
|
|
} else if (variant === 'secondary') {
|
|
variantStyle = {};
|
|
variantClass = 'btn-glass-secondary font-medium';
|
|
} else if (variant === 'danger') {
|
|
variantStyle = {
|
|
backgroundColor: '#dc2626',
|
|
color: '#ffffff',
|
|
boxShadow: 'var(--rim-light-inner)',
|
|
};
|
|
variantClass = 'font-medium transition-all duration-200 hover:bg-[#b91c1c]';
|
|
} else if (variant === 'ghost') {
|
|
variantStyle = {
|
|
background: 'transparent',
|
|
color: 'var(--text-primary)',
|
|
};
|
|
variantClass = 'font-medium transition-colors duration-200 hover:bg-[rgba(var(--ember-rim-color),0.08)]';
|
|
}
|
|
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
type={type}
|
|
disabled={isDisabled}
|
|
aria-busy={loading || undefined}
|
|
className={[
|
|
'relative inline-flex items-center justify-center gap-2 select-none',
|
|
sizeCls,
|
|
variantClass,
|
|
isDisabled ? 'opacity-50 cursor-not-allowed pointer-events-none' : '',
|
|
'focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
className,
|
|
]
|
|
.filter(Boolean)
|
|
.join(' ')}
|
|
style={{
|
|
...variantStyle,
|
|
'--tw-ring-color': 'var(--accent-ember)',
|
|
'--tw-ring-offset-color': 'transparent',
|
|
...style,
|
|
}}
|
|
{...rest}
|
|
>
|
|
{loading && (
|
|
<span
|
|
aria-hidden="true"
|
|
className="inline-block h-4 w-4 animate-spin rounded-full border-2 border-current border-r-transparent"
|
|
/>
|
|
)}
|
|
{!loading && leadingIcon && (
|
|
<span aria-hidden="true" className="inline-flex">{leadingIcon}</span>
|
|
)}
|
|
<span>{children}</span>
|
|
{!loading && trailingIcon && (
|
|
<span aria-hidden="true" className="inline-flex">{trailingIcon}</span>
|
|
)}
|
|
</button>
|
|
);
|
|
});
|
|
|
|
export default Button;
|