mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
feat(coach): swap the sources-rail toggle to a shadcn Checkbox
Replace the raw <input type="checkbox"> in the sources rail with a shadcn-style <Checkbox> backed by radix-ui. The new primitive ships a real focus ring, a Space-toggles keyboard contract, and a touch- friendly hit target so the rail behaves correctly on the right-edge side-tray surface mobile users open via the chevron button.
This commit is contained in:
1 parent
2fb964ef9d
commit
40916d3127
2 files changed
+58
-9
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
Smile,
|
||||
} from "lucide-react";
|
||||
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
@@ -234,20 +235,21 @@ export function SourcesRail({
|
||||
!checked && "opacity-60",
|
||||
)}
|
||||
>
|
||||
<input
|
||||
{/* v1.4.27 R3d MB4 / CF-40 — swap the raw HTML checkbox
|
||||
for the shadcn `<Checkbox>` primitive so the rail
|
||||
ships a real focus ring, a proper keyboard contract
|
||||
(Space toggles, Tab moves), and a touch-friendly
|
||||
hit target on the side-tray surface. The wrapping
|
||||
`<label htmlFor={checkboxId}>` below still acts as
|
||||
the row-wide tap target on mobile. */}
|
||||
<Checkbox
|
||||
id={checkboxId}
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
disabled={!interactive}
|
||||
onChange={() => toggleSource(row.key)}
|
||||
onCheckedChange={() => toggleSource(row.key)}
|
||||
data-slot="coach-sources-checkbox"
|
||||
aria-label={t(row.metricKey)}
|
||||
className={cn(
|
||||
"border-border/70 text-dracula-purple",
|
||||
"size-4 shrink-0 cursor-pointer rounded",
|
||||
"focus-visible:ring-ring/50 focus-visible:ring-2",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
)}
|
||||
className="cursor-pointer"
|
||||
/>
|
||||
<row.Icon
|
||||
className={cn("size-3.5", row.accentClass)}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
||||
import { Check } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
* v1.4.27 R3d MB4 / CF-40 — shadcn-style `<Checkbox>` primitive backed
|
||||
* by `radix-ui`'s `Checkbox` namespace. Brought in so the Coach
|
||||
* sources-rail can drop its raw `<input type="checkbox">` for a
|
||||
* keyboard + touch accessible control that ships proper focus rings
|
||||
* and a 44 px hit target on mobile.
|
||||
*
|
||||
* Mirrors the v1.4.27 shadcn `<Checkbox>` recipe: a Root that draws
|
||||
* the border + checked-state background, an Indicator slot that
|
||||
* shows the lucide `<Check>` when the box is checked.
|
||||
*/
|
||||
function Checkbox({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
||||
return (
|
||||
<CheckboxPrimitive.Root
|
||||
data-slot="checkbox"
|
||||
className={cn(
|
||||
"peer border-border/70 size-4 shrink-0 rounded border",
|
||||
"data-[state=checked]:bg-dracula-purple data-[state=checked]:border-dracula-purple data-[state=checked]:text-background",
|
||||
"focus-visible:ring-ring/50 focus-visible:ring-2 focus-visible:outline-none",
|
||||
"disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"transition-colors",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator
|
||||
data-slot="checkbox-indicator"
|
||||
className="flex items-center justify-center text-current"
|
||||
>
|
||||
<Check className="size-3" aria-hidden="true" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
);
|
||||
}
|
||||
|
||||
export { Checkbox };
|
||||
Reference in new issue
Block a user