PILLS {{ pills.map(({ current })=>current.label) }}
+
MODEL {{ model.currents.map(({ label })=>label) }}
-
-
-
-
-
-
-
- {{ value }}
-
-
-
-
-
-
-
-
-
+ :class="[$style.pill, $style[isStatic ? 'static' : pill.current.label === '' ? 'empty' : pill.current.type === 'custom' ? 'custom' : 'preset']]"
+ @changed="() => { console.log('CCCCCC', index); changed(index, pill) }"
+ >
+ {{ pill.current.label }}
+ {{ `${index} ${componentKey}` }}
+
@@ -233,47 +139,14 @@ watch(model, () => {
// Compensation for round shapes -> https://en.wikipedia.org/wiki/Overshoot_(typography)
margin: 0 -4px;
- padding:4px;
+ // padding: 4px;
border-radius: 22px;
- min-height: 48px;
- min-width: 160px;
+ gap: 8px;
+ padding: 2px;
- gap: 4px;
-
- > .pill {
- padding: 2px;
- &.static {
- text-decoration: none;
- }
- &.preset {
- &:is(:hover, :focus-visible) .pill-content {
- text-decoration: line-through;
- }
- .pill-content::after{
- content:'×';
- margin-left: 8px;
- }
- }
- &.custom {
- text-decoration: none;
- }
-
- }
- >.dropdown{
- position: absolute;
- inset: 0;
-
- border-radius: 15px;
- padding: 2px 11.25px;
- text-align: right;
- background: transparent;
- appearance: auto;
- margin-right: 12px;
-
- // From vitepress default, needed for app
- border: 0;
- color: inherit;
+ .empty {
+ flex-grow: 1;
}
}
&:hover:has(select)>.list {
diff --git a/front/ui-docs/components/ui/pills.md b/front/ui-docs/components/ui/pills.md
index 63cd8ce89..d6966545b 100644
--- a/front/ui-docs/components/ui/pills.md
+++ b/front/ui-docs/components/ui/pills.md
@@ -1,38 +1,41 @@
-
```ts
@@ -46,133 +49,66 @@ 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`.
+- `currents`: these items are currently selected
+- `others`: these items 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.
-::: warning
+Each item has a `label` of type `string` as well as a `type` of either:
-If you place custom pills into `others`, the user will be able to select, edit and delete them but not to deselect them. If there is a use case for this, we have to design a good UX for deselecting custom pills.
-
-:::
-
-## Test
-
-
+- `custom`: the user can edit its label or
+- `preset`: the user cannot edit its label
## No pills
```ts
const nullModel = ref({
- current: []
-});
+ currents: []
+}) as { currents: Item[] };
```
```vue-html
```
-
-
-
+
## Predefined list of pills
```ts
const staticModel = ref({
- current: ["#Noise", "#FieldRecording", "#Experiment"]
+ currents: [
+ { label: "#Noise", type: 'preset' },
+ { label: "#FieldRecording", type: 'preset' },
+ { label: "#Experiment", type: 'preset' }
+ ]
});
```
```vue-html
-
+
```
-
-
-
+
## 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"]
+ ...staticModel,
+ others: [
+ { label: "#Melody", type: 'preset' },
+ { label: "#Rhythm", type: 'preset' }
+ ]
});
```
```vue-html
-
+
```
-
-
-
+
## Let users add, remove and edit custom pills
@@ -180,48 +116,16 @@ Use [reactive](https://vuejs.org/guide/essentials/reactivity-fundamentals.html#r
```ts
const customModel = ref({
- current: ["custom", "#FieldRecording", "#Experiment"],
- others: ["#Melody", "#Rhythm"],
- custom: ["custom"]
+ ...staticModel,
+ others: [
+ { label: "#MyTag1", type: 'custom' },
+ { label: "#MyTag2", type: 'custom' }
+ ]
});
```
```vue-html
-
+
```
-
-
-
-
-## Combine Pills with other input fields
-
-
-
-
-
-
- Ordering
-
-
-
-
+