mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-20 20:34:19 +00:00
Replace left-border colored stripes with severity dots across all pages (AuditPage, AuditRulesPage, InstallForm, GitSyncPage, SkillsPage) and components (Card accent variant, ConfirmDialog, Select). Card accent now uses a thicker border instead of a left stripe. Fix Cmd+S modifier HUD staying visible by resetting state immediately after shortcut fires and adding a 2-second auto-dismiss safety timer. Additional refinements: extract Checkbox/Select/Spinner/Tooltip into standalone components, update Button link variant to pencil colors, replace SkillsPage FilterChips with SegmentedControl connected, and update style guide to mark left-border stripes as an anti-pattern.
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { useId } from 'react';
|
|
import { Check, Minus } from 'lucide-react';
|
|
import { radius } from '../design';
|
|
|
|
interface CheckboxProps {
|
|
label: string;
|
|
checked: boolean;
|
|
onChange: (checked: boolean) => void;
|
|
className?: string;
|
|
indeterminate?: boolean;
|
|
disabled?: boolean;
|
|
size?: 'sm' | 'md';
|
|
}
|
|
|
|
const sizeMap = {
|
|
sm: { box: 'w-4 h-4', icon: 12, text: 'text-sm' },
|
|
md: { box: 'w-5 h-5', icon: 14, text: 'text-base' },
|
|
};
|
|
|
|
export function Checkbox({
|
|
label,
|
|
checked,
|
|
onChange,
|
|
className = '',
|
|
indeterminate = false,
|
|
disabled = false,
|
|
size = 'md',
|
|
}: CheckboxProps) {
|
|
const id = useId();
|
|
const s = sizeMap[size];
|
|
|
|
return (
|
|
<label
|
|
htmlFor={id}
|
|
className={`
|
|
inline-flex items-center gap-2 select-none
|
|
${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}
|
|
${className}
|
|
`}
|
|
>
|
|
<input
|
|
id={id}
|
|
type="checkbox"
|
|
checked={checked}
|
|
onChange={(e) => !disabled && onChange(e.target.checked)}
|
|
disabled={disabled}
|
|
className="sr-only"
|
|
/>
|
|
<span
|
|
className={`
|
|
${s.box} flex items-center justify-center border transition-all duration-150
|
|
${disabled ? '' : 'active:scale-95'}
|
|
focus-visible:ring-2 focus-visible:ring-blue/30 focus-visible:ring-offset-1
|
|
${
|
|
checked || indeterminate
|
|
? 'bg-blue border-blue'
|
|
: 'bg-surface border-muted-dark hover:border-pencil-light'
|
|
}
|
|
`}
|
|
style={{ borderRadius: radius.sm }}
|
|
>
|
|
{indeterminate ? (
|
|
<Minus size={s.icon} strokeWidth={3} className="text-white" />
|
|
) : checked ? (
|
|
<Check size={s.icon} strokeWidth={3} className="text-white" />
|
|
) : null}
|
|
</span>
|
|
<span className={`${s.text} text-pencil`}>{label}</span>
|
|
</label>
|
|
);
|
|
}
|