-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(InputMenu): new component (#1095)
- Loading branch information
1 parent
66a80c7
commit 6d8d82a
Showing
20 changed files
with
852 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup> | ||
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer'] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" /> | ||
</template> |
13 changes: 13 additions & 0 deletions
13
docs/components/content/examples/InputMenuExampleEmptySlot.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup> | ||
const people = [] | ||
const selected = ref() | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people"> | ||
<template #empty> | ||
No people | ||
</template> | ||
</UInputMenu> | ||
</template> |
36 changes: 36 additions & 0 deletions
36
docs/components/content/examples/InputMenuExampleObjects.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup> | ||
const people = [{ | ||
id: 'benjamincanac', | ||
label: 'benjamincanac', | ||
href: 'https://github.com/benjamincanac', | ||
target: '_blank', | ||
avatar: { src: 'https://avatars.githubusercontent.com/u/739984?v=4' } | ||
}, { | ||
id: 'Atinux', | ||
label: 'Atinux', | ||
href: 'https://github.com/Atinux', | ||
target: '_blank', | ||
avatar: { src: 'https://avatars.githubusercontent.com/u/904724?v=4' } | ||
}, { | ||
id: 'smarroufin', | ||
label: 'smarroufin', | ||
href: 'https://github.com/smarroufin', | ||
target: '_blank', | ||
avatar: { src: 'https://avatars.githubusercontent.com/u/7547335?v=4' } | ||
}, { | ||
id: 'nobody', | ||
label: 'Nobody', | ||
icon: 'i-heroicons-user-circle' | ||
}] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people"> | ||
<template #leading> | ||
<UIcon v-if="selected.icon" :name="selected.icon" class="w-4 h-4 mx-0.5" /> | ||
<UAvatar v-else-if="selected.avatar" v-bind="selected.avatar" size="3xs" class="mx-0.5" /> | ||
</template> | ||
</UInputMenu> | ||
</template> |
26 changes: 26 additions & 0 deletions
26
docs/components/content/examples/InputMenuExampleObjectsValueAttribute.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script setup> | ||
const people = [{ | ||
id: 1, | ||
name: 'Wade Cooper' | ||
}, { | ||
id: 2, | ||
name: 'Arlene Mccoy' | ||
}, { | ||
id: 3, | ||
name: 'Devon Webb' | ||
}, { | ||
id: 4, | ||
name: 'Tom Cook' | ||
}] | ||
const selected = ref(people[0].name) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu | ||
v-model="selected" | ||
:options="people" | ||
value-attribute="name" | ||
option-attribute="name" | ||
/> | ||
</template> |
13 changes: 13 additions & 0 deletions
13
docs/components/content/examples/InputMenuExampleOptionEmptySlot.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup> | ||
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer'] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" searchable> | ||
<template #option-empty="{ query }"> | ||
<q>{{ query }}</q> not found | ||
</template> | ||
</UInputMenu> | ||
</template> |
25 changes: 25 additions & 0 deletions
25
docs/components/content/examples/InputMenuExampleOptionSlot.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script setup> | ||
const people = [ | ||
{ name: 'Wade Cooper', online: true }, | ||
{ name: 'Arlene Mccoy', online: false }, | ||
{ name: 'Devon Webb', online: false }, | ||
{ name: 'Tom Cook', online: true }, | ||
{ name: 'Tanya Fox', online: false }, | ||
{ name: 'Hellen Schmidt', online: true }, | ||
{ name: 'Caroline Schultz', online: true }, | ||
{ name: 'Mason Heaney', online: false }, | ||
{ name: 'Claudie Smitham', online: true }, | ||
{ name: 'Emil Schaefer', online: false } | ||
] | ||
const selected = ref(people[3]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" option-attribute="name"> | ||
<template #option="{ option: person }"> | ||
<span :class="[person.online ? 'bg-green-400' : 'bg-gray-200', 'inline-block h-2 w-2 flex-shrink-0 rounded-full']" aria-hidden="true" /> | ||
<span class="truncate">{{ person.name }}</span> | ||
</template> | ||
</UInputMenu> | ||
</template> |
9 changes: 9 additions & 0 deletions
9
docs/components/content/examples/InputMenuExamplePopperArrow.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup> | ||
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer'] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" :popper="{ arrow: true }" /> | ||
</template> |
9 changes: 9 additions & 0 deletions
9
docs/components/content/examples/InputMenuExamplePopperOffset.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup> | ||
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer'] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" :popper="{ offsetDistance: 0 }" /> | ||
</template> |
9 changes: 9 additions & 0 deletions
9
docs/components/content/examples/InputMenuExamplePopperPlacement.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup> | ||
const people = ['Wade Cooper', 'Arlene Mccoy', 'Devon Webb', 'Tom Cook', 'Tanya Fox', 'Hellen Schmidt', 'Caroline Schultz', 'Mason Heaney', 'Claudie Smitham', 'Emil Schaefer'] | ||
const selected = ref(people[0]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu v-model="selected" :options="people" :popper="{ placement: 'right-start' }" /> | ||
</template> |
28 changes: 28 additions & 0 deletions
28
docs/components/content/examples/InputMenuExampleSearchAttributes.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup> | ||
const options = [ | ||
{ id: 1, name: 'Wade Cooper', colors: ['red', 'yellow'] }, | ||
{ id: 2, name: 'Arlene Mccoy', colors: ['blue', 'yellow'] }, | ||
{ id: 3, name: 'Devon Webb', colors: ['green', 'blue'] }, | ||
{ id: 4, name: 'Tom Cook', colors: ['blue', 'red'] }, | ||
{ id: 5, name: 'Tanya Fox', colors: ['green', 'red'] }, | ||
{ id: 5, name: 'Hellen Schmidt', colors: ['green', 'yellow'] } | ||
] | ||
const selected = ref(options[1]) | ||
</script> | ||
|
||
<template> | ||
<UInputMenu | ||
v-model="selected" | ||
:options="options" | ||
placeholder="Select a person" | ||
by="id" | ||
option-attribute="name" | ||
:search-attributes="['name', 'colors']" | ||
> | ||
<template #option="{ option: person }"> | ||
<span v-for="color in person.colors" :key="color.id" class="h-2 w-2 rounded-full" :class="`bg-${color}-500 dark:bg-${color}-400`" /> | ||
<span class="truncate">{{ person.name }}</span> | ||
</template> | ||
</UInputMenu> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6d8d82a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ui – ./
ui-nuxt-js.vercel.app
ui.nuxt.com
ui-git-dev-nuxt-js.vercel.app