-
Notifications
You must be signed in to change notification settings - Fork 27
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
Showing
19 changed files
with
194 additions
and
13 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,53 @@ | ||
<script setup> | ||
import { ref } from 'vue' | ||
import { Menu } from 'tailv' | ||
|
||
const items = ref([ | ||
{ | ||
key: '1', | ||
type: 'group', | ||
label: 'Group title', | ||
children: [ | ||
{key: '1-1', label: '1st menu item', | ||
}, | ||
{key: '1-2', label: '2nd menu item', | ||
}, | ||
], | ||
}, | ||
{ | ||
key: '2', | ||
label: 'sub menu', | ||
children: [ | ||
{key: '2-1', label: '3rd menu item', | ||
}, | ||
{key: '2-2', label: '4th menu item',}, | ||
], | ||
}, | ||
{ | ||
key: '3', | ||
label: 'disabled sub menu', | ||
disabled: true, | ||
children: [ | ||
{ | ||
key: '3-1', | ||
label: '5d menu item', | ||
}, | ||
{ | ||
key: '3-2', | ||
label: '6th menu item', | ||
}, | ||
], | ||
}, | ||
]) | ||
|
||
</script> | ||
|
||
# CheckboxGroup | ||
|
||
## Default | ||
|
||
<div class="flex flex-wrap gap-2 not-prose"> | ||
<div class="border border-slate-300"> | ||
<Menu :items="items" /> | ||
</div> | ||
</div> |
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,17 @@ | ||
<script setup lang="ts"> | ||
import { ref, computed } from 'vue' | ||
defineOptions({ name: 'Badge' }) | ||
const emit = defineEmits<{ click: [any] }>() | ||
const slots = defineSlots<{ default?(_: {}): any }>() | ||
const props = defineProps({ | ||
color: String, | ||
}) | ||
</script> | ||
<template> | ||
<span | ||
class="inline-flex items-center rounded-md bg-slate-50 py-1 px-2 text-xs font-medium text-slate-600 ring-1 ring-gray-500/10 ring-inset" | ||
> | ||
<slot /> | ||
</span> | ||
</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
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
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,24 @@ | ||
<script setup lang="ts"> | ||
import { ref, computed } from 'vue' | ||
defineOptions({ name: 'Dropdown' }) | ||
const emit = defineEmits<{ click: [any] }>() | ||
const slots = defineSlots<{ default?(_: {}): any }>() | ||
const props = defineProps({ | ||
menu: Array, | ||
}) | ||
</script> | ||
<template> | ||
<Popper trigger="click" placement="bottom" ref="popperRef"> | ||
<slot /> | ||
<template #content> | ||
<div class="z-popover ring-opacity-5 rounded-md bg-white ring-1 shadow-lg ring-slate-300"> | ||
<slot name="content"> | ||
<div class="px-2"> | ||
{{ content }} | ||
</div> | ||
</slot> | ||
</div> | ||
</template> | ||
</Popper> | ||
</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
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,48 @@ | ||
<script setup lang="ts"> | ||
import { ref, computed, type PropType } from 'vue' | ||
import { isDividerItem, isGroupItem, isMenuItem, type MenuItem, type MenuItemType } from './types' | ||
defineOptions({ name: 'Menu' }) | ||
const emit = defineEmits<{ click: [any] }>() | ||
const slots = defineSlots<{ default?(_: {}): any }>() | ||
const props = defineProps({ | ||
title: String, | ||
items: { | ||
type: Array as PropType<MenuItem[]>, | ||
default: () => [], | ||
}, | ||
}) | ||
const current = ref<MenuItemType>() | ||
const isCurrent = (item: MenuItemType) => { | ||
return item.key === current.value?.key | ||
} | ||
</script> | ||
<template> | ||
<nav class="flex flex-1 flex-col p-1" aria-label="Sidebar"> | ||
<ul role="list" class="space-y-1"> | ||
<li v-for="item in items"> | ||
<div v-if="isDividerItem(item)" class="bg-muted -mx-1 my-1 h-px" /> | ||
<div v-if="isGroupItem(item)" class="text-xs font-semibold leading-6 text-slate-400">{{ item.label }}</div> | ||
<a | ||
v-if="isMenuItem(item)" | ||
:class="[ | ||
isCurrent(item) ? 'text-primary-600 bg-gray-50' : 'hover:text-primary-600 text-gray-700 hover:bg-gray-50', | ||
'group flex gap-x-3 rounded-md p-2 text-sm font-semibold leading-6', | ||
]" | ||
> | ||
<component | ||
:is="item.icon" | ||
:class="[ | ||
isCurrent(item) ? 'text-primary-600' : 'group-hover:text-primary-600 text-gray-400', | ||
'h-6 w-6 shrink-0', | ||
]" | ||
aria-hidden="true" | ||
/> | ||
{{ item.label }} | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
</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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Menu } from './Menu.vue' | ||
export type { MenuItem, MenuItemDividerType, MenuItemGroupType, MenuItemType } from './types' |
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,32 @@ | ||
import type { Component } from 'vue' | ||
|
||
export type MenuItemType = { | ||
type: never | ||
key: string | ||
label: string | ||
disabled?: boolean | ||
icon?: Component | ||
children?: MenuItem[] | ||
} | ||
|
||
export type MenuItemGroupType = { | ||
type: 'group' | ||
label: string | ||
children: MenuItem[] | ||
} | ||
|
||
export type MenuItemDividerType = { | ||
type: 'divider' | ||
} | ||
|
||
export type MenuItem = MenuItemDividerType | MenuItemGroupType | MenuItemType | ||
|
||
export function isDividerItem(item: MenuItem): item is MenuItemDividerType { | ||
return item.type === 'divider' | ||
} | ||
export function isGroupItem(item: MenuItem): item is MenuItemGroupType { | ||
return item.type === 'group' | ||
} | ||
export function isMenuItem(item: MenuItem): item is MenuItemType { | ||
return !isGroupItem(item) && !isDividerItem(item) | ||
} |
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
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
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