From 3ffa7840273e4b6b1b3adc966e29ea71d75f3f59 Mon Sep 17 00:00:00 2001 From: upsiflu Date: Sun, 9 Mar 2025 13:13:44 +0100 Subject: [PATCH] feat(ui): users can change pill content with presets and custom labels --- front/src/components/ui/Pill.vue | 498 ++++++++++++++++++++++++---- front/src/components/ui/pill.scss | 72 ---- front/ui-docs/components/ui/pill.md | 76 +++-- 3 files changed, 485 insertions(+), 161 deletions(-) delete mode 100644 front/src/components/ui/pill.scss diff --git a/front/src/components/ui/Pill.vue b/front/src/components/ui/Pill.vue index ee30858f9..9bf4ad51b 100644 --- a/front/src/components/ui/Pill.vue +++ b/front/src/components/ui/Pill.vue @@ -1,86 +1,448 @@ - diff --git a/front/src/components/ui/pill.scss b/front/src/components/ui/pill.scss deleted file mode 100644 index 423da442c..000000000 --- a/front/src/components/ui/pill.scss +++ /dev/null @@ -1,72 +0,0 @@ -.funkwhale { - &.pill { - color: var(--fw-text-color); - - // @include dark-theme { - // --fw-darken-pastel: color-mix(in srgb, var(--fw-pastel-4) 90%, black); - // background-color: var(--fw-darken-pastel, var(--fw-bg-color)); - // } - - position: relative; - display: inline-flex; - - font-family: $font-main; - - line-height: 1em; - font-size: small; - - border-radius: 100vh; - - > .pill-content { - padding: 0.45em 0.75em 0.55em 0.75em; - white-space: nowrap; - min-width: 28px; - border-radius: inherit; - &:focus-visible, &:focus { - outline: 1px solid var(--focus-ring-color); - outline-offset: 2px; - } - } - - > .pill-image { - position: relative; - aspect-ratio: 1; - border-radius: 50%; - overflow: hidden; - height: calc(2em - 4px); - margin: 2px; - align-content: center; - - + .pill-content { - padding-left: 0.25em; - } - - > * { - height: 100%; - width: 100%; - } - - > i.bi { - font-size: 18px; - } - - > img { - object-fit: cover; - } - } - - &:hover:not(.no-underline) { - text-decoration: underline; - } - - &[disabled] { - font-weight: normal; - cursor: default; - } - - &.is-focused, - &:focus { - box-shadow: none !important; - } - } -} diff --git a/front/ui-docs/components/ui/pill.md b/front/ui-docs/components/ui/pill.md index c7fbb2d2a..b2b0f8d94 100644 --- a/front/ui-docs/components/ui/pill.md +++ b/front/ui-docs/components/ui/pill.md @@ -4,8 +4,14 @@ import { computed, ref } from 'vue' import Pill from '~/components/ui/Pill.vue' import Button from '~/components/ui/Button.vue' -const customTag=ref('Custom Tag') -const isDeleted = computed(() => customTag.value==='' ? 'Pill was deleted' : '') +const customTag = ref({ + current: { type: 'custom', label: 'I-am-custom.-Change-me!' }, + others: [ + { type: 'preset', label: 'Preset-1' }, + { type: 'preset', label: 'Preset-2' }, + { type: 'preset', label: 'Preset-3' }, + ] +}) ```ts @@ -141,7 +147,7 @@ Image pills contain a small circular image on their left. These can be used for ```vue-html{2-4} Awesome artist @@ -149,43 +155,71 @@ Image pills contain a small circular image on their left. These can be used for Awesome artist ## Editable pill -Add `v-model="..."` to link the pill content to a `ref`. +Add `v-model="..."` to link the pill content to a `ref` with one `current` item and zero or more `others`. Set each item's `type` to `preset` or `custom`. + +- The `current` item can be changed by the user. +- The `other` items can be selected instead of the `current`. +- Items with type `custom` can be edited and deleted by the user. `preset` items can only be selected or deselected. ```ts import { ref } from "vue" -const customTag = ref("Custom Tag") +const customTag = ref({ + current: { type: 'custom', label: 'I-am-custom.-Change-me!' }, + others: [ + { type: 'preset', label: 'Preset-1' }, + { type: 'preset', label: 'Preset-2' }, + { type: 'preset', label: 'Preset-3' }, + ] +}) ``` ```vue-html - - - ``` -Edit the text, then hit Enter or click outside. The button will show the updated text. +## Add an action + + + + + + +{{ customTag }}