From c3e88262533b4711b2a0395a96f2ae4a26d8f0b5 Mon Sep 17 00:00:00 2001 From: Vasu Singh Date: Fri, 16 Jun 2023 18:50:45 +0530 Subject: [PATCH] feat(component): New checkbox component (#151) * feat(component): New component checkbox * feat(component): checkbox docs and link checkbox * added gradient to home page * remove unused props * code refactor * code refactor * fix type error * convert div to label --- docs/.vitepress/config.ts | 2 +- docs/.vitepress/theme/clear.css | 8 ++- docs/assets/logo.svg | 2 +- docs/components/checkbox.md | 69 +++++++++++++++++++ .../checkbox/examples/CheckboxChecked.vue | 12 ++++ .../checkbox/examples/CheckboxDefault.vue | 12 ++++ .../checkbox/examples/CheckboxDisabled.vue | 12 ++++ .../checkbox/examples/CheckboxLink.vue | 14 ++++ docs/index.md | 3 + src/components/Checkbox/Checkbox.vue | 35 ++++++++++ .../composables/useCheckboxClasses.ts | 23 +++++++ 11 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 docs/components/checkbox.md create mode 100644 docs/components/checkbox/examples/CheckboxChecked.vue create mode 100644 docs/components/checkbox/examples/CheckboxDefault.vue create mode 100644 docs/components/checkbox/examples/CheckboxDisabled.vue create mode 100644 docs/components/checkbox/examples/CheckboxLink.vue create mode 100644 src/components/Checkbox/Checkbox.vue create mode 100644 src/components/Checkbox/composables/useCheckboxClasses.ts diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 8cf9f9f..b1e6b95 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -65,7 +65,7 @@ function getComponents() { function getFormComponents() { return [ { text: 'Input', link: 'components/input' }, - { text: 'Select', link: 'components/select' }, + { text: 'Checkbox', link: 'components/checkbox' }, ] } diff --git a/docs/.vitepress/theme/clear.css b/docs/.vitepress/theme/clear.css index 0653c2f..2da8c79 100644 --- a/docs/.vitepress/theme/clear.css +++ b/docs/.vitepress/theme/clear.css @@ -3,5 +3,11 @@ input, optgroup, select, textarea { - border: inherit; /* border: 0 by default in vitepress removes all border for border class */ + border: inherit; + /* border: 0 by default in vitepress removes all border for border class */ +} + +:root { + --vp-home-hero-image-background-image: linear-gradient( -45deg, #41b88380 30%, #35495e80 ); + --vp-home-hero-image-filter: blur(72px); } \ No newline at end of file diff --git a/docs/assets/logo.svg b/docs/assets/logo.svg index 1a29055..cdf70d9 100644 --- a/docs/assets/logo.svg +++ b/docs/assets/logo.svg @@ -1,4 +1,4 @@ - + diff --git a/docs/components/checkbox.md b/docs/components/checkbox.md new file mode 100644 index 0000000..a57e2e1 --- /dev/null +++ b/docs/components/checkbox.md @@ -0,0 +1,69 @@ + +# Vue Footer Component - Flowbite + +## Default checkbox + +```vue + + +``` + + + +## Disabled checkbox + +```vue + + +``` + + + +## Checked checkbox + +```vue + + +``` + + + +## Link with checkbox + +```vue +
+ + I agree with the terms and conditions. + +
+ +``` + + diff --git a/docs/components/checkbox/examples/CheckboxChecked.vue b/docs/components/checkbox/examples/CheckboxChecked.vue new file mode 100644 index 0000000..ea28e5b --- /dev/null +++ b/docs/components/checkbox/examples/CheckboxChecked.vue @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/docs/components/checkbox/examples/CheckboxDefault.vue b/docs/components/checkbox/examples/CheckboxDefault.vue new file mode 100644 index 0000000..cf15cd9 --- /dev/null +++ b/docs/components/checkbox/examples/CheckboxDefault.vue @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/docs/components/checkbox/examples/CheckboxDisabled.vue b/docs/components/checkbox/examples/CheckboxDisabled.vue new file mode 100644 index 0000000..906e285 --- /dev/null +++ b/docs/components/checkbox/examples/CheckboxDisabled.vue @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/docs/components/checkbox/examples/CheckboxLink.vue b/docs/components/checkbox/examples/CheckboxLink.vue new file mode 100644 index 0000000..065f405 --- /dev/null +++ b/docs/components/checkbox/examples/CheckboxLink.vue @@ -0,0 +1,14 @@ + + + \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index c70f0ee..4c0c540 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,6 +8,9 @@ hero: name: Flowbite Vue 3 text: Vue component library based on Tailwind CSS tagline: Get started with the most popular open-source library of interactive UI components built with the utility classes from Tailwind CSS + image: + src: /assets/logo.svg + alt: VitePress actions: - theme: brand text: Get Started diff --git a/src/components/Checkbox/Checkbox.vue b/src/components/Checkbox/Checkbox.vue new file mode 100644 index 0000000..b7785e1 --- /dev/null +++ b/src/components/Checkbox/Checkbox.vue @@ -0,0 +1,35 @@ + + + \ No newline at end of file diff --git a/src/components/Checkbox/composables/useCheckboxClasses.ts b/src/components/Checkbox/composables/useCheckboxClasses.ts new file mode 100644 index 0000000..bd4e7d5 --- /dev/null +++ b/src/components/Checkbox/composables/useCheckboxClasses.ts @@ -0,0 +1,23 @@ +import { computed } from 'vue' +import { simplifyTailwindClasses } from '@/utils/simplifyTailwindClasses' + +// LABEL +const defaultLabelClasses = 'block text-sm font-medium text-gray-900 dark:text-gray-300' + +// CHECKBOX +const defaultCheckboxClasses = 'w-4 h-4 rounded bg-gray-100 border-gray-300 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-600 dark:border-gray-500' + +export function useCheckboxClasses() { + const checkboxClasses = computed(() => { + return simplifyTailwindClasses(defaultCheckboxClasses) + }) + + const labelClasses = computed(() => { + return defaultLabelClasses + }) + + return { + checkboxClasses, + labelClasses, + } +} \ No newline at end of file