diff --git a/front/src/components/ui/Pill.vue b/front/src/components/ui/Pill.vue index 8c1b4448c..91671a423 100644 --- a/front/src/components/ui/Pill.vue +++ b/front/src/components/ui/Pill.vue @@ -8,24 +8,34 @@ const handleClick = (event: MouseEvent) => { emit('click', event) } const props = defineProps<{ noUnderline?:true } & (PastelProps | ColorProps) & VariantProps & RaisedProps>() +const model = defineModel() diff --git a/front/src/components/ui/Pills.vue b/front/src/components/ui/Pills.vue index bc0480eb9..442cf216d 100644 --- a/front/src/components/ui/Pills.vue +++ b/front/src/components/ui/Pills.vue @@ -1,5 +1,5 @@ @@ -67,23 +76,8 @@ const deselectPill = (value:string) => v-bind="color({}, ['solid', 'default', 'secondary'])()" :class="$style.list" > - - {{ value }} - - - {{ value }}   × - - + + + + + + {{ value }} + + + + + + + + + + @@ -110,6 +143,8 @@ const deselectPill = (value:string) => font-weight: 600; } >.list { + position: relative; + padding:4px; border-radius: 24px; @@ -124,9 +159,11 @@ const deselectPill = (value:string) => padding: 2px; } >.dropdown{ + position: absolute; + inset: 0; + border-radius: 15px; padding: 2px 11.25px; - flex-grow: 1; text-align: right; background: transparent; appearance: auto; @@ -137,10 +174,10 @@ const deselectPill = (value:string) => color: inherit; } } - &:hover>.list { + &:hover:has(select)>.list { box-shadow: inset 0 0 0 4px var(--border-color) } - :has(>.dropdown:focus) { + :has(>select:focus) { box-shadow: inset 0 0 0 4px var(--focus-ring-color) } } diff --git a/front/ui-docs/components/ui/pill.md b/front/ui-docs/components/ui/pill.md index e92e497f7..8d9dfefbc 100644 --- a/front/ui-docs/components/ui/pill.md +++ b/front/ui-docs/components/ui/pill.md @@ -1,16 +1,22 @@ ```ts -import Pill from "~/components/ui/Pill.vue" +import Pill from "~/components/ui/Pill.vue"; ``` # Pill Pills are decorative elements that display information about content they attach to. They can be links to other content or simple colored labels. -You can add text to pills by adding it between the `` tags. +You can add text to pills by adding it between the `` tags. Alternatively, you can set `v-model` and [make the pill editable](#editable-pill). | Prop | Data type | Required? | Default | Description | | ------- | ----------------------------------------------------------------------------------------------- | --------- | ----------- | ---------------------- | @@ -128,14 +134,14 @@ Funkwhale pills support a range of pastel colors to create visually appealing in Yellow pill -## Image pills +## Image pill Image pills contain a small circular image on their left. These can be used for decorative links such as artist links. To created an image pill, insert a link to the image between the pill tags as a ` Awesome artist + +## Editable pill + +Add `v-model="..."` to link the pill content to a `ref`. Note that the pill is not rendered if v-model is ''. + +```ts +import { computed, ref } from "vue"; +const customTag = ref(" "); +const isDeleted = computed(() => customTag.value === ""); +``` + +```vue-html + + + +``` + + + + + + diff --git a/front/ui-docs/components/ui/pills.md b/front/ui-docs/components/ui/pills.md index ddedc28a0..380dec6e5 100644 --- a/front/ui-docs/components/ui/pills.md +++ b/front/ui-docs/components/ui/pills.md @@ -7,25 +7,63 @@ import Input from '~/components/ui/Input.vue'; const nullModel = ref({ current: [], - others: [] }); const staticModel = ref({ - current: ["#Noise", "#FieldRecording", "#Experiment"] + current: ["#Noise", "#FieldRecording", "#Experiment"], }); const interactiveModel = ref({ current: ["#Noise", "#FieldRecording", "#Experiment"], - others: ["#Melody", "#Rhythm"] + others: ["#Melody", "#Rhythm"], +}); + +const customModel = ref({ + current: ["#Noise", "#FieldRecording", "#Experiment"], + others: ["#Melody", "#Rhythm"], + custom: ["#Noise"], }); ```ts -import Pills from "~/components/ui/Pills.vue" +import Pills from "~/components/ui/Pills.vue"; ``` # Pills +Show a dense list of pills representing tags, categories or options. +Users can select a subset of given options and create new ones. + +The model you provide will be mutated by this component: + +- `current`: these pills are currently selected +- `others`: these pills are currently not selected (but can be selected by the user). This prop is optional. By adding it, you allow users to change the selection. +- `custom`: these pills were created by the user. This prop is optional. Users can edit, add and remove any pill defined in this array. Note that the `custom` array should only contain pills that are either in `current` or in `others`. + +## No pills + +```ts +const nullModel = ref({ + current: [], +}); +``` + +```vue-html + +``` + + + + + +## Predefined list of pills + +```ts +const staticModel = ref({ + current: ["#Noise", "#FieldRecording", "#Experiment"], +}); +``` + ```vue-html ``` @@ -34,24 +72,39 @@ import Pills from "~/components/ui/Pills.vue" +## Let users select and unselect pills + Select a set of pills from presets, and add and remove custom ones +```ts +const interactiveModel = ref({ + current: ["#Noise", "#FieldRecording", "#Experiment"], + others: ["#Melody", "#Rhythm"], +}); +``` + ```vue-html - ``` - -## No pills +## Let users add, remove and edit custom pills + +```ts +const customModel = ref({ + current: ["#Noise", "#FieldRecording", "#Experiment"], + others: ["#Melody", "#Rhythm"], + custom: ["#Noise"], +}); +``` ```vue-html - + ``` - +