From 2f13d5f009556c59a81c8cdbd8fad8c1e6c62bb9 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 8 Oct 2022 10:50:56 +0800 Subject: [PATCH] [ui][text area] implementation --- apps/storybook/stories/text-area.stories.tsx | 144 ++++++++++++++++++ apps/storybook/stories/text-input.stories.tsx | 2 +- packages/ui/src/TextArea/TextArea.tsx | 141 +++++++++++++++++ packages/ui/src/TextInput/TextInput.tsx | 3 +- packages/ui/src/index.tsx | 3 + 5 files changed, 290 insertions(+), 3 deletions(-) create mode 100644 apps/storybook/stories/text-area.stories.tsx create mode 100644 packages/ui/src/TextArea/TextArea.tsx diff --git a/apps/storybook/stories/text-area.stories.tsx b/apps/storybook/stories/text-area.stories.tsx new file mode 100644 index 00000000..14d4acdb --- /dev/null +++ b/apps/storybook/stories/text-area.stories.tsx @@ -0,0 +1,144 @@ +import React, { useState } from 'react'; +import type { ComponentMeta } from '@storybook/react'; +import type { TextAreaResize } from '@tih/ui'; +import { TextArea } from '@tih/ui'; + +const textAreaResize: ReadonlyArray = [ + 'vertical', + 'horizontal', + 'none', + 'both', +]; + +export default { + argTypes: { + autoComplete: { + control: 'text', + }, + disabled: { + control: 'boolean', + }, + errorMessage: { + control: 'text', + }, + isLabelHidden: { + control: 'boolean', + }, + label: { + control: 'text', + }, + name: { + control: 'text', + }, + placeholder: { + control: 'text', + }, + readOnly: { + control: 'boolean', + }, + required: { + control: 'boolean', + }, + resize: { + control: { type: 'select' }, + options: textAreaResize, + }, + rows: { + control: 'number', + }, + }, + component: TextArea, + title: 'TextArea', +} as ComponentMeta; + +export const Basic = { + args: { + label: 'Comment', + placeholder: 'Type your comment here', + }, +}; + +export function HiddenLabel() { + const [value, setValue] = useState(''); + + return ( +