mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 11:20:36 +01:00
feat(Button): add subtle variant
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import theme from '#build/ui/button'
|
import theme from '#build/ui/button'
|
||||||
|
|
||||||
const sizes = Object.keys(theme.variants.size)
|
const sizes = Object.keys(theme.variants.size)
|
||||||
|
const variants = Object.keys(theme.variants.variant)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -40,11 +41,7 @@ const sizes = Object.keys(theme.variants.size)
|
|||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" />
|
<UButton v-for="variant in variants" :key="variant" icon="i-heroicons-rocket-launch" label="Button" :variant="(variant as any)" />
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" variant="outline" />
|
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" variant="soft" />
|
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" variant="ghost" />
|
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" variant="link" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<UButton icon="i-heroicons-rocket-launch" label="Button" color="white" />
|
<UButton icon="i-heroicons-rocket-launch" label="Button" color="white" />
|
||||||
@@ -79,7 +76,7 @@ const sizes = Object.keys(theme.variants.size)
|
|||||||
<UButton v-for="size in sizes" :key="size" icon="i-heroicons-rocket-launch" :size="(size as any)" />
|
<UButton v-for="size in sizes" :key="size" icon="i-heroicons-rocket-launch" :size="(size as any)" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<UButton icon="i-heroicons-rocket-launch" trailing-icon="i-heroicons-chevron-down-20-solid" label="Block" loading block />
|
<UButton icon="i-heroicons-rocket-launch" trailing-icon="i-heroicons-chevron-down-20-solid" label="Block" block />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<UButton icon="i-heroicons-cloud-arrow-down" label="Button" class="group" :ui="{ leadingIcon: 'group-hover:animate-pulse' }" />
|
<UButton icon="i-heroicons-cloud-arrow-down" label="Button" class="group" :ui="{ leadingIcon: 'group-hover:animate-pulse' }" />
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default (config: { colors: string[] }) => ({
|
|||||||
solid: '',
|
solid: '',
|
||||||
outline: '',
|
outline: '',
|
||||||
soft: '',
|
soft: '',
|
||||||
|
subtle: '',
|
||||||
ghost: '',
|
ghost: '',
|
||||||
link: ''
|
link: ''
|
||||||
},
|
},
|
||||||
@@ -87,6 +88,10 @@ export default (config: { colors: string[] }) => ({
|
|||||||
color,
|
color,
|
||||||
variant: 'soft',
|
variant: 'soft',
|
||||||
class: `text-${color}-500 dark:text-${color}-400 bg-${color}-50 hover:bg-${color}-100 disabled:bg-${color}-50 dark:bg-${color}-950 dark:hover:bg-${color}-900 dark:disabled:bg-${color}-950 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}-500 dark:focus-visible:ring-${color}-400`
|
class: `text-${color}-500 dark:text-${color}-400 bg-${color}-50 hover:bg-${color}-100 disabled:bg-${color}-50 dark:bg-${color}-950 dark:hover:bg-${color}-900 dark:disabled:bg-${color}-950 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}-500 dark:focus-visible:ring-${color}-400`
|
||||||
|
})), ...config.colors.map((color: string) => ({
|
||||||
|
color,
|
||||||
|
variant: 'subtle',
|
||||||
|
class: `text-${color}-500 dark:text-${color}-400 ring ring-inset ring-${color}-500/25 dark:ring-${color}-400/25 bg-${color}-500/10 hover:bg-${color}-100 disabled:bg-${color}-50 dark:bg-${color}-400/10 dark:hover:bg-${color}-950 dark:disabled:bg-${color}-400/10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}-500 dark:focus-visible:ring-${color}-400`
|
||||||
})), ...config.colors.map((color: string) => ({
|
})), ...config.colors.map((color: string) => ({
|
||||||
color,
|
color,
|
||||||
variant: 'ghost',
|
variant: 'ghost',
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ describe('Button', () => {
|
|||||||
['with color', { props: { label: 'Button', color: 'red' as const } }],
|
['with color', { props: { label: 'Button', color: 'red' as const } }],
|
||||||
['with variant outline', { props: { label: 'Button', variant: 'outline' as const } }],
|
['with variant outline', { props: { label: 'Button', variant: 'outline' as const } }],
|
||||||
['with variant soft', { props: { label: 'Button', variant: 'soft' as const } }],
|
['with variant soft', { props: { label: 'Button', variant: 'soft' as const } }],
|
||||||
|
['with variant subtle', { props: { label: 'Button', variant: 'subtle' as const } }],
|
||||||
['with variant ghost', { props: { label: 'Button', variant: 'ghost' as const } }],
|
['with variant ghost', { props: { label: 'Button', variant: 'ghost' as const } }],
|
||||||
['with variant link', { props: { label: 'Button', variant: 'link' as const } }],
|
['with variant link', { props: { label: 'Button', variant: 'link' as const } }],
|
||||||
['with icon', { props: { icon: 'i-heroicons-rocket-launch' } }],
|
['with icon', { props: { icon: 'i-heroicons-rocket-launch' } }],
|
||||||
|
|||||||
@@ -197,3 +197,10 @@ exports[`Button > renders with variant soft correctly 1`] = `
|
|||||||
<!--v-if-->
|
<!--v-if-->
|
||||||
</button>"
|
</button>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Button > renders with variant subtle correctly 1`] = `
|
||||||
|
"<button type="button" class="rounded-md font-medium inline-flex items-center focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 px-2.5 py-1.5 text-sm gap-x-1.5 text-primary-500 dark:text-primary-400 ring ring-inset ring-primary-500/25 dark:ring-primary-400/25 bg-primary-500/10 hover:bg-primary-100 disabled:bg-primary-50 dark:bg-primary-400/10 dark:hover:bg-primary-950 dark:disabled:bg-primary-400/10 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400">
|
||||||
|
<!--v-if--><span class="">Button</span>
|
||||||
|
<!--v-if-->
|
||||||
|
</button>"
|
||||||
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user