Skip to content

Commit cf3ebb4

Browse files
authored
feat: Add disabled state support and Storybook stories for Button and ActionIcon components (#1647)
1 parent 1603602 commit cf3ebb4

4 files changed

Lines changed: 426 additions & 107 deletions

File tree

‎.changeset/strange-trees-march.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
feat: Add disabled state support and Storybook stories for Button and ActionIcon components
6+
7+
- Ensure all Button and ActionIcon variants use Mantine's default disabled styling for consistency
8+
- Add comprehensive Storybook stories including Playground, DisabledStates, and LoadingStates
9+
- Improve component documentation and testing capabilities

‎packages/app/src/stories/ActionIcon.stories.tsx‎

Lines changed: 208 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
11
import { ActionIcon, Group, Stack, Text } from '@mantine/core';
2-
import type { Meta } from '@storybook/nextjs';
2+
import type { Meta, StoryObj } from '@storybook/nextjs';
33
import {
44
IconCheck,
55
IconEdit,
6+
IconLoader2,
67
IconPlus,
78
IconSettings,
89
IconTrash,
910
IconX,
1011
} from '@tabler/icons-react';
1112

12-
const meta: Meta = {
13+
const meta: Meta<typeof ActionIcon> = {
1314
title: 'Components/ActionIcon',
1415
component: ActionIcon,
1516
parameters: {
1617
layout: 'centered',
1718
},
19+
argTypes: {
20+
variant: {
21+
control: 'select',
22+
options: ['primary', 'secondary', 'danger'],
23+
},
24+
size: {
25+
control: 'select',
26+
options: ['xs', 'sm', 'md', 'lg', 'xl'],
27+
},
28+
disabled: {
29+
control: 'boolean',
30+
},
31+
loading: {
32+
control: 'boolean',
33+
},
34+
},
1835
};
1936

2037
export default meta;
38+
type Story = StoryObj<typeof ActionIcon>;
39+
40+
// Interactive playground story
41+
export const Playground: Story = {
42+
args: {
43+
children: <IconSettings size={18} />,
44+
variant: 'primary',
45+
size: 'md',
46+
disabled: false,
47+
loading: false,
48+
},
49+
};
2150

2251
export const CustomVariants = () => (
2352
<Stack gap="xl">
@@ -102,6 +131,183 @@ export const Sizes = () => (
102131
</Stack>
103132
);
104133

134+
export const DisabledStates = () => (
135+
<Stack gap="xl">
136+
<Text size="lg" fw={700}>
137+
Disabled ActionIcon States
138+
</Text>
139+
<Text size="sm" c="dimmed">
140+
All ActionIcon variants should have a consistent disabled appearance with
141+
reduced opacity and a &quot;not-allowed&quot; cursor.
142+
</Text>
143+
144+
<div>
145+
<Text size="sm" fw={600} mb="xs">
146+
Primary - Normal vs Disabled
147+
</Text>
148+
<Group>
149+
<ActionIcon variant="primary" size="md">
150+
<IconCheck size={18} />
151+
</ActionIcon>
152+
<ActionIcon variant="primary" size="md" disabled>
153+
<IconCheck size={18} />
154+
</ActionIcon>
155+
<ActionIcon variant="primary" size="lg">
156+
<IconCheck size={20} />
157+
</ActionIcon>
158+
<ActionIcon variant="primary" size="lg" disabled>
159+
<IconCheck size={20} />
160+
</ActionIcon>
161+
</Group>
162+
</div>
163+
164+
<div>
165+
<Text size="sm" fw={600} mb="xs">
166+
Secondary - Normal vs Disabled
167+
</Text>
168+
<Group>
169+
<ActionIcon variant="secondary" size="md">
170+
<IconEdit size={18} />
171+
</ActionIcon>
172+
<ActionIcon variant="secondary" size="md" disabled>
173+
<IconEdit size={18} />
174+
</ActionIcon>
175+
<ActionIcon variant="secondary" size="lg">
176+
<IconEdit size={20} />
177+
</ActionIcon>
178+
<ActionIcon variant="secondary" size="lg" disabled>
179+
<IconEdit size={20} />
180+
</ActionIcon>
181+
</Group>
182+
</div>
183+
184+
<div>
185+
<Text size="sm" fw={600} mb="xs">
186+
Danger - Normal vs Disabled
187+
</Text>
188+
<Group>
189+
<ActionIcon variant="danger" size="md">
190+
<IconTrash size={18} />
191+
</ActionIcon>
192+
<ActionIcon variant="danger" size="md" disabled>
193+
<IconTrash size={18} />
194+
</ActionIcon>
195+
<ActionIcon variant="danger" size="lg">
196+
<IconTrash size={20} />
197+
</ActionIcon>
198+
<ActionIcon variant="danger" size="lg" disabled>
199+
<IconTrash size={20} />
200+
</ActionIcon>
201+
</Group>
202+
</div>
203+
204+
<div>
205+
<Text size="sm" fw={600} mb="xs">
206+
Subtle - Normal vs Disabled
207+
</Text>
208+
<Group>
209+
<ActionIcon variant="subtle" size="md">
210+
<IconSettings size={18} />
211+
</ActionIcon>
212+
<ActionIcon variant="subtle" size="md" disabled>
213+
<IconSettings size={18} />
214+
</ActionIcon>
215+
<ActionIcon variant="subtle" size="lg">
216+
<IconSettings size={20} />
217+
</ActionIcon>
218+
<ActionIcon variant="subtle" size="lg" disabled>
219+
<IconSettings size={20} />
220+
</ActionIcon>
221+
</Group>
222+
</div>
223+
224+
<div>
225+
<Text size="sm" fw={600} mb="xs">
226+
All Sizes - Disabled
227+
</Text>
228+
<Group align="center">
229+
<ActionIcon variant="primary" size="xs" disabled>
230+
<IconPlus size={14} />
231+
</ActionIcon>
232+
<ActionIcon variant="primary" size="sm" disabled>
233+
<IconPlus size={16} />
234+
</ActionIcon>
235+
<ActionIcon variant="primary" size="md" disabled>
236+
<IconPlus size={18} />
237+
</ActionIcon>
238+
<ActionIcon variant="primary" size="lg" disabled>
239+
<IconPlus size={20} />
240+
</ActionIcon>
241+
<ActionIcon variant="primary" size="xl" disabled>
242+
<IconPlus size={22} />
243+
</ActionIcon>
244+
</Group>
245+
</div>
246+
</Stack>
247+
);
248+
249+
export const LoadingStates = () => (
250+
<Stack gap="xl">
251+
<Text size="lg" fw={700}>
252+
Loading ActionIcon States
253+
</Text>
254+
<Text size="sm" c="dimmed">
255+
ActionIcons can show a loading spinner to indicate async operations.
256+
</Text>
257+
258+
<div>
259+
<Text size="sm" fw={600} mb="xs">
260+
Loading Variants
261+
</Text>
262+
<Group>
263+
<ActionIcon variant="primary" loading>
264+
<IconCheck size={18} />
265+
</ActionIcon>
266+
<ActionIcon variant="secondary" loading>
267+
<IconEdit size={18} />
268+
</ActionIcon>
269+
<ActionIcon variant="danger" loading>
270+
<IconTrash size={18} />
271+
</ActionIcon>
272+
<ActionIcon variant="subtle" loading>
273+
<IconSettings size={18} />
274+
</ActionIcon>
275+
</Group>
276+
</div>
277+
278+
<div>
279+
<Text size="sm" fw={600} mb="xs">
280+
Custom Loading Indicator
281+
</Text>
282+
<Group>
283+
<ActionIcon variant="primary" loading loaderProps={{ type: 'dots' }}>
284+
<IconCheck size={18} />
285+
</ActionIcon>
286+
<ActionIcon variant="primary">
287+
<IconLoader2 size={18} className="animate-spin" />
288+
</ActionIcon>
289+
</Group>
290+
</div>
291+
292+
<div>
293+
<Text size="sm" fw={600} mb="xs">
294+
Loading with Different Sizes
295+
</Text>
296+
<Group align="center">
297+
<ActionIcon variant="primary" size="sm" loading>
298+
<IconCheck size={16} />
299+
</ActionIcon>
300+
<ActionIcon variant="primary" size="md" loading>
301+
<IconCheck size={18} />
302+
</ActionIcon>
303+
<ActionIcon variant="primary" size="lg" loading>
304+
<IconCheck size={20} />
305+
</ActionIcon>
306+
</Group>
307+
</div>
308+
</Stack>
309+
);
310+
105311
export const CommonUseCases = () => (
106312
<Stack gap="md">
107313
<Text size="sm" fw={600}>

0 commit comments

Comments
 (0)