From bbf3df852feacd44ed1be74a6ba797974d2f3486 Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Fri, 20 Oct 2023 17:13:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(react)=20add=20TextArea=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit How could we ship a design system library without a textarea? --- .changeset/ninety-eggs-cross.md | 5 + .../src/components/Forms/TextArea/index.mdx | 126 +++++++++ .../src/components/Forms/TextArea/index.scss | 108 ++++++++ .../components/Forms/TextArea/index.spec.tsx | 194 +++++++++++++ .../Forms/TextArea/index.stories.tsx | 254 ++++++++++++++++++ .../src/components/Forms/TextArea/index.tsx | 103 +++++++ .../src/components/Forms/TextArea/tokens.ts | 18 ++ packages/react/src/cunningham-tokens.css | 14 + packages/react/src/cunningham-tokens.js | 2 +- packages/react/src/cunningham-tokens.ts | 2 +- packages/react/src/index.scss | 1 + packages/react/src/index.ts | 1 + 12 files changed, 826 insertions(+), 2 deletions(-) create mode 100644 .changeset/ninety-eggs-cross.md create mode 100644 packages/react/src/components/Forms/TextArea/index.mdx create mode 100644 packages/react/src/components/Forms/TextArea/index.scss create mode 100644 packages/react/src/components/Forms/TextArea/index.spec.tsx create mode 100644 packages/react/src/components/Forms/TextArea/index.stories.tsx create mode 100644 packages/react/src/components/Forms/TextArea/index.tsx create mode 100644 packages/react/src/components/Forms/TextArea/tokens.ts diff --git a/.changeset/ninety-eggs-cross.md b/.changeset/ninety-eggs-cross.md new file mode 100644 index 0000000..44faa11 --- /dev/null +++ b/.changeset/ninety-eggs-cross.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": minor +--- + +add TextArea component diff --git a/packages/react/src/components/Forms/TextArea/index.mdx b/packages/react/src/components/Forms/TextArea/index.mdx new file mode 100644 index 0000000..212ad0a --- /dev/null +++ b/packages/react/src/components/Forms/TextArea/index.mdx @@ -0,0 +1,126 @@ +import { Canvas, Meta, Story, Source, ArgTypes } from '@storybook/blocks'; +import * as Stories from './index.stories'; +import { TextArea } from '.'; + + + +# TextArea + +Cunningham provides a versatile TextArea component that you can use in your forms. + + + + + + + +## States + +You can use the following props to change the state of the TextArea component by using the `state` props. + + + + + + + + + + + + + +## Disabled + +As a regular textarea, you can disable it by using the `disabled` props. + + + + + + +## Texts + +You can define a text that will appear below the input by using the `text` props. + + + + + +You can also independently add a text on the right side by using the `rightText` props. + + + + + +## Width + +By default, the textarea has a default width, like all inputs. But you can force it to take the full width of its container by using the `fullWidth` props. + + + + + +## Chars Counter + +You can display a counter of the number of characters entered in the textarea by using the `charsCounter` props. Please bare +in mind to also define `charCounterMax`. + + + + + +## Controlled / Non Controlled + +Like a native textarea, you can use the TextArea component in a controlled or non controlled way. You can see the example below +using the component in a controlled way. + + + + + +## Ref + +You can use the `ref` props to get a reference to the textarea element. + + + + + +## Props + +You can use all the props of the native html `