From 98efe12065fdf4e7c59dad963c26a53759a00f49 Mon Sep 17 00:00:00 2001 From: egor Date: Tue, 20 Sep 2022 12:17:38 +0200 Subject: [PATCH] feat(form): refactored the form with utrecht components --- components/button/css/template.tsx | 23 ++- components/form-feedback/css/template.tsx | 19 +- components/form-field/css/template.tsx | 13 +- components/form-fieldset/css/template.tsx | 7 +- components/form-textinput/css/template.tsx | 26 +-- .../demopages/nl-design-system/Formulier.tsx | 190 ++++++++++++++++++ .../nl-design-system/algemeen-new.stories.mdx | 7 + .../demopages/nl-design-system/index.scss | 3 + 8 files changed, 247 insertions(+), 41 deletions(-) create mode 100644 documentation/demopages/nl-design-system/Formulier.tsx diff --git a/components/button/css/template.tsx b/components/button/css/template.tsx index 35af4773e8..8af3ce49bb 100644 --- a/components/button/css/template.tsx +++ b/components/button/css/template.tsx @@ -3,6 +3,7 @@ * Copyright (c) 2022 Community for NL Design System */ import '@utrecht/component-library-css'; +import { Button as ButtonUtrecht } from '@utrecht/component-library-react'; import clsx from 'clsx'; import React from 'react'; import { iconNames as iconOptions } from '../../icon/css/template'; @@ -92,22 +93,16 @@ export const Button: React.FC = ({
); return ( - + ); }; diff --git a/components/form-feedback/css/template.tsx b/components/form-feedback/css/template.tsx index d4ed477920..522cd75417 100644 --- a/components/form-feedback/css/template.tsx +++ b/components/form-feedback/css/template.tsx @@ -2,6 +2,7 @@ * @license EUPL-1.2 * Copyright (c) 2021 Community for NL Design System */ +import { FormFieldDescription } from '@utrecht/component-library-react'; import React from 'react'; import './index.scss'; @@ -26,17 +27,23 @@ export const defaultArgs: IFeedbackProps = { export const FormFeedback: React.FC = ({ text = defaultArgs.text, type = defaultArgs.type }) => { if (type === 'warning') { return ( -
-
+ +
{text} -
+ ); } else { return ( -
-
+ +
{text} -
+ ); } }; diff --git a/components/form-field/css/template.tsx b/components/form-field/css/template.tsx index 47f9c42f7c..8d67c4139a 100644 --- a/components/form-field/css/template.tsx +++ b/components/form-field/css/template.tsx @@ -2,6 +2,7 @@ * @license EUPL-1.2 * Copyright (c) 2021 Community for NL Design System */ +import { FormField, FormLabel } from '@utrecht/component-library-react'; import React from 'react'; import { ExpandableText } from '../../expandable-text/css/template'; import { FormFeedback } from '../../form-feedback/css/template'; @@ -80,14 +81,16 @@ export const Field: React.FC = ({ } return ( -
-
+ ); }; diff --git a/components/form-fieldset/css/template.tsx b/components/form-fieldset/css/template.tsx index 4011bd2834..670b39d58a 100644 --- a/components/form-fieldset/css/template.tsx +++ b/components/form-fieldset/css/template.tsx @@ -2,6 +2,7 @@ * @license EUPL-1.2 * Copyright (c) 2021 Community for NL Design System */ +import { FieldsetLegend, Fieldset as FieldsetUtrecht } from '@utrecht/component-library-react'; import React from 'react'; import { ITextInputFieldProps, TextInputField } from '../../form-field/css/textinput-field.template'; @@ -61,11 +62,11 @@ export const Fieldset: React.FC = ({ children, }) => { return ( -
- {legend && {legend}} + + {legend && {legend}} {fields && fields.map((fieldProps) => )} {children} -
+ ); }; diff --git a/components/form-textinput/css/template.tsx b/components/form-textinput/css/template.tsx index 5efacd8fd4..0adba06de6 100644 --- a/components/form-textinput/css/template.tsx +++ b/components/form-textinput/css/template.tsx @@ -2,8 +2,8 @@ * @license EUPL-1.2 * Copyright (c) 2021 Community for NL Design System */ -import clsx from 'clsx'; import './index.scss'; +import { Textarea, Textbox } from '@utrecht/component-library-react'; import React from 'react'; export interface ITextInputProps { @@ -65,7 +65,6 @@ export const defaultArgs: ITextInputProps = { export const TextInput: React.FC = ({ id = defaultArgs.id, disabled = defaultArgs.disabled, - focus = defaultArgs.focus, invalid = defaultArgs.invalid, readOnly = defaultArgs.readOnly, required = defaultArgs.required, @@ -76,20 +75,11 @@ export const TextInput: React.FC = ({ }) => { const props = { id, - className: clsx( - 'utrecht-textbox', - 'utrecht-textbox--html-input', - disabled && 'utrecht-textbox--disabled', - focus && 'utrecht-textbox--focus utrecht-textbox--focus-visible', - invalid && 'utrecht-textbox--invalid', - readOnly && 'utrecht-textbox--readonly', - required && 'utrecht-textbox--required', - ), - disabled: disabled || null, - 'aria-invalid': invalid || null, - required: required || null, - readOnly: readOnly || null, - placeholder: placeholder || null, + disabled, + invalid, + required, + readOnly, + placeholder, defaultValue: value, ...((valueType === 'number' || valueType === 'currency') && { inputMode: 'numeric' as any, @@ -98,13 +88,13 @@ export const TextInput: React.FC = ({ }; if (inputType === 'text') { - const inputMarkup = ; + const inputMarkup = ; if (valueType === 'currency') { return
€{inputMarkup}
; } else { return inputMarkup; } } else { - return