Skip to content

Commit

Permalink
feat(VBtnGroup/VBottomNav): Add baseColor prop
Browse files Browse the repository at this point in the history
fixes #17042
  • Loading branch information
yuwu9145 committed Jan 25, 2024
1 parent 0e94ff4 commit 7976cd9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { convertToUnit, genericComponent, propsFactory, useRender } from '@/util
import type { GenericProps } from '@/util'

export const makeVBottomNavigationProps = propsFactory({
baseColor: String,
bgColor: String,
color: String,
grow: Boolean,
Expand Down Expand Up @@ -99,6 +100,7 @@ export const VBottomNavigation = genericComponent<new <T>(

provideDefaults({
VBtn: {
baseColor: toRef(props, 'baseColor'),
color: toRef(props, 'color'),
density: toRef(props, 'density'),
stacked: computed(() => props.mode !== 'horizontal'),
Expand Down
23 changes: 16 additions & 7 deletions packages/vuetify/src/components/VBtn/VBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const makeVBtnProps = propsFactory({
type: Boolean,
default: undefined,
},
baseColor: String,
symbol: {
type: null,
default: VBtnToggleSymbol,
Expand Down Expand Up @@ -100,7 +101,6 @@ export const VBtn = genericComponent<VBtnSlots>()({
setup (props, { attrs, slots }) {
const { themeClasses } = provideTheme(props)
const { borderClasses } = useBorder(props)
const { colorClasses, colorStyles, variantClasses } = useVariant(props)
const { densityClasses } = useDensity(props)
const { dimensionStyles } = useDimension(props)
const { elevationClasses } = useElevation(props)
Expand All @@ -123,6 +123,19 @@ export const VBtn = genericComponent<VBtnSlots>()({

return group?.isSelected.value
})

const variantProps = computed(() => {
const showColor = (
(group?.isSelected.value && (!link.isLink.value || link.isActive?.value)) ||
(!group || link.isActive?.value)
)
return ({
color: showColor ? props.color ?? props.baseColor : props.baseColor,
variant: props.variant,
})
})
const { colorClasses, colorStyles, variantClasses } = useVariant(variantProps)

const isDisabled = computed(() => group?.disabled.value || props.disabled)
const isElevated = computed(() => {
return props.variant === 'elevated' && !(props.disabled || props.flat || props.border)
Expand Down Expand Up @@ -158,10 +171,6 @@ export const VBtn = genericComponent<VBtnSlots>()({
const hasPrepend = !!(props.prependIcon || slots.prepend)
const hasAppend = !!(props.appendIcon || slots.append)
const hasIcon = !!(props.icon && props.icon !== true)
const hasColor = (
(group?.isSelected.value && (!link.isLink.value || link.isActive?.value)) ||
(!group || link.isActive?.value)
)

return (
<Tag
Expand All @@ -182,7 +191,7 @@ export const VBtn = genericComponent<VBtnSlots>()({
},
themeClasses.value,
borderClasses.value,
hasColor ? colorClasses.value : undefined,
colorClasses.value,
densityClasses.value,
elevationClasses.value,
loaderClasses.value,
Expand All @@ -193,7 +202,7 @@ export const VBtn = genericComponent<VBtnSlots>()({
props.class,
]}
style={[
hasColor ? colorStyles.value : undefined,
colorStyles.value,
dimensionStyles.value,
locationStyles.value,
sizeStyles.value,
Expand Down
2 changes: 2 additions & 0 deletions packages/vuetify/src/components/VBtnGroup/VBtnGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { toRef } from 'vue'
import { genericComponent, propsFactory, useRender } from '@/util'

export const makeVBtnGroupProps = propsFactory({
baseColor: String,
divided: Boolean,

...makeBorderProps(),
Expand Down Expand Up @@ -44,6 +45,7 @@ export const VBtnGroup = genericComponent()({
provideDefaults({
VBtn: {
height: 'auto',
baseColor: toRef(props, 'baseColor'),
color: toRef(props, 'color'),
density: toRef(props, 'density'),
flat: true,
Expand Down

0 comments on commit 7976cd9

Please sign in to comment.