From f98a1a422e0d3854c04d058e7828fdde3968d1c5 Mon Sep 17 00:00:00 2001 From: mfrachet Date: Tue, 7 Sep 2021 16:23:05 +0200 Subject: [PATCH] Adding stories --- .../lib/src/components/Form/Form.stories.mdx | 75 +++++++++++++++++++ .../src/{old => }/components/Form/index.js | 0 packages/core/helper-plugin/lib/src/index.js | 2 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 packages/core/helper-plugin/lib/src/components/Form/Form.stories.mdx rename packages/core/helper-plugin/lib/src/{old => }/components/Form/index.js (100%) diff --git a/packages/core/helper-plugin/lib/src/components/Form/Form.stories.mdx b/packages/core/helper-plugin/lib/src/components/Form/Form.stories.mdx new file mode 100644 index 000000000000..8650c3f19d5a --- /dev/null +++ b/packages/core/helper-plugin/lib/src/components/Form/Form.stories.mdx @@ -0,0 +1,75 @@ + + +import { Meta, ArgsTable, Canvas, Story } from '@storybook/addon-docs'; +import { Main, Row } from '@strapi/parts'; +import { TextInput } from '@strapi/parts/TextInput'; +import { Button } from '@strapi/parts/Button'; +import { Box } from '@strapi/parts/Box'; +import { Text } from '@strapi/parts/Text'; +import { Formik } from 'formik'; +import * as Yup from 'yup'; +import Form from './'; + + + +# Form + +This component is used to display a Formik form with additionnal error handling on fields + +## Per field error + + + +
+ + {({ handleSubmit, values, errors, handleChange }) => ( +
+ + + + )} +
+
+
+
+ +## Per form error + +Make sure to run this story in detached mode. The embeded iframe breaks the focus behaviour. + + + +
+ + {({ handleSubmit, values, errors, handleChange }) => ( +
+ {errors.email ? + The email is invalid + : null} + + + + )} +
+
+
+
+ +### Props + + diff --git a/packages/core/helper-plugin/lib/src/old/components/Form/index.js b/packages/core/helper-plugin/lib/src/components/Form/index.js similarity index 100% rename from packages/core/helper-plugin/lib/src/old/components/Form/index.js rename to packages/core/helper-plugin/lib/src/components/Form/index.js diff --git a/packages/core/helper-plugin/lib/src/index.js b/packages/core/helper-plugin/lib/src/index.js index 3963c0eb07ad..0052c821d7f2 100644 --- a/packages/core/helper-plugin/lib/src/index.js +++ b/packages/core/helper-plugin/lib/src/index.js @@ -23,7 +23,6 @@ export { default as HeaderSearch } from './old/components/HeaderSearch'; export { default as IcoContainer } from './old/components/IcoContainer'; export { default as InputAddon } from './old/components/InputAddon'; export { default as EmptyState } from './old/components/EmptyState'; -export { default as Form } from './old/components/Form'; export * from './old/components/Tabs'; export * from './old/components/Select'; @@ -190,6 +189,7 @@ export { default as LoadingIndicatorPage } from './components/LoadingIndicatorPa export { default as SettingsPageTitle } from './components/SettingsPageTitle'; export { default as Search } from './components/Search'; export { default as Status } from './components/Status'; +export { default as Form } from './components/Form'; // New icons export { default as SortIcon } from './icons/SortIcon';