This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
forked from nuxt/ui
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2b9948
commit b6cb72d
Showing
12 changed files
with
677 additions
and
55 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
35 changes: 35 additions & 0 deletions
35
docs/app/components/content/examples/select/SelectFetchExample.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,35 @@ | ||
<script setup lang="ts"> | ||
const { data: users, status } = await useFetch('https://jsonplaceholder.typicode.com/users', { | ||
transform: (data: { name: string, id: number }[]) => { | ||
return data?.map(user => ({ | ||
label: user.name, | ||
value: String(user.id), | ||
avatar: { src: `https://i.pravatar.cc/120?img=${user.id}` } | ||
})) || [] | ||
}, | ||
lazy: true | ||
}) | ||
function getUserAvatar(value: string) { | ||
return users.value?.find(user => user.value === value)?.avatar || {} | ||
} | ||
</script> | ||
|
||
<template> | ||
<USelect | ||
:items="users || []" | ||
:loading="status === 'pending'" | ||
icon="i-heroicons-user" | ||
placeholder="Select user" | ||
class="w-48" | ||
> | ||
<template #leading="{ modelValue, ui }"> | ||
<UAvatar | ||
v-if="modelValue" | ||
v-bind="getUserAvatar(modelValue)" | ||
:size="ui.itemLeadingAvatarSize()" | ||
:class="ui.itemLeadingAvatar()" | ||
/> | ||
</template> | ||
</USelect> | ||
</template> |
13 changes: 13 additions & 0 deletions
13
docs/app/components/content/examples/select/SelectIconExample.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 lang="ts"> | ||
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done']) | ||
</script> | ||
|
||
<template> | ||
<USelect | ||
default-value="Backlog" | ||
:items="items" | ||
:ui="{ | ||
trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200' | ||
}" | ||
/> | ||
</template> |
45 changes: 45 additions & 0 deletions
45
docs/app/components/content/examples/select/SelectItemsAvatarExample.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,45 @@ | ||
<script setup lang="ts"> | ||
const items = ref([ | ||
{ | ||
label: 'benjamincanac', | ||
value: 'benjamincanac', | ||
avatar: { | ||
src: 'https://github.com/benjamincanac.png', | ||
alt: 'benjamincanac' | ||
} | ||
}, | ||
{ | ||
label: 'romhml', | ||
value: 'romhml', | ||
avatar: { | ||
src: 'https://github.com/romhml.png', | ||
alt: 'romhml' | ||
} | ||
}, | ||
{ | ||
label: 'noook', | ||
value: 'noook', | ||
avatar: { | ||
src: 'https://github.com/noook.png', | ||
alt: 'noook' | ||
} | ||
} | ||
]) | ||
function getAvatar(value: string) { | ||
return items.value.find(item => item.value === value)?.avatar | ||
} | ||
</script> | ||
|
||
<template> | ||
<USelect default-value="benjamincanac" :items="items" class="w-40"> | ||
<template #leading="{ modelValue, ui }"> | ||
<UAvatar | ||
v-if="modelValue" | ||
v-bind="getAvatar(modelValue)" | ||
:size="ui.itemLeadingAvatarSize()" | ||
:class="ui.itemLeadingAvatar()" | ||
/> | ||
</template> | ||
</USelect> | ||
</template> |
44 changes: 44 additions & 0 deletions
44
docs/app/components/content/examples/select/SelectItemsChipExample.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,44 @@ | ||
<script setup lang="ts"> | ||
const items = ref([ | ||
{ | ||
label: 'bug', | ||
value: 'bug', | ||
chip: { | ||
color: 'red' as const | ||
} | ||
}, | ||
{ | ||
label: 'enhancement', | ||
value: 'enhancement', | ||
chip: { | ||
color: 'blue' as const | ||
} | ||
}, | ||
{ | ||
label: 'feature', | ||
value: 'feature', | ||
chip: { | ||
color: 'violet' as const | ||
} | ||
} | ||
]) | ||
function getChip(value: string) { | ||
return items.value.find(item => item.value === value)?.chip | ||
} | ||
</script> | ||
|
||
<template> | ||
<USelect default-value="bug" :items="items" class="w-40"> | ||
<template #leading="{ modelValue, ui }"> | ||
<UChip | ||
v-if="modelValue" | ||
v-bind="getChip(modelValue)" | ||
inset | ||
standalone | ||
:size="ui.itemLeadingChipSize()" | ||
:class="ui.itemLeadingChip()" | ||
/> | ||
</template> | ||
</USelect> | ||
</template> |
31 changes: 31 additions & 0 deletions
31
docs/app/components/content/examples/select/SelectItemsIconExample.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,31 @@ | ||
<script setup lang="ts"> | ||
const selected = ref('backlog') | ||
const items = ref([ | ||
{ | ||
label: 'Backlog', | ||
value: 'backlog', | ||
icon: 'i-heroicons-question-mark-circle' | ||
}, | ||
{ | ||
label: 'Todo', | ||
value: 'todo', | ||
icon: 'i-heroicons-plus-circle' | ||
}, | ||
{ | ||
label: 'In Progress', | ||
value: 'in_progress', | ||
icon: 'i-heroicons-arrow-up-circle' | ||
}, | ||
{ | ||
label: 'Done', | ||
value: 'done', | ||
icon: 'i-heroicons-check-circle' | ||
} | ||
]) | ||
const icon = computed(() => items.value.find(item => item.value === selected.value)?.icon) | ||
</script> | ||
|
||
<template> | ||
<USelect v-model="selected" :icon="icon" :items="items" class="w-40" /> | ||
</template> |
12 changes: 12 additions & 0 deletions
12
docs/app/components/content/examples/select/SelectOpenExample.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,12 @@ | ||
<script setup lang="ts"> | ||
const open = ref(false) | ||
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done']) | ||
defineShortcuts({ | ||
o: () => open.value = !open.value | ||
}) | ||
</script> | ||
|
||
<template> | ||
<USelect v-model:open="open" default-value="Backlog" :items="items" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ ignore: | |
props: | ||
color: gray | ||
variant: subtle | ||
highlight: false | ||
placeholder: 'Search...' | ||
--- | ||
:: | ||
|
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.