diff --git a/.eslintrc.js b/.eslintrc.js index 6e93d4a..bfe268c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,5 +20,6 @@ module.exports = { 'comma-dangle': ['error', 'always-multiline'], 'no-multiple-empty-lines': 'error', 'object-curly-spacing': ['error', 'always'], + 'vue/no-v-model-argument': 'off', }, } diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 649fdf6..8cf9f9f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -65,6 +65,7 @@ function getComponents() { function getFormComponents() { return [ { text: 'Input', link: 'components/input' }, + { text: 'Select', link: 'components/select' }, ] } diff --git a/docs/components/select.md b/docs/components/select.md new file mode 100644 index 0000000..c3d3059 --- /dev/null +++ b/docs/components/select.md @@ -0,0 +1,76 @@ + + +# Vue Select Components - Flowbite + +#### Get started with the select component to allow the user to choose from one or more options from a dropdown list based on multiple styles, sizes, and variants + +--- + +:::tip +Original reference: [https://flowbite.com/docs/forms/select/](https://flowbite.com/docs/forms/select/) +::: + +The select input component can be used to gather information from users based on multiple options in the form of a dropdown list and by browsing this page you will find multiple options, styles, sizes, and variants built with the utility classes from Tailwind CSS also available in dark mode. + +## Default +```vue + + +``` + + + +## Disabled + +```vue + +``` + + + +## Underlined + +```vue + +``` + + + +## Size + +```vue + +``` + + \ No newline at end of file diff --git a/docs/components/select/examples/DisabledSelect.vue b/docs/components/select/examples/DisabledSelect.vue new file mode 100644 index 0000000..e6b4508 --- /dev/null +++ b/docs/components/select/examples/DisabledSelect.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/docs/components/select/examples/SelectExample.vue b/docs/components/select/examples/SelectExample.vue new file mode 100644 index 0000000..d1f84fd --- /dev/null +++ b/docs/components/select/examples/SelectExample.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/docs/components/select/examples/SelectSize.vue b/docs/components/select/examples/SelectSize.vue new file mode 100644 index 0000000..5583775 --- /dev/null +++ b/docs/components/select/examples/SelectSize.vue @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/docs/components/select/examples/UnderlinedSelect.vue b/docs/components/select/examples/UnderlinedSelect.vue new file mode 100644 index 0000000..809ac8b --- /dev/null +++ b/docs/components/select/examples/UnderlinedSelect.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/src/components/Select/Select.vue b/src/components/Select/Select.vue new file mode 100644 index 0000000..e145ce8 --- /dev/null +++ b/src/components/Select/Select.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/components/Select/composables/useSelectClasses.ts b/src/components/Select/composables/useSelectClasses.ts new file mode 100644 index 0000000..3b1d710 --- /dev/null +++ b/src/components/Select/composables/useSelectClasses.ts @@ -0,0 +1,43 @@ +import type { Ref } from 'vue' +import { computed } from 'vue' +import { simplifyTailwindClasses } from '@/utils/simplifyTailwindClasses' +import type { InputSize } from '@/components/Input/types' + +// LABEL +const defaultLabelClasses = 'block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300' + +// SELECT +const defaultSelectClasses = 'w-full text-gray-900 bg-gray-50 border-[1px] border-gray-300 rounded-lg focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500' +const disabledSelectClasses = 'cursor-not-allowed bg-gray-100' +const underlineSelectClasses = 'bg-transparent dark:bg-transparent border-0 border-b-2 border-gray-200 appearance-none dark:border-gray-700 focus:outline-none focus:ring-0 focus:border-gray-200 peer rounded-none' +const selectSizeClasses: Record = { + lg: 'p-4', + md: 'p-2.5 text-sm', + sm: 'p-2 text-sm', +} + +export type UseSelectClassesProps = { + size: Ref + disabled: Ref + underline: Ref +} + +export function useSelectClasses(props: UseSelectClassesProps) { + const selectClasses = computed(() => { + return simplifyTailwindClasses(defaultSelectClasses, selectSizeClasses[props.size.value], props.disabled.value ? disabledSelectClasses : '') + }) + + const underlineClasses = computed(() => { + return underlineSelectClasses + }) + + const labelClasses = computed(() => { + return defaultLabelClasses + }) + + return { + selectClasses, + underlineClasses, + labelClasses, + } +} \ No newline at end of file diff --git a/src/components/Select/types.ts b/src/components/Select/types.ts new file mode 100644 index 0000000..b879850 --- /dev/null +++ b/src/components/Select/types.ts @@ -0,0 +1,4 @@ +export type OptionsType = { + value: string, + name: string, +} diff --git a/src/index.ts b/src/index.ts index 1a34345..a1b73bd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,4 +52,6 @@ export { default as Input } from './components/Input/Input.vue' export { default as SlotListener } from './components/utils/SlotListener/SlotListener.vue' +export { default as Select } from './components/Select/Select.vue' + export * from './composables'