Skip to content

Commit 430b332

Browse files
committed
Add base checkbox and rename Component Library -> Components inside Storybook
1 parent 56b2ee2 commit 430b332

File tree

10 files changed

+437
-33
lines changed

10 files changed

+437
-33
lines changed

libs/@hashintel/ds-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"motion": "12.23.24"
4343
},
4444
"devDependencies": {
45-
"@figma/code-connect": "1.3.6",
45+
"@figma/code-connect": "1.3.7",
4646
"@local/eslint": "0.0.0-private",
4747
"@local/tsconfig": "0.0.0-private",
4848
"@pandacss/dev": "1.4.3",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import figma from "@figma/code-connect";
2+
3+
import { Checkbox } from "./checkbox";
4+
5+
/**
6+
* -- This file was auto-generated by Code Connect --
7+
* `props` includes a mapping from your code props to Figma properties.
8+
* You should check this is correct, and update the `example` function
9+
* to return the code example you'd like to see in Figma
10+
*/
11+
12+
figma.connect(
13+
Checkbox,
14+
"https://www.figma.com/design/WmnosvOvi4Blw0HK0jh1mG/Design-System?node-id=384%3A25638",
15+
{
16+
props: {
17+
// These props were automatically mapped based on your linked code:
18+
checked: figma.enum("checked", {
19+
false: false,
20+
true: true,
21+
indeterminate: "indeterminate",
22+
}),
23+
disabled: figma.enum("_state", {
24+
disabled: true,
25+
}),
26+
label: figma.string("label"),
27+
// No matching props could be found for these Figma properties:
28+
// "showLabel": figma.boolean('_showLabel'),
29+
// "label": figma.string('label'),
30+
// "showIcon": figma.boolean('_showIcon'),
31+
// "icon": figma.instance('Icon')
32+
},
33+
example: (props) => (
34+
<Checkbox
35+
checked={props.checked}
36+
disabled={props.disabled}
37+
label={props.label}
38+
/>
39+
),
40+
},
41+
);
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import type { Meta, StoryObj } from "@storybook/react-vite";
2+
import { useState } from "react";
3+
4+
import { Checkbox, type CheckboxProps } from "./checkbox";
5+
6+
const meta: Meta<CheckboxProps> = {
7+
title: "Components/Checkbox",
8+
component: Checkbox,
9+
parameters: {
10+
layout: "centered",
11+
docs: {
12+
description: {
13+
component: `
14+
# Checkbox Component
15+
16+
A simple checkbox component built with @ark-ui/react and styled with PandaCSS.
17+
No refraction effects - just clean, accessible checkboxes.
18+
19+
## States
20+
21+
- **Unchecked**: Default empty state
22+
- **Checked**: Selected state with checkmark
23+
- **Indeterminate**: Partial selection state with minus icon
24+
- **Disabled**: Non-interactive state
25+
26+
## Interactions
27+
28+
- **Hover**: Slightly darker border and background
29+
- **Focus**: Blue outline ring
30+
- **Disabled**: Reduced opacity and muted colors
31+
`,
32+
},
33+
},
34+
},
35+
argTypes: {
36+
disabled: {
37+
control: "boolean",
38+
description: "Whether the checkbox is disabled",
39+
},
40+
label: {
41+
control: "text",
42+
description: "Label text for the checkbox",
43+
},
44+
},
45+
args: {
46+
disabled: false,
47+
label: "Label",
48+
},
49+
};
50+
51+
export default meta;
52+
53+
type Story = StoryObj<typeof meta>;
54+
55+
/**
56+
* Default checkbox in unchecked state
57+
*/
58+
export const Default: Story = {
59+
args: {
60+
checked: false,
61+
},
62+
};
63+
64+
/**
65+
* Checkbox in checked state
66+
*/
67+
export const Checked: Story = {
68+
args: {
69+
checked: true,
70+
},
71+
};
72+
73+
/**
74+
* Checkbox in indeterminate state (partial selection)
75+
*/
76+
export const Indeterminate: Story = {
77+
args: {
78+
checked: "indeterminate",
79+
},
80+
};
81+
82+
/**
83+
* Disabled checkbox states
84+
*/
85+
export const Disabled: Story = {
86+
render: () => (
87+
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
88+
<Checkbox label="Unchecked Disabled" disabled defaultChecked={false} />
89+
<Checkbox label="Checked Disabled" disabled defaultChecked />
90+
<Checkbox
91+
label="Indeterminate Disabled"
92+
disabled
93+
defaultChecked="indeterminate"
94+
/>
95+
</div>
96+
),
97+
};
98+
99+
/**
100+
* Interactive checkbox with controlled state
101+
*/
102+
export const Interactive: Story = {
103+
render: () => {
104+
const [checked, setChecked] = useState<boolean | "indeterminate">(false);
105+
106+
return (
107+
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
108+
<Checkbox
109+
label="Interactive Checkbox"
110+
checked={checked}
111+
onCheckedChange={setChecked}
112+
/>
113+
<div style={{ fontSize: "14px", color: "#666" }}>
114+
Current state:{" "}
115+
<strong>
116+
{checked === "indeterminate"
117+
? "Indeterminate"
118+
: checked
119+
? "Checked"
120+
: "Unchecked"}
121+
</strong>
122+
</div>
123+
<div style={{ display: "flex", gap: "8px" }}>
124+
<button
125+
type="button"
126+
onClick={() => setChecked(false)}
127+
style={{
128+
padding: "4px 12px",
129+
borderRadius: "4px",
130+
border: "1px solid #ccc",
131+
background: "white",
132+
cursor: "pointer",
133+
}}
134+
>
135+
Uncheck
136+
</button>
137+
<button
138+
type="button"
139+
onClick={() => setChecked(true)}
140+
style={{
141+
padding: "4px 12px",
142+
borderRadius: "4px",
143+
border: "1px solid #ccc",
144+
background: "white",
145+
cursor: "pointer",
146+
}}
147+
>
148+
Check
149+
</button>
150+
<button
151+
type="button"
152+
onClick={() => setChecked("indeterminate")}
153+
style={{
154+
padding: "4px 12px",
155+
borderRadius: "4px",
156+
border: "1px solid #ccc",
157+
background: "white",
158+
cursor: "pointer",
159+
}}
160+
>
161+
Set Indeterminate
162+
</button>
163+
</div>
164+
</div>
165+
);
166+
},
167+
};

0 commit comments

Comments
 (0)