2022-11-03 18:09:54 +01:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import {
|
|
|
|
DISPLAY,
|
|
|
|
FLEX_DIRECTION,
|
2023-02-02 21:15:26 +01:00
|
|
|
Size,
|
|
|
|
AlignItems,
|
|
|
|
IconColor,
|
2022-11-03 18:09:54 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
import Box from '../../ui/box';
|
2022-11-29 22:01:05 +01:00
|
|
|
|
|
|
|
import { Icon, ICON_NAMES, TextField } from '..';
|
2022-11-03 18:09:54 +01:00
|
|
|
|
|
|
|
import { Label } from './label';
|
|
|
|
|
|
|
|
import README from './README.mdx';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/ComponentLibrary/Label',
|
2023-01-20 20:27:46 +01:00
|
|
|
|
2022-11-03 18:09:54 +01:00
|
|
|
component: Label,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
htmlFor: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
required: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args: {
|
|
|
|
children: 'Label',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const Template = (args) => <Label {...args} />;
|
|
|
|
|
|
|
|
export const DefaultStory = Template.bind({});
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
|
|
|
export const Children = (args) => (
|
|
|
|
<Box
|
|
|
|
display={DISPLAY.INLINE_FLEX}
|
|
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
|
|
gap={2}
|
|
|
|
>
|
|
|
|
<Label {...args}>Plain text</Label>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Label {...args} display={DISPLAY.FLEX} alignItems={AlignItems.flexStart}>
|
2022-11-03 18:09:54 +01:00
|
|
|
Text and icon
|
|
|
|
<Icon
|
2023-02-02 21:15:26 +01:00
|
|
|
color={IconColor.iconAlternative}
|
2023-01-24 18:39:46 +01:00
|
|
|
name={ICON_NAMES.INFO}
|
2023-02-02 21:15:26 +01:00
|
|
|
size={Size.inherit}
|
2022-11-03 18:09:54 +01:00
|
|
|
/>
|
|
|
|
</Label>
|
|
|
|
<Label
|
|
|
|
{...args}
|
|
|
|
display={DISPLAY.INLINE_FLEX}
|
|
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.flexStart}
|
2022-11-03 18:09:54 +01:00
|
|
|
>
|
|
|
|
Label that wraps an input
|
2022-11-29 22:01:05 +01:00
|
|
|
<TextField placeholder="Click label to focus" />
|
2022-11-03 18:09:54 +01:00
|
|
|
</Label>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const HtmlFor = (args) => {
|
|
|
|
const [value, setValue] = useState('');
|
|
|
|
const handleOnChange = (e) => {
|
|
|
|
setValue(e.target.value);
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<Box display={DISPLAY.INLINE_FLEX} flexDirection={FLEX_DIRECTION.COLUMN}>
|
|
|
|
<Label {...args} />
|
2022-11-29 22:01:05 +01:00
|
|
|
<TextField
|
2022-11-03 18:09:54 +01:00
|
|
|
id="add-network"
|
|
|
|
value={value}
|
|
|
|
onChange={handleOnChange}
|
|
|
|
placeholder="Enter network name"
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
HtmlFor.args = {
|
|
|
|
children: 'Network name',
|
|
|
|
htmlFor: 'add-network',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Required = Template.bind({});
|
|
|
|
Required.args = {
|
|
|
|
required: true,
|
|
|
|
};
|