-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(editor): Create N8nCheckbox Vue component (#3678)
* ✨ 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
- Loading branch information
1 parent
6f95121
commit a847190
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/design-system/src/components/N8nCheckbox/Checkbox.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: '<n8n-checkbox v-model="isChecked" v-bind="$props" @input="onInput"></n8n-checkbox>', | ||
methods, | ||
}); | ||
|
||
export const Default = DefaultTemplate.bind({}); | ||
Default.args = { | ||
label: 'This is a default checkbox', | ||
tooltipText: 'Checkbox tooltip', | ||
disabled: false, | ||
indeterminate: false, | ||
size: 'small', | ||
}; |
66 changes: 66 additions & 0 deletions
66
packages/design-system/src/components/N8nCheckbox/Checkbox.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<el-checkbox | ||
v-bind="$props" | ||
:disabled="disabled" | ||
:indeterminate="indeterminate" | ||
:value="value" | ||
@change="onChange" | ||
> | ||
<n8n-input-label | ||
:label="label" | ||
:tooltipText="tooltipText" | ||
:bold="false" | ||
:size="labelSize" | ||
></n8n-input-label> | ||
</el-checkbox> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import ElCheckbox from 'element-ui/lib/checkbox'; | ||
import N8nInputLabel from '../N8nInputLabel'; | ||
export default Vue.extend({ | ||
name: 'n8n-checkbox', | ||
components: { | ||
ElCheckbox, | ||
N8nInputLabel, | ||
}, | ||
props: { | ||
label: { | ||
type: String, | ||
required: true, | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
tooltipText: { | ||
type: String, | ||
required: false, | ||
}, | ||
indeterminate: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
value: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
labelSize: { | ||
type: String, | ||
default: 'medium', | ||
validator: (value: string): boolean => | ||
['small', 'medium'].includes(value), | ||
}, | ||
}, | ||
methods: { | ||
onChange(e) { | ||
this.$emit("input", e); | ||
}, | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import N8nCheckbox from './Checkbox.vue'; | ||
|
||
export default N8nCheckbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters