mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-30 05:34:33 +08:00
storybook: add lint command and lint files
This commit is contained in:
@ -1,4 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
extends: ['tih'],
|
extends: ['tih'],
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
project: ['./tsconfig.json'],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"build": "build-storybook --docs",
|
"build": "build-storybook --docs",
|
||||||
"preview-storybook": "serve storybook-static",
|
"preview-storybook": "serve storybook-static",
|
||||||
"clean": "rm -rf .turbo && rm -rf node_modules",
|
"clean": "rm -rf .turbo && rm -rf node_modules",
|
||||||
|
"lint": "eslint stories/**/*.ts* --fix",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Alert, AlertVariant } from '@tih/ui';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { AlertVariant } from '@tih/ui';
|
||||||
|
import { Alert } from '@tih/ui';
|
||||||
|
|
||||||
const alertVariants: ReadonlyArray<AlertVariant> = [
|
const alertVariants: ReadonlyArray<AlertVariant> = [
|
||||||
'info',
|
'info',
|
||||||
@ -10,24 +11,24 @@ const alertVariants: ReadonlyArray<AlertVariant> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Alert',
|
|
||||||
component: Alert,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
title: {
|
title: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
variant: {
|
variant: {
|
||||||
options: alertVariants,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: alertVariants,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Alert,
|
||||||
|
title: 'Alert',
|
||||||
} as ComponentMeta<typeof Alert>;
|
} as ComponentMeta<typeof Alert>;
|
||||||
|
|
||||||
export const Basic = {
|
export const Basic = {
|
||||||
args: {
|
args: {
|
||||||
|
children: 'This is something you should pay your full attention to.',
|
||||||
title: 'Please pay attention',
|
title: 'Please pay attention',
|
||||||
variant: 'info',
|
variant: 'info',
|
||||||
children: 'This is something you should pay your full attention to.',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Badge, BadgeVariant } from '@tih/ui';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { BadgeVariant } from '@tih/ui';
|
||||||
|
import { Badge } from '@tih/ui';
|
||||||
|
|
||||||
const badgeVariants: ReadonlyArray<BadgeVariant> = [
|
const badgeVariants: ReadonlyArray<BadgeVariant> = [
|
||||||
'primary',
|
'primary',
|
||||||
@ -11,14 +12,14 @@ const badgeVariants: ReadonlyArray<BadgeVariant> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Badge',
|
|
||||||
component: Badge,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
variant: {
|
variant: {
|
||||||
options: badgeVariants,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: badgeVariants,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Badge,
|
||||||
|
title: 'Badge',
|
||||||
} as ComponentMeta<typeof Badge>;
|
} as ComponentMeta<typeof Badge>;
|
||||||
|
|
||||||
export const Basic = {
|
export const Basic = {
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
import React from 'react';
|
||||||
|
import { EnvelopeIcon } from '@heroicons/react/24/solid';
|
||||||
import {
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
Button,
|
import type {
|
||||||
ButtonAddOnPosition,
|
ButtonAddOnPosition,
|
||||||
ButtonDisplay,
|
ButtonDisplay,
|
||||||
ButtonSize,
|
ButtonSize,
|
||||||
ButtonType,
|
ButtonType,
|
||||||
ButtonVariant,
|
ButtonVariant} from '@tih/ui';
|
||||||
|
import {
|
||||||
|
Button
|
||||||
} from '@tih/ui';
|
} from '@tih/ui';
|
||||||
import React from 'react';
|
|
||||||
import { EnvelopeIcon } from '@heroicons/react/24/solid';
|
|
||||||
|
|
||||||
const buttonTypes: ReadonlyArray<ButtonType> = ['button', 'reset', 'submit'];
|
const buttonTypes: ReadonlyArray<ButtonType> = ['button', 'reset', 'submit'];
|
||||||
const buttonSizes: ReadonlyArray<ButtonSize> = ['sm', 'md', 'lg'];
|
const buttonSizes: ReadonlyArray<ButtonSize> = ['sm', 'md', 'lg'];
|
||||||
@ -27,16 +27,14 @@ const buttonVariants: ReadonlyArray<ButtonVariant> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Button',
|
|
||||||
component: Button,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
addonPosition: {
|
addonPosition: {
|
||||||
options: buttonAddOnPositions,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: buttonAddOnPositions,
|
||||||
},
|
},
|
||||||
display: {
|
display: {
|
||||||
options: buttonDisplays,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: buttonDisplays,
|
||||||
},
|
},
|
||||||
isDisabled: {
|
isDisabled: {
|
||||||
control: 'boolean',
|
control: 'boolean',
|
||||||
@ -48,18 +46,20 @@ export default {
|
|||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
options: buttonSizes,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: buttonSizes,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
options: buttonTypes,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: buttonTypes,
|
||||||
},
|
},
|
||||||
variant: {
|
variant: {
|
||||||
options: buttonVariants,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: buttonVariants,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Button,
|
||||||
|
title: 'Button',
|
||||||
} as ComponentMeta<typeof Button>;
|
} as ComponentMeta<typeof Button>;
|
||||||
|
|
||||||
export const Basic = {
|
export const Basic = {
|
||||||
@ -111,8 +111,8 @@ export function Disabled() {
|
|||||||
<div className="space-x-4">
|
<div className="space-x-4">
|
||||||
{buttonVariants.map((variant) => (
|
{buttonVariants.map((variant) => (
|
||||||
<Button
|
<Button
|
||||||
isDisabled={true}
|
|
||||||
key={variant}
|
key={variant}
|
||||||
|
isDisabled={true}
|
||||||
label="Click Me"
|
label="Click Me"
|
||||||
size="md"
|
size="md"
|
||||||
variant={variant}
|
variant={variant}
|
||||||
@ -128,8 +128,8 @@ export function Loading() {
|
|||||||
<div className="space-x-4">
|
<div className="space-x-4">
|
||||||
{buttonVariants.map((variant) => (
|
{buttonVariants.map((variant) => (
|
||||||
<Button
|
<Button
|
||||||
isLoading={true}
|
|
||||||
key={variant}
|
key={variant}
|
||||||
|
isLoading={true}
|
||||||
label="Click Me"
|
label="Click Me"
|
||||||
size="md"
|
size="md"
|
||||||
variant={variant}
|
variant={variant}
|
||||||
@ -139,9 +139,9 @@ export function Loading() {
|
|||||||
<div className="space-x-4">
|
<div className="space-x-4">
|
||||||
{buttonVariants.map((variant) => (
|
{buttonVariants.map((variant) => (
|
||||||
<Button
|
<Button
|
||||||
|
key={variant}
|
||||||
isDisabled={true}
|
isDisabled={true}
|
||||||
isLoading={true}
|
isLoading={true}
|
||||||
key={variant}
|
|
||||||
label="Click Me"
|
label="Click Me"
|
||||||
size="md"
|
size="md"
|
||||||
variant={variant}
|
variant={variant}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Button, Dialog } from '@tih/ui';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import { Button, Dialog } from '@tih/ui';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Dialog',
|
|
||||||
component: Dialog,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
title: {
|
title: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Dialog,
|
||||||
|
title: 'Dialog',
|
||||||
} as ComponentMeta<typeof Dialog>;
|
} as ComponentMeta<typeof Dialog>;
|
||||||
|
|
||||||
export function Basic({
|
export function Basic({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { DropdownMenu, DropdownMenuAlignment, DropdownMenuSize } from '@tih/ui';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { DropdownMenuAlignment, DropdownMenuSize } from '@tih/ui';
|
||||||
|
import { DropdownMenu } from '@tih/ui';
|
||||||
|
|
||||||
const DropdownMenuAlignments: ReadonlyArray<DropdownMenuAlignment> = [
|
const DropdownMenuAlignments: ReadonlyArray<DropdownMenuAlignment> = [
|
||||||
'start',
|
'start',
|
||||||
@ -12,27 +13,27 @@ const DropdownMenuSizes: ReadonlyArray<DropdownMenuSize> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'DropdownMenu',
|
|
||||||
component: DropdownMenu,
|
|
||||||
parameters: {
|
|
||||||
docs: {
|
|
||||||
inlineStories: false,
|
|
||||||
iframeHeight: 300,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
align: {
|
align: {
|
||||||
options: DropdownMenuAlignments,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: DropdownMenuAlignments,
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
options: DropdownMenuSizes,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: DropdownMenuSizes,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: DropdownMenu,
|
||||||
|
parameters: {
|
||||||
|
docs: {
|
||||||
|
iframeHeight: 300,
|
||||||
|
inlineStories: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
title: 'DropdownMenu',
|
||||||
} as ComponentMeta<typeof DropdownMenu>;
|
} as ComponentMeta<typeof DropdownMenu>;
|
||||||
|
|
||||||
export function Basic({
|
export function Basic({
|
||||||
@ -62,11 +63,11 @@ export function Basic({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu align={align} label={label} size={size}>
|
<DropdownMenu align={align} label={label} size={size}>
|
||||||
{menuItems.map(({ label, value }) => (
|
{menuItems.map(({ label: itemLabel, value }) => (
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
key={value}
|
key={value}
|
||||||
isSelected={value === selectedValue}
|
isSelected={value === selectedValue}
|
||||||
label={label}
|
label={itemLabel}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedValue(value);
|
setSelectedValue(value);
|
||||||
}}
|
}}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Select, SelectDisplay } from '@tih/ui';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { SelectDisplay } from '@tih/ui';
|
||||||
|
import { Select } from '@tih/ui';
|
||||||
|
|
||||||
const SelectDisplays: ReadonlyArray<SelectDisplay> = ['inline', 'block'];
|
const SelectDisplays: ReadonlyArray<SelectDisplay> = ['inline', 'block'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Select',
|
|
||||||
component: Select,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
display: {
|
display: {
|
||||||
options: SelectDisplays,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: SelectDisplays,
|
||||||
},
|
},
|
||||||
isLabelHidden: {
|
isLabelHidden: {
|
||||||
control: 'boolean',
|
control: 'boolean',
|
||||||
@ -22,6 +21,8 @@ export default {
|
|||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Select,
|
||||||
|
title: 'Select',
|
||||||
} as ComponentMeta<typeof Select>;
|
} as ComponentMeta<typeof Select>;
|
||||||
|
|
||||||
export function Basic({
|
export function Basic({
|
||||||
@ -40,7 +41,6 @@ export function Basic({
|
|||||||
display={display}
|
display={display}
|
||||||
isLabelHidden={isLabelHidden}
|
isLabelHidden={isLabelHidden}
|
||||||
label={label}
|
label={label}
|
||||||
onChange={setValue}
|
|
||||||
name={name}
|
name={name}
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
@ -57,14 +57,15 @@ export function Basic({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={value}
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Basic.args = {
|
Basic.args = {
|
||||||
label: 'Select fruit',
|
|
||||||
display: 'inline',
|
display: 'inline',
|
||||||
isLabelHidden: false,
|
isLabelHidden: false,
|
||||||
|
label: 'Select fruit',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Display() {
|
export function Display() {
|
||||||
@ -74,7 +75,6 @@ export function Display() {
|
|||||||
<div className="space-x-4">
|
<div className="space-x-4">
|
||||||
<Select
|
<Select
|
||||||
label="Select a fruit"
|
label="Select a fruit"
|
||||||
onChange={setValue}
|
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
label: 'Apple',
|
label: 'Apple',
|
||||||
@ -90,6 +90,7 @@ export function Display() {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={value}
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Button, SlideOut, SlideOutEnterFrom, SlideOutSize } from '@tih/ui';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { SlideOutEnterFrom, SlideOutSize } from '@tih/ui';
|
||||||
|
import { Button, SlideOut } from '@tih/ui';
|
||||||
|
|
||||||
const slideOutEnterFrom: ReadonlyArray<SlideOutEnterFrom> = ['start', 'end'];
|
const slideOutEnterFrom: ReadonlyArray<SlideOutEnterFrom> = ['start', 'end'];
|
||||||
const slideOutSize: ReadonlyArray<SlideOutSize> = ['sm', 'md', 'lg', 'xl'];
|
const slideOutSize: ReadonlyArray<SlideOutSize> = ['sm', 'md', 'lg', 'xl'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'SlideOut',
|
|
||||||
component: SlideOut,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
|
enterFrom: {
|
||||||
|
control: { type: 'select' },
|
||||||
|
options: slideOutEnterFrom,
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
control: { type: 'select' },
|
||||||
|
options: slideOutSize,
|
||||||
|
},
|
||||||
title: {
|
title: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
enterFrom: {
|
|
||||||
options: slideOutEnterFrom,
|
|
||||||
control: { type: 'select' },
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
options: slideOutSize,
|
|
||||||
control: { type: 'select' },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
component: SlideOut,
|
||||||
|
title: 'SlideOut',
|
||||||
} as ComponentMeta<typeof SlideOut>;
|
} as ComponentMeta<typeof SlideOut>;
|
||||||
|
|
||||||
export function Basic({
|
export function Basic({
|
||||||
@ -50,8 +51,8 @@ export function Basic({
|
|||||||
}
|
}
|
||||||
|
|
||||||
Basic.args = {
|
Basic.args = {
|
||||||
title: 'Navigation',
|
|
||||||
children: <div className="p-4">Hello World</div>,
|
children: <div className="p-4">Hello World</div>,
|
||||||
enterFrom: 'end',
|
enterFrom: 'end',
|
||||||
size: 'md',
|
size: 'md',
|
||||||
|
title: 'Navigation',
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
|
|
||||||
import { Spinner, SpinnerColor, SpinnerSize, SpinnerDisplay } from '@tih/ui';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import type { SpinnerColor, SpinnerDisplay,SpinnerSize } from '@tih/ui';
|
||||||
|
import { Spinner } from '@tih/ui';
|
||||||
|
|
||||||
const spinnerColors: ReadonlyArray<SpinnerColor> = ['default', 'inherit'];
|
const spinnerColors: ReadonlyArray<SpinnerColor> = ['default', 'inherit'];
|
||||||
const spinnerDisplays: ReadonlyArray<SpinnerDisplay> = ['block', 'inline'];
|
const spinnerDisplays: ReadonlyArray<SpinnerDisplay> = ['block', 'inline'];
|
||||||
const spinnerSizes: ReadonlyArray<SpinnerSize> = ['xs', 'sm', 'md', 'lg'];
|
const spinnerSizes: ReadonlyArray<SpinnerSize> = ['xs', 'sm', 'md', 'lg'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Spinner',
|
|
||||||
component: Spinner,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
color: {
|
color: {
|
||||||
options: spinnerColors,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: spinnerColors,
|
||||||
},
|
},
|
||||||
display: {
|
display: {
|
||||||
options: spinnerDisplays,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: spinnerDisplays,
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
options: spinnerSizes,
|
|
||||||
control: { type: 'select' },
|
control: { type: 'select' },
|
||||||
|
options: spinnerSizes,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Spinner,
|
||||||
|
title: 'Spinner',
|
||||||
} as ComponentMeta<typeof Spinner>;
|
} as ComponentMeta<typeof Spinner>;
|
||||||
|
|
||||||
export const Basic = {
|
export const Basic = {
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import { ComponentMeta } from '@storybook/react';
|
|
||||||
import { Tabs } from '@tih/ui';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
|
import { Tabs } from '@tih/ui';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Tabs',
|
|
||||||
component: Tabs,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
label: {
|
label: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: Tabs,
|
||||||
|
title: 'Tabs',
|
||||||
} as ComponentMeta<typeof Tabs>;
|
} as ComponentMeta<typeof Tabs>;
|
||||||
|
|
||||||
export function Basic({
|
export function Basic({
|
||||||
@ -20,7 +20,6 @@ export function Basic({
|
|||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
label={label}
|
label={label}
|
||||||
onChange={setValue}
|
|
||||||
tabs={[
|
tabs={[
|
||||||
{
|
{
|
||||||
label: 'Apple',
|
label: 'Apple',
|
||||||
@ -36,6 +35,7 @@ export function Basic({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={value}
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
EnvelopeIcon,
|
EnvelopeIcon,
|
||||||
KeyIcon,
|
KeyIcon,
|
||||||
QuestionMarkCircleIcon,
|
QuestionMarkCircleIcon,
|
||||||
} from '@heroicons/react/24/solid';
|
} from '@heroicons/react/24/solid';
|
||||||
import { ComponentMeta } from '@storybook/react';
|
import type { ComponentMeta } from '@storybook/react';
|
||||||
import { TextInput } from '@tih/ui';
|
import { TextInput } from '@tih/ui';
|
||||||
import React, { useState } from 'react';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'TextInput',
|
|
||||||
component: TextInput,
|
|
||||||
argTypes: {
|
argTypes: {
|
||||||
autoComplete: {
|
autoComplete: {
|
||||||
control: 'text',
|
control: 'text',
|
||||||
@ -36,6 +34,8 @@ export default {
|
|||||||
control: 'text',
|
control: 'text',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
component: TextInput,
|
||||||
|
title: 'TextInput',
|
||||||
} as ComponentMeta<typeof TextInput>;
|
} as ComponentMeta<typeof TextInput>;
|
||||||
|
|
||||||
export const Basic = {
|
export const Basic = {
|
||||||
@ -89,9 +89,9 @@ export function Icon() {
|
|||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
startIcon={QuestionMarkCircleIcon}
|
|
||||||
label="Account number"
|
label="Account number"
|
||||||
placeholder="000-00-0000"
|
placeholder="000-00-0000"
|
||||||
|
startIcon={QuestionMarkCircleIcon}
|
||||||
type="text"
|
type="text"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
@ -116,10 +116,10 @@ export function Error() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Email"
|
|
||||||
errorMessage={
|
errorMessage={
|
||||||
value.length < 6 ? 'Password must be at least 6 characters' : undefined
|
value.length < 6 ? 'Password must be at least 6 characters' : undefined
|
||||||
}
|
}
|
||||||
|
label="Email"
|
||||||
startIcon={KeyIcon}
|
startIcon={KeyIcon}
|
||||||
type="password"
|
type="password"
|
||||||
value={value}
|
value={value}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Menu } from '@headlessui/react';
|
import { Menu } from '@headlessui/react';
|
||||||
|
|
||||||
type Props = Readonly<{
|
type Props = Readonly<{
|
||||||
|
Reference in New Issue
Block a user