From a847190f3312539281cb9f4aedb5da527eff7fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Mon, 11 Jul 2022 23:34:45 +0200 Subject: [PATCH] refactor(editor): Create N8nCheckbox Vue component (#3678) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Implementing N8nCheckbox Vue component * ✨ Added checkbox support to N8nFormInput component * 👌 Updating n8n-checkbox component so it supports indeterminate state and input event * 💄 Adding the `labelSize` property to the `N8nCheckbox` component --- .../N8nCheckbox/Checkbox.stories.ts | 36 ++++++++++ .../src/components/N8nCheckbox/Checkbox.vue | 66 +++++++++++++++++++ .../src/components/N8nCheckbox/index.ts | 3 + .../src/components/N8nFormInput/FormInput.vue | 17 ++++- .../N8nFormInputs/FormInputs.stories.js | 9 +++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 packages/design-system/src/components/N8nCheckbox/Checkbox.stories.ts create mode 100644 packages/design-system/src/components/N8nCheckbox/Checkbox.vue create mode 100644 packages/design-system/src/components/N8nCheckbox/index.ts diff --git a/packages/design-system/src/components/N8nCheckbox/Checkbox.stories.ts b/packages/design-system/src/components/N8nCheckbox/Checkbox.stories.ts new file mode 100644 index 0000000000..a253cba7ac --- /dev/null +++ b/packages/design-system/src/components/N8nCheckbox/Checkbox.stories.ts @@ -0,0 +1,36 @@ +/* tslint:disable:variable-name */ +import N8nCheckbox from "./Checkbox.vue"; +import { StoryFn } from '@storybook/vue'; +import { action } from '@storybook/addon-actions'; + +export default { + title: 'Atoms/Checkbox', + component: N8nCheckbox, +}; + +const methods = { + onInput: action('input'), + onFocus: action('focus'), + onChange: action('change'), +}; + +const DefaultTemplate: StoryFn = (args, { argTypes }) => ({ + props: Object.keys(argTypes), + components: { + N8nCheckbox, + }, + data: () => ({ + isChecked: false, + }), + template: '', + methods, +}); + +export const Default = DefaultTemplate.bind({}); +Default.args = { + label: 'This is a default checkbox', + tooltipText: 'Checkbox tooltip', + disabled: false, + indeterminate: false, + size: 'small', +}; diff --git a/packages/design-system/src/components/N8nCheckbox/Checkbox.vue b/packages/design-system/src/components/N8nCheckbox/Checkbox.vue new file mode 100644 index 0000000000..88c4c31780 --- /dev/null +++ b/packages/design-system/src/components/N8nCheckbox/Checkbox.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/packages/design-system/src/components/N8nCheckbox/index.ts b/packages/design-system/src/components/N8nCheckbox/index.ts new file mode 100644 index 0000000000..a60ee7eb39 --- /dev/null +++ b/packages/design-system/src/components/N8nCheckbox/index.ts @@ -0,0 +1,3 @@ +import N8nCheckbox from './Checkbox.vue'; + +export default N8nCheckbox; diff --git a/packages/design-system/src/components/N8nFormInput/FormInput.vue b/packages/design-system/src/components/N8nFormInput/FormInput.vue index e81476f2d1..659368f09d 100644 --- a/packages/design-system/src/components/N8nFormInput/FormInput.vue +++ b/packages/design-system/src/components/N8nFormInput/FormInput.vue @@ -1,5 +1,12 @@