Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-kit): add
NSelectTab
component
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
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
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,49 @@ | ||
<script setup lang="ts"> | ||
import { useVModel } from '@vueuse/core' | ||
const props = withDefaults( | ||
defineProps<{ | ||
modelValue?: any | ||
disabled?: boolean | ||
options: { value: any; label: string }[] | ||
}>(), | ||
{ | ||
modelValue: undefined, | ||
disabled: false, | ||
}, | ||
) | ||
const emit = defineEmits<{ (...args: any): void }>() | ||
const input = useVModel(props, 'modelValue', emit, { passive: true }) | ||
</script> | ||
|
||
<template> | ||
<fieldset | ||
class="n-select-tabs flex flex-inline flex-wrap items-center border n-border-base rounded focus-within:n-focus-base focus-within:border-context n-bg-base" | ||
> | ||
<label | ||
v-for="i, idx of options" | ||
:key="i.label" | ||
:disabled="disabled" | ||
class="relative n-border-base hover:n-bg-active px-0.5em py-0.1em" | ||
:class="[ | ||
idx ? 'border-l n-border-base ml--1px' : '', | ||
i.value === input ? 'n-bg-active' : '', | ||
]" | ||
:title="i.label" | ||
> | ||
<div | ||
:class="[ | ||
i.value === input ? '' : 'op35', | ||
]" | ||
>{{ i.label }}</div> | ||
<input | ||
v-model="input" | ||
type="radio" | ||
:disabled="disabled" | ||
:value="i.value" | ||
:title="i.label" | ||
class="absolute inset-0 op-0.1" | ||
> | ||
</label> | ||
</fieldset> | ||
</template> |