File tree Expand file tree Collapse file tree 1 file changed +22
-15
lines changed
apps/class-solid/src/components/plots Expand file tree Collapse file tree 1 file changed +22
-15
lines changed Original file line number Diff line number Diff line change 11import { For } from "solid-js" ;
2- import { cn } from "~/lib/utils" ;
3- import { Checkbox } from "../ui/checkbox" ;
2+ import { createUniqueId } from "solid-js" ;
43import type { ChartData } from "./ChartContainer" ;
54import { useChartContext } from "./ChartContainer" ;
65
@@ -15,21 +14,29 @@ export function Legend<T>(props: LegendProps<T>) {
1514
1615 return (
1716 < div
18- class = { cn (
19- "flex flex-wrap justify-end text-sm tracking-tight" ,
20- `w-[${ chart . width } px]` ,
21- ) }
17+ class = { "flex flex-wrap justify-end gap-2 text-sm tracking-tight" }
18+ style = { `max-width: ${ chart . width } px;` }
2219 >
2320 < For each = { props . entries ( ) } >
24- { ( d ) => (
25- < div class = " flex gap-1" >
26- < Checkbox
27- checked = { props . toggles [ d . label ] }
28- onChange = { ( v ) => props . onChange ( d . label , v ) }
29- />
30- < p style = { `color: ${ d . color } ` } > { d . label } </ p >
31- </ div >
32- ) }
21+ { ( d ) => {
22+ const id = createUniqueId ( ) ;
23+ return (
24+ < div
25+ class = "flex items-center gap-1"
26+ style = { `color: ${ d . color } ; accent-color: ${ d . color } ` }
27+ >
28+ < input
29+ type = "checkbox"
30+ checked = { props . toggles [ d . label ] }
31+ onChange = { ( v ) =>
32+ props . onChange ( d . label , v . currentTarget . checked )
33+ }
34+ id = { id }
35+ />
36+ < label for = { id } > { d . label } </ label >
37+ </ div >
38+ ) ;
39+ } }
3340 </ For >
3441 </ div >
3542 ) ;
You can’t perform that action at this time.
0 commit comments