1- import { defineComponent , ExtractPropTypes , inject } from 'vue' ;
1+ import { defineComponent , ExtractPropTypes , inject , CSSProperties } from 'vue' ;
22import VcTooltip from '../vc-tooltip' ;
33import classNames from '../_util/classNames' ;
44import getPlacements from './placements' ;
55import PropTypes from '../_util/vue-types' ;
6+ import { PresetColorTypes } from '../_util/colors' ;
67import {
78 hasProp ,
89 getComponent ,
@@ -28,6 +29,8 @@ const splitObject = (obj: any, keys: string[]) => {
2829} ;
2930const props = abstractTooltipProps ( ) ;
3031
32+ const PresetColorRegex = new RegExp ( `^(${ PresetColorTypes . join ( '|' ) } )(-inverse)?$` ) ;
33+
3134const tooltipProps = {
3235 ...props ,
3336 title : PropTypes . VNodeChild ,
@@ -176,7 +179,13 @@ export default defineComponent({
176179
177180 render ( ) {
178181 const { $props, $data, $attrs } = this ;
179- const { prefixCls : customizePrefixCls , openClassName, getPopupContainer } = $props ;
182+ const {
183+ prefixCls : customizePrefixCls ,
184+ openClassName,
185+ getPopupContainer,
186+ color,
187+ overlayClassName,
188+ } = $props ;
180189 const { getPopupContainer : getContextPopupContainer } = this . configProvider ;
181190 const getPrefixCls = this . configProvider . getPrefixCls ;
182191 const prefixCls = getPrefixCls ( 'tooltip' , customizePrefixCls ) ;
@@ -197,6 +206,16 @@ export default defineComponent({
197206 [ openClassName || `${ prefixCls } -open` ] : sVisible ,
198207 [ child . props && child . props . class ] : child . props && child . props . class ,
199208 } ) ;
209+ const customOverlayClassName = classNames ( overlayClassName , {
210+ [ `${ prefixCls } -${ color } ` ] : color && PresetColorRegex . test ( color ) ,
211+ } ) ;
212+ let formattedOverlayInnerStyle : CSSProperties ;
213+ let arrowContentStyle : CSSProperties ;
214+ if ( color && ! PresetColorRegex . test ( color ) ) {
215+ formattedOverlayInnerStyle = { backgroundColor : color } ;
216+ arrowContentStyle = { backgroundColor : color } ;
217+ }
218+
200219 const vcTooltipProps = {
201220 ...$attrs ,
202221 ...$props ,
@@ -206,6 +225,9 @@ export default defineComponent({
206225 overlay : this . getOverlay ( ) ,
207226 visible : sVisible ,
208227 ref : 'tooltip' ,
228+ overlayClassName : customOverlayClassName ,
229+ overlayInnerStyle : formattedOverlayInnerStyle ,
230+ arrowContent : < span class = { `${ prefixCls } -arrow-content` } style = { arrowContentStyle } > </ span > ,
209231 onVisibleChange : this . handleVisibleChange ,
210232 onPopupAlign : this . onPopupAlign ,
211233 } ;
0 commit comments