mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 18:30:35 +01:00
feat(Badge): add support within button groups (#3224)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
committed by
GitHub
parent
deddc7cf97
commit
10fb843f8f
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<UButtonGroup>
|
||||||
|
<UBadge color="neutral" variant="outline" size="lg" label="https://" />
|
||||||
|
|
||||||
|
<UInput color="neutral" variant="outline" placeholder="www.example.com" />
|
||||||
|
</UButtonGroup>
|
||||||
|
</template>
|
||||||
@@ -84,16 +84,22 @@ slots:
|
|||||||
|
|
||||||
### With tooltip
|
### With tooltip
|
||||||
|
|
||||||
You can use a tooltip within a button group.
|
You can use a [Tooltip](/components/tooltip) within a button group.
|
||||||
|
|
||||||
:component-example{name="button-group-tooltip-example"}
|
:component-example{name="button-group-tooltip-example"}
|
||||||
|
|
||||||
### With dropdown
|
### With dropdown
|
||||||
|
|
||||||
You can use a dropdown menu within a button group.
|
You can use a [DropdownMenu](/components/dropdown-menu) within a button group.
|
||||||
|
|
||||||
:component-example{name="button-group-dropdown-example"}
|
:component-example{name="button-group-dropdown-example"}
|
||||||
|
|
||||||
|
### With badge
|
||||||
|
|
||||||
|
You can use a [Badge](/components/badge) within a button group.
|
||||||
|
|
||||||
|
:component-example{name="button-group-badge-example"}
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ const sizes = Object.keys(theme.variants.size) as Array<keyof typeof theme.varia
|
|||||||
Button
|
Button
|
||||||
</UButton>
|
</UButton>
|
||||||
</UButtonGroup>
|
</UButtonGroup>
|
||||||
|
|
||||||
|
<UButtonGroup>
|
||||||
|
<UBadge color="neutral" variant="outline" size="lg" label="https://" />
|
||||||
|
<UInput color="neutral" variant="outline" placeholder="www.example.com" />
|
||||||
|
</UButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex gap-4 items-center justify-center">
|
<div class="flex gap-4 items-center justify-center">
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface BadgeSlots {
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { Primitive } from 'reka-ui'
|
import { Primitive } from 'reka-ui'
|
||||||
|
import { useButtonGroup } from '../composables/useButtonGroup'
|
||||||
import { useComponentIcons } from '../composables/useComponentIcons'
|
import { useComponentIcons } from '../composables/useComponentIcons'
|
||||||
import UIcon from './Icon.vue'
|
import UIcon from './Icon.vue'
|
||||||
import UAvatar from './Avatar.vue'
|
import UAvatar from './Avatar.vue'
|
||||||
@@ -47,12 +48,14 @@ const props = withDefaults(defineProps<BadgeProps>(), {
|
|||||||
})
|
})
|
||||||
defineSlots<BadgeSlots>()
|
defineSlots<BadgeSlots>()
|
||||||
|
|
||||||
|
const { orientation, size: buttonGroupSize } = useButtonGroup<BadgeProps>(props)
|
||||||
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(props)
|
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(props)
|
||||||
|
|
||||||
const ui = computed(() => badge({
|
const ui = computed(() => badge({
|
||||||
color: props.color,
|
color: props.color,
|
||||||
variant: props.variant,
|
variant: props.variant,
|
||||||
size: props.size
|
size: buttonGroupSize.value || props.size,
|
||||||
|
buttonGroup: orientation.value
|
||||||
}))
|
}))
|
||||||
|
|
||||||
extendDevtoolsMeta({ defaultProps: { label: 'Badge' } })
|
extendDevtoolsMeta({ defaultProps: { label: 'Badge' } })
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { ModuleOptions } from '../module'
|
import type { ModuleOptions } from '../module'
|
||||||
|
import { buttonGroupVariant } from './button-group'
|
||||||
|
|
||||||
export default (options: Required<ModuleOptions>) => ({
|
export default (options: Required<ModuleOptions>) => ({
|
||||||
slots: {
|
slots: {
|
||||||
@@ -10,6 +11,7 @@ export default (options: Required<ModuleOptions>) => ({
|
|||||||
trailingIcon: 'shrink-0'
|
trailingIcon: 'shrink-0'
|
||||||
},
|
},
|
||||||
variants: {
|
variants: {
|
||||||
|
...buttonGroupVariant,
|
||||||
color: {
|
color: {
|
||||||
...Object.fromEntries((options.theme.colors || []).map((color: string) => [color, ''])),
|
...Object.fromEntries((options.theme.colors || []).map((color: string) => [color, ''])),
|
||||||
neutral: ''
|
neutral: ''
|
||||||
|
|||||||
Reference in New Issue
Block a user