diff --git a/components/badge/Badge.tsx b/components/badge/Badge.tsx index e1d8a9e6d..30195d049 100644 --- a/components/badge/Badge.tsx +++ b/components/badge/Badge.tsx @@ -107,7 +107,7 @@ export default defineComponent({ const statusCls = computed(() => ({ [`${prefixCls.value}-status-dot`]: hasStatus.value, [`${prefixCls.value}-status-${props.status}`]: !!props.status, - [`${prefixCls.value}-status-${props.color}`]: isInternalColor.value, + [`${prefixCls.value}-color-${props.color}`]: isInternalColor.value, })); const statusStyle = computed(() => { @@ -125,7 +125,7 @@ export default defineComponent({ [`${prefixCls.value}-multiple-words`]: !isDotRef.value && displayCount.value && displayCount.value.toString().length > 1, [`${prefixCls.value}-status-${props.status}`]: !!props.status, - [`${prefixCls.value}-status-${props.color}`]: isInternalColor.value, + [`${prefixCls.value}-color-${props.color}`]: isInternalColor.value, })); return () => { diff --git a/components/badge/style/index.ts b/components/badge/style/index.ts index 1e46c6007..67ac2c829 100644 --- a/components/badge/style/index.ts +++ b/components/badge/style/index.ts @@ -73,9 +73,12 @@ const genSharedBadgeStyle: GenerateStyle = (token: BadgeToken): CSSO const ribbonPrefixCls = `${antCls}-ribbon`; const ribbonWrapperPrefixCls = `${antCls}-ribbon-wrapper`; - const statusPreset = genPresetColor(token, (colorKey, { darkColor }) => ({ - [`${componentCls}-status-${colorKey}`]: { + const colorPreset = genPresetColor(token, (colorKey, { darkColor }) => ({ + [`&${componentCls} ${componentCls}-color-${colorKey}`]: { background: darkColor, + [`&:not(${componentCls}-count)`]: { + color: darkColor, + }, }, })); @@ -150,9 +153,9 @@ const genSharedBadgeStyle: GenerateStyle = (token: BadgeToken): CSSO insetInlineEnd: 0, transform: 'translate(50%, -50%)', transformOrigin: '100% 0%', - [`${iconCls}-spin`]: { + [`&${iconCls}-spin`]: { animationName: antBadgeLoadingCircle, - animationDuration: token.motionDurationMid, + animationDuration: '1s', animationIterationCount: 'infinite', animationTimingFunction: 'linear', }, @@ -207,13 +210,13 @@ const genSharedBadgeStyle: GenerateStyle = (token: BadgeToken): CSSO [`${componentCls}-status-warning`]: { backgroundColor: token.colorWarning, }, - ...statusPreset, [`${componentCls}-status-text`]: { marginInlineStart: marginXS, color: token.colorText, fontSize: token.fontSize, }, }, + ...colorPreset, [`${componentCls}-zoom-appear, ${componentCls}-zoom-enter`]: { animationName: antZoomBadgeIn, animationDuration: token.motionDurationSlow, @@ -284,7 +287,6 @@ const genSharedBadgeStyle: GenerateStyle = (token: BadgeToken): CSSO ...resetComponent(token), position: 'absolute', top: marginXS, - height: badgeFontHeight, padding: `0 ${token.paddingXS}px`, color: token.colorPrimary, lineHeight: `${badgeFontHeight}px`, diff --git a/components/float-button/FloatButton.tsx b/components/float-button/FloatButton.tsx index 228a4a454..3f4575d04 100644 --- a/components/float-button/FloatButton.tsx +++ b/components/float-button/FloatButton.tsx @@ -1,6 +1,7 @@ import classNames from '../_util/classNames'; import { defineComponent, computed, ref } from 'vue'; import Tooltip from '../tooltip'; +import Badge from '../badge'; import Content from './FloatButtonContent'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { useInjectFloatButtonGroupContext } from './context'; @@ -37,6 +38,7 @@ const FloatButton = defineComponent({ shape = 'circle', description = slots.description?.(), tooltip, + badge = {}, ...restProps } = props; @@ -60,15 +62,17 @@ const FloatButton = defineComponent({ ? () => (slots.tooltip && slots.tooltip()) || tooltip : undefined, default: () => ( -
- description, - }} - > -
+ +
+ description, + }} + > +
+
), }} > diff --git a/components/float-button/__tests__/__snapshots__/demo.test.js.snap b/components/float-button/__tests__/__snapshots__/demo.test.js.snap index 654b3fab2..4fcd2217f 100644 --- a/components/float-button/__tests__/__snapshots__/demo.test.js.snap +++ b/components/float-button/__tests__/__snapshots__/demo.test.js.snap @@ -20,6 +20,44 @@ exports[`renders ./components/float-button/demo/back-top.vue correctly 1`] = ` `; +exports[`renders ./components/float-button/demo/badge.vue correctly 1`] = ` + +
+
+`; + exports[`renders ./components/float-button/demo/basic.vue correctly 1`] = `