From 337373ff7523dce56a50f6e0e335f902cabbed9c Mon Sep 17 00:00:00 2001 From: upsiflu Date: Mon, 3 Feb 2025 23:09:32 +0100 Subject: [PATCH] refactor(ui): add Slider component --- front/src/components/ui/Slider.vue | 107 ++++++++++++++++++++++++++ front/ui-docs/.vitepress/config.ts | 1 + front/ui-docs/components/ui/slider.md | 59 ++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 front/src/components/ui/Slider.vue create mode 100644 front/ui-docs/components/ui/slider.md diff --git a/front/src/components/ui/Slider.vue b/front/src/components/ui/Slider.vue new file mode 100644 index 000000000..b58cec20d --- /dev/null +++ b/front/src/components/ui/Slider.vue @@ -0,0 +1,107 @@ + + + + + + diff --git a/front/ui-docs/.vitepress/config.ts b/front/ui-docs/.vitepress/config.ts index f2338f080..0f3707bc7 100644 --- a/front/ui-docs/.vitepress/config.ts +++ b/front/ui-docs/.vitepress/config.ts @@ -42,6 +42,7 @@ export default defineConfig({ ], }, { text: 'Input', link: '/components/ui/input' }, + { text: 'Slider', link: '/components/ui/slider' }, { text: 'Popover (Dropdown Menu)', link: '/components/ui/popover' }, { text: 'Textarea', link: '/components/ui/textarea' }, { text: 'Toggle', link: '/components/ui/toggle' }, diff --git a/front/ui-docs/components/ui/slider.md b/front/ui-docs/components/ui/slider.md new file mode 100644 index 000000000..c2ba5cb39 --- /dev/null +++ b/front/ui-docs/components/ui/slider.md @@ -0,0 +1,59 @@ + + +```ts +import Slider from "~/components/ui/Slider.vue"; +``` + +# Slider + +Let a user select a value along a gradient. + +The model (required) is the current value. + +```ts +const options = { + me: "Only I can find and edit this", + pod: "Me and other users on the instance can find and edit this", + everyone: "Everyone can find and edit this", +} as const; + +const option = ref("me"); +``` + +```vue-html + +``` + + + +Functionality: + +- Define a list of `[value:string, description:markdown]` pairs (props) +- Select one value as active (model) + +User interaction: + +- It mimics the functionality of a single `range` input: + - to be operated with arrow keys or mouse + - focus is indicated + - ticks are indicated + +Design: + +- A pin (same as in the toggle component) +- a range (very faint) +- Ticks + +- Not to be confused with a pearls navigation patterns (list of dots; indicates temporal range)