From 40e789cd5f03eaabc75f2251bf5a0351efaa5887 Mon Sep 17 00:00:00 2001 From: literat Date: Wed, 28 Jun 2023 10:22:57 +0200 Subject: [PATCH] Docs(web-react): Align Field components README examples with other packages' READMEs --- .../src/components/CheckboxField/README.md | 23 +++++++++--- .../web-react/src/components/Field/README.md | 10 ++++- .../src/components/Field/ValidationText.tsx | 2 +- .../components/Field/useValidationText.tsx | 10 ++--- .../src/components/RadioField/README.md | 23 +++++++++++- .../web-react/src/components/Select/README.md | 24 +++++++++++- .../src/components/TextArea/README.md | 26 +++++++++++-- .../stories/TextAreaValidationState.tsx | 6 +-- .../src/components/TextField/README.md | 37 +++++++++++++++++-- .../stories/TextFieldValidationState.tsx | 6 +-- .../src/components/TextFieldBase/README.md | 36 +++++++++++++++++- 11 files changed, 173 insertions(+), 30 deletions(-) diff --git a/packages/web-react/src/components/CheckboxField/README.md b/packages/web-react/src/components/CheckboxField/README.md index e7d3158d0e..998b3e16cb 100644 --- a/packages/web-react/src/components/CheckboxField/README.md +++ b/packages/web-react/src/components/CheckboxField/README.md @@ -1,16 +1,27 @@ # CheckboxField -CheckboxField enables the user to check/uncheck choice. It has input, a label, and an optional helperText. -It could be disabled or have a validation state. The label could be hidden and show if the input is required. +CheckboxField enables the user to check/uncheck choice. +It has input, a label, and an optional helperText. +It could be disabled or have a validation state. +The label could be hidden and show if the input is required. + +Basic example usage: + +```jsx + +``` + +Advanced example usage: ```jsx ``` diff --git a/packages/web-react/src/components/Field/README.md b/packages/web-react/src/components/Field/README.md index a9a70274e0..c3f163af18 100644 --- a/packages/web-react/src/components/Field/README.md +++ b/packages/web-react/src/components/Field/README.md @@ -8,8 +8,16 @@ The ValidationText subcomponent displays validation texts for Field components l import { ValidationText } from '@lmc-eu/spirit-web-react/components'; ``` +Basic example usage: + +```jsx + +``` + +Advanced example: + ```jsx - + ``` ## ValidationText diff --git a/packages/web-react/src/components/Field/ValidationText.tsx b/packages/web-react/src/components/Field/ValidationText.tsx index 1661c3f783..4ecf6f389b 100644 --- a/packages/web-react/src/components/Field/ValidationText.tsx +++ b/packages/web-react/src/components/Field/ValidationText.tsx @@ -7,8 +7,8 @@ export interface ValidationTextProps extends ValidationTextProp { } const defaultProps = { - elementType: 'div', className: undefined, + elementType: 'div', }; export const ValidationText = (props: ValidationTextProps) => { diff --git a/packages/web-react/src/components/Field/useValidationText.tsx b/packages/web-react/src/components/Field/useValidationText.tsx index 8d65f0b490..bff99ffd03 100644 --- a/packages/web-react/src/components/Field/useValidationText.tsx +++ b/packages/web-react/src/components/Field/useValidationText.tsx @@ -3,14 +3,14 @@ import { ValidationState, ValidationTextType } from '../../types'; import ValidationText from './ValidationText'; export interface UseValidationTextProps { - validationTextClassName?: string; + validationElementType?: ElementType; validationState?: ValidationState; validationText?: ValidationTextType; - validationElementType?: ElementType; + validationTextClassName?: string; } export const useValidationText = (props: UseValidationTextProps): ReactNode => { - const { validationTextClassName, validationState, validationText, validationElementType } = props; + const { validationElementType, validationState, validationText, validationTextClassName } = props; return useMemo( () => @@ -18,10 +18,10 @@ export const useValidationText = (props: UseValidationTextProps): ReactNode => { validationText && ( ), - [validationState, validationText, validationElementType, validationTextClassName], + [validationElementType, validationState, validationText, validationTextClassName], ); }; diff --git a/packages/web-react/src/components/RadioField/README.md b/packages/web-react/src/components/RadioField/README.md index 55d2cddb58..1a9dae6192 100644 --- a/packages/web-react/src/components/RadioField/README.md +++ b/packages/web-react/src/components/RadioField/README.md @@ -1,9 +1,28 @@ # RadioField -Use RadioField when you have a group of mutually exclusive choices and only one selection from the group is allowed. It has input and label. It can be disabled or have a validation state. The label can be hidden. +Use RadioField when you have a group of mutually exclusive choices and only one selection from the group is allowed. +It has input and label. +It can be disabled or have a validation state. +The label can be hidden. + +Basic example usage: + +```jsx + +``` + +Advanced example usage: ```jsx - + ``` ## Available props diff --git a/packages/web-react/src/components/Select/README.md b/packages/web-react/src/components/Select/README.md index a63da2347e..68b869024b 100644 --- a/packages/web-react/src/components/Select/README.md +++ b/packages/web-react/src/components/Select/README.md @@ -1,7 +1,29 @@ # Select +This is React implementation of the [Select][select] component. + +Basic example usage: + +```jsx + +``` + +Advanced example usage: + ```jsx - diff --git a/packages/web-react/src/components/TextArea/README.md b/packages/web-react/src/components/TextArea/README.md index 163cb7af27..46f382cd01 100644 --- a/packages/web-react/src/components/TextArea/README.md +++ b/packages/web-react/src/components/TextArea/README.md @@ -1,14 +1,34 @@ # TextArea TextArea enables the user to add longer text to a form. -It could be disabled or have a validation state with validation text. +It could be disabled or have a validation state with optional validation text. The label could be hidden and show if the textarea is required. +Basic example usage: + +```jsx +