|
| 1 | +--- |
| 2 | +title: Filter Pill |
| 3 | +description: A Filter Pill offers a button paired with a popover to show and manage filtering options, the label and |
| 4 | + content of the filter can be handled through slots and props. |
| 5 | +status: beta |
| 6 | +# storybook: https://dialtone.dialpad.com/vue/?path=/story/components-filter-pill--default @TODO: Uncomment once it's RFP |
| 7 | +--- |
| 8 | + |
| 9 | +<code-well-header> |
| 10 | + <dt-filter-pill |
| 11 | + v-model="exampleFilters" |
| 12 | + label="With header, content and footer" |
| 13 | + > |
| 14 | + </dt-filter-pill> |
| 15 | +</code-well-header> |
| 16 | +
|
| 17 | +## Variants |
| 18 | + |
| 19 | +### Base |
| 20 | + |
| 21 | +<code-well-header> |
| 22 | + <dt-stack direction="row" gap="400"> |
| 23 | + <dt-filter-pill |
| 24 | + label="Simple example" |
| 25 | + v-model="baseFilters" |
| 26 | + ref="simpleExample" |
| 27 | + > |
| 28 | + </dt-filter-pill> |
| 29 | + </dt-stack> |
| 30 | +</code-well-header> |
| 31 | + |
| 32 | +<code-example-tabs |
| 33 | +:htmlCode='() => $refs.simpleExample' |
| 34 | +vueCode='<dt-filter-pill v-model="[...]" label="..."/>' |
| 35 | +showHtmlWarning /> |
| 36 | + |
| 37 | +### Disabled |
| 38 | + |
| 39 | +<code-well-header> |
| 40 | + <dt-stack direction="row" gap="400"> |
| 41 | + <dt-filter-pill label="Disabled filter" disabled ref="disabledFilter"></dt-filter-pill> |
| 42 | + </dt-stack> |
| 43 | +</code-well-header> |
| 44 | + |
| 45 | +<code-example-tabs |
| 46 | +:htmlCode='() => $refs.disabledFilter' |
| 47 | +vueCode='<dt-filter-pill v-model="[...]" label="..." disabled/>' |
| 48 | +showHtmlWarning /> |
| 49 | + |
| 50 | +### Active |
| 51 | + |
| 52 | +<code-well-header> |
| 53 | + <dt-stack direction="row" gap="400"> |
| 54 | + <dt-filter-pill |
| 55 | + label="Active example" |
| 56 | + v-model="activeFilters" |
| 57 | + ref="activeExample" |
| 58 | + > |
| 59 | + </dt-filter-pill> |
| 60 | + </dt-stack> |
| 61 | +</code-well-header> |
| 62 | + |
| 63 | +<code-example-tabs |
| 64 | +:htmlCode='() => $refs.activeExample' |
| 65 | +vueCode='<dt-filter-pill v-model="[...]" label="..."/>' |
| 66 | +showHtmlWarning /> |
| 67 | + |
| 68 | +### Clearable |
| 69 | + |
| 70 | +You can handle the filter resetting, the button will show whenever an active filter is passed. |
| 71 | +It will emit the `reset` event when clicked. |
| 72 | + |
| 73 | +<code-well-header> |
| 74 | + <dt-stack direction="row" gap="400"> |
| 75 | + <dt-filter-pill |
| 76 | + label="Clearable example" |
| 77 | + ref="clearableExample" |
| 78 | + v-model="clearableFilters" |
| 79 | + > |
| 80 | + </dt-filter-pill> |
| 81 | + </dt-stack> |
| 82 | +</code-well-header> |
| 83 | + |
| 84 | +<code-example-tabs |
| 85 | +:htmlCode='() => $refs.clearableExample' |
| 86 | +vueCode='<dt-filter-pill label="..." v-model="[...]" />' |
| 87 | +showHtmlWarning /> |
| 88 | + |
| 89 | +### Non Clearable |
| 90 | + |
| 91 | +Setting the `hide-clear` prop will hide the reset/clear button in case you don't want your filter be reset. |
| 92 | + |
| 93 | +<code-well-header> |
| 94 | + <dt-stack direction="row" gap="400"> |
| 95 | + <dt-filter-pill |
| 96 | + label="Non Clearable example" |
| 97 | + ref="clearableExample" |
| 98 | + v-model="nonClearableFilters" |
| 99 | + hide-clear |
| 100 | + > |
| 101 | + </dt-filter-pill> |
| 102 | + </dt-stack> |
| 103 | +</code-well-header> |
| 104 | + |
| 105 | +<code-example-tabs |
| 106 | +:htmlCode='() => $refs.clearableExample' |
| 107 | +vueCode='<dt-filter-pill label="..." v-model="[...]" hide-clear />' |
| 108 | +showHtmlWarning /> |
| 109 | + |
| 110 | +### Sizes |
| 111 | + |
| 112 | +<code-well-header> |
| 113 | + <dt-stack direction="row" gap="300"> |
| 114 | + <dt-filter-pill |
| 115 | + v-for="size in sizes" |
| 116 | + :key="size" |
| 117 | + :label="size" |
| 118 | + :size="size" |
| 119 | + ref="smExample" |
| 120 | + ></dt-filter-pill> |
| 121 | + </dt-stack> |
| 122 | +</code-well-header> |
| 123 | + |
| 124 | +<code-example-tabs |
| 125 | +:htmlCode='() => $refs.smExample[1]' |
| 126 | +vueCode='<dt-filter-pill label="..." size="sm" />' |
| 127 | +showHtmlWarning /> |
| 128 | + |
| 129 | +### With default slot |
| 130 | + |
| 131 | +Using the "default" slot, you're able to override the `label` prop |
| 132 | + |
| 133 | +<code-well-header> |
| 134 | + <dt-stack direction="row" gap="400"> |
| 135 | + <dt-filter-pill |
| 136 | + ref="clearableExample" |
| 137 | + v-model="defaultSlotFilters" |
| 138 | + > |
| 139 | + <template #default> |
| 140 | + With Default slot |
| 141 | + </template> |
| 142 | + </dt-filter-pill> |
| 143 | + </dt-stack> |
| 144 | +</code-well-header> |
| 145 | + |
| 146 | +<code-example-tabs |
| 147 | +:htmlCode='() => $refs.clearableExample' |
| 148 | +vueCode='<dt-filter-pill label="..." v-model="[...]"> |
| 149 | + <template #default> |
| 150 | + With Default slot |
| 151 | + </template> |
| 152 | +</dt-filter-pill>' |
| 153 | +showHtmlWarning /> |
| 154 | + |
| 155 | +### With content slot |
| 156 | + |
| 157 | +Using the "content" slot, you're able to override the popover content, this enables you |
| 158 | +to create custom filter pill. |
| 159 | + |
| 160 | +<code-well-header> |
| 161 | + <dt-stack direction="row" gap="400"> |
| 162 | + <dt-filter-pill |
| 163 | + label="With content slot" |
| 164 | + ref="clearableExample" |
| 165 | + v-model="contentSlotFilters" |
| 166 | + > |
| 167 | + <template #content> |
| 168 | + Content slot example |
| 169 | + </template> |
| 170 | + </dt-filter-pill> |
| 171 | + </dt-stack> |
| 172 | +</code-well-header> |
| 173 | + |
| 174 | +<code-example-tabs |
| 175 | +:htmlCode='() => $refs.clearableExample' |
| 176 | +vueCode='<dt-filter-pill label="..." v-model="[...]"> |
| 177 | + <template #content> |
| 178 | + Content slot example |
| 179 | + </template> |
| 180 | +</dt-filter-pill>' |
| 181 | +showHtmlWarning /> |
| 182 | + |
| 183 | +## Vue API |
| 184 | + |
| 185 | +<component-vue-api component-name="filterPill"></component-vue-api> |
| 186 | + |
| 187 | +## Classes |
| 188 | + |
| 189 | +<component-class-table component-name="filter-pill"></component-class-table> |
| 190 | + |
| 191 | +<script setup> |
| 192 | +import { ref } from 'vue'; |
| 193 | +import { DtIconSearch, DtIconClose } from '@dialpad/dialtone-icons/vue3'; |
| 194 | + |
| 195 | +const inputValue = ref(''); |
| 196 | +const exampleFilters = ref([ |
| 197 | + {name: 'Option 1'}, |
| 198 | + {name: 'Option 2'}, |
| 199 | +]); |
| 200 | +const baseFilters = ref([ |
| 201 | + {name: 'Option 1'}, |
| 202 | + {name: 'Option 2'}, |
| 203 | + {name: 'Option 3'}, |
| 204 | +]); |
| 205 | +const activeFilters = ref([ |
| 206 | + {name: 'Option 1'}, |
| 207 | + {name: 'Option 2'}, |
| 208 | + {name: 'Option 3', active: true} |
| 209 | +]); |
| 210 | +const clearableFilters = ref([ |
| 211 | + {name: 'Option 1'}, |
| 212 | + {name: 'Option 2', active: true}, |
| 213 | + {name: 'Option 3'} |
| 214 | +]); |
| 215 | +const nonClearableFilters = ref([ |
| 216 | + {name: 'Option 1', active: true}, |
| 217 | + {name: 'Option 2'}, |
| 218 | + {name: 'Option 3'} |
| 219 | +]); |
| 220 | +const defaultSlotFilters = ref([ |
| 221 | + {name: 'Option 1'}, |
| 222 | + {name: 'Option 2'}, |
| 223 | +]); |
| 224 | +const contentSlotFilters = ref([ |
| 225 | + {name: 'Option 1'}, |
| 226 | + {name: 'Option 2'}, |
| 227 | +]); |
| 228 | +const sizes = Object.keys(window.DIALTONE_CONSTANTS.BUTTON_SIZE_MODIFIERS); |
| 229 | +const sizeNames = { |
| 230 | + xs: 'Extra small', |
| 231 | + sm: 'Small', |
| 232 | + md: 'Medium', |
| 233 | + lg: 'Large', |
| 234 | + xl: 'Extra Large', |
| 235 | +}; |
| 236 | +</script> |
0 commit comments