From 7d86f391567f756c1912bae50dbd6ab44c22321f Mon Sep 17 00:00:00 2001 From: Tom Smith Date: Wed, 14 Jun 2023 13:05:16 +0100 Subject: [PATCH] fixes #175 proof of concept for Slider component from daisyUI --- .gitignore | 1 + .../content/examples/SliderExample.vue | 7 + docs/content/3.forms/9.slider.md | 83 ++++++ src/colors.ts | 1 + src/runtime/app.config.ts | 10 + src/runtime/components/forms/Slider.vue | 244 ++++++++++++++++++ 6 files changed, 346 insertions(+) create mode 100644 docs/components/content/examples/SliderExample.vue create mode 100644 docs/content/3.forms/9.slider.md create mode 100644 src/runtime/components/forms/Slider.vue diff --git a/.gitignore b/.gitignore index 544a23abb1..df00b3321e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist .DS_Store .history .vercel +.idea diff --git a/docs/components/content/examples/SliderExample.vue b/docs/components/content/examples/SliderExample.vue new file mode 100644 index 0000000000..8fe05d3cf3 --- /dev/null +++ b/docs/components/content/examples/SliderExample.vue @@ -0,0 +1,7 @@ + + + diff --git a/docs/content/3.forms/9.slider.md b/docs/content/3.forms/9.slider.md new file mode 100644 index 0000000000..24c2304b61 --- /dev/null +++ b/docs/content/3.forms/9.slider.md @@ -0,0 +1,83 @@ +--- +github: true +description: Display a slider field +navigation: + badge: "Edge" +--- + +## Usage + +Use a `v-model` to make the Input reactive. + +::component-example +#default +:slider-example + +#code + +```vue + + + +``` + +:: + +### Style + +Use the `color` prop to change the visual style of the Slider. + +## ::component-card + +baseProps: +name: 'slider' +placeholder: 'Search...' +props: +color: 'lime' + +--- + +:: + +### Size + +Use the `size` prop to change the size of the Input. + +## ::component-card + +baseProps: +name: 'slider' +props: +size: 'sm' + +--- + +:: + +### Disabled + +Use the `disabled` prop to disable the Input. + +## ::component-card + +baseProps: +name: 'input' +placeholder: 'Search...' +props: +disabled: true + +--- + +:: + +## Props + +:component-props + +## Preset + +:component-preset diff --git a/src/colors.ts b/src/colors.ts index ae4c030ecd..9fe7be102f 100644 --- a/src/colors.ts +++ b/src/colors.ts @@ -120,6 +120,7 @@ export const generateSafelist = (colors: string[]) => { return [ ...safelist, + ...colors.map(color => `[&::-webkit-slider-thumb]:shadow-${color}-500`), // Gray safelist for Avatar & Notification 'bg-gray-500', 'dark:bg-gray-400', diff --git a/src/runtime/app.config.ts b/src/runtime/app.config.ts index 506633425e..e6450f864e 100644 --- a/src/runtime/app.config.ts +++ b/src/runtime/app.config.ts @@ -510,6 +510,15 @@ const toggle = { } } +const slider = { + base: 'h-6 w-full cursor-pointer bg-transparent rounded-full overflow-hidden', + thumb : '[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:top-[50%] [&::-webkit-slider-thumb]:shadow-range [&::-webkit-slider-thumb]:inset-box-shadow [&::-webkit-slider-thumb]:relative [&::-webkit-slider-thumb]:h-6 [&::-webkit-slider-thumb]:w-6 [&::-webkit-slider-thumb]:border-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:shadow-{color}-500 [&::-webkit-slider-thumb]:-translate-y-1/2', + default: { + size: 'sm', + color: 'primary', + } +} + // Layout const card = { @@ -864,6 +873,7 @@ export default { dropdown, kbd, input, + slider, formGroup, textarea, select, diff --git a/src/runtime/components/forms/Slider.vue b/src/runtime/components/forms/Slider.vue new file mode 100644 index 0000000000..aceae8f350 --- /dev/null +++ b/src/runtime/components/forms/Slider.vue @@ -0,0 +1,244 @@ + + + + +