Skip to content

Commit

Permalink
Grafana UI: Checkbox.story.tsx - Replace VerticalGroupwith Stack (
Browse files Browse the repository at this point in the history
  • Loading branch information
eledobleefe committed Apr 18, 2024
1 parent 0d11f9b commit e65669b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-ui/src/components/Forms/Checkbox.story.tsx:5381": [
[0, 0, 0, "\'VerticalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
"packages/grafana-ui/src/components/Forms/FieldArray.story.tsx:5381": [
[0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
],
Expand Down
24 changes: 9 additions & 15 deletions packages/grafana-ui/src/components/Forms/Checkbox.story.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meta, StoryFn } from '@storybook/react';
import React, { useState, useCallback } from 'react';

import { VerticalGroup } from '../Layout/Layout';
import { Stack } from '../Layout/Stack/Stack';

import { Checkbox } from './Checkbox';
import mdx from './Checkbox.mdx';
Expand All @@ -26,11 +26,7 @@ export const Basic: StoryFn<typeof Checkbox> = (args) => {
(e: React.FormEvent<HTMLInputElement>) => setChecked(e.currentTarget.checked),
[setChecked]
);
return (
<div>
<Checkbox value={checked} onChange={onChange} {...args} />
</div>
);
return <Checkbox value={checked} onChange={onChange} {...args} />;
};

Basic.args = {
Expand All @@ -44,7 +40,7 @@ Basic.args = {
export const StackedList = () => {
return (
<div>
<VerticalGroup>
<Stack direction="column" alignItems="flex-start">
<Checkbox
defaultChecked={true}
label="Skip TLS cert validation"
Expand All @@ -60,18 +56,16 @@ export const StackedList = () => {
label="Another checkbox times 2"
description="Another long description that does not make any sense or does it?"
/>
</VerticalGroup>
</Stack>
</div>
);
};

export const InAField: StoryFn<typeof Checkbox> = (args) => {
return (
<div>
<Field {...args}>
<Checkbox name="hide" id="hide" defaultChecked={true} />
</Field>
</div>
<Field {...args}>
<Checkbox name="hide" id="hide" defaultChecked={true} />
</Field>
);
};

Expand All @@ -93,14 +87,14 @@ export const AllStates: StoryFn<typeof Checkbox> = (args) => {

return (
<div>
<VerticalGroup>
<Stack direction="column" alignItems="flex-start">
<Checkbox value={checked} onChange={onChange} {...args} />
<Checkbox value={true} label="Checked" />
<Checkbox value={false} label="Unchecked" />
<Checkbox value={false} indeterminate={true} label="Interdeterminate" />
<Checkbox value={false} invalid={true} label="Invalid and unchecked" />
<Checkbox value={true} invalid={true} label="Invalid and checked" />
</VerticalGroup>
</Stack>
</div>
);
};
Expand Down

0 comments on commit e65669b

Please sign in to comment.