1
- import { defineComponent , ExtractPropTypes , inject } from 'vue' ;
1
+ import { defineComponent , ExtractPropTypes , inject , CSSProperties } from 'vue' ;
2
2
import VcTooltip from '../vc-tooltip' ;
3
3
import classNames from '../_util/classNames' ;
4
4
import getPlacements from './placements' ;
5
5
import PropTypes from '../_util/vue-types' ;
6
+ import { PresetColorTypes } from '../_util/colors' ;
6
7
import {
7
8
hasProp ,
8
9
getComponent ,
@@ -28,6 +29,8 @@ const splitObject = (obj: any, keys: string[]) => {
28
29
} ;
29
30
const props = abstractTooltipProps ( ) ;
30
31
32
+ const PresetColorRegex = new RegExp ( `^(${ PresetColorTypes . join ( '|' ) } )(-inverse)?$` ) ;
33
+
31
34
const tooltipProps = {
32
35
...props ,
33
36
title : PropTypes . VNodeChild ,
@@ -176,7 +179,13 @@ export default defineComponent({
176
179
177
180
render ( ) {
178
181
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 ;
180
189
const { getPopupContainer : getContextPopupContainer } = this . configProvider ;
181
190
const getPrefixCls = this . configProvider . getPrefixCls ;
182
191
const prefixCls = getPrefixCls ( 'tooltip' , customizePrefixCls ) ;
@@ -197,6 +206,16 @@ export default defineComponent({
197
206
[ openClassName || `${ prefixCls } -open` ] : sVisible ,
198
207
[ child . props && child . props . class ] : child . props && child . props . class ,
199
208
} ) ;
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
+
200
219
const vcTooltipProps = {
201
220
...$attrs ,
202
221
...$props ,
@@ -206,6 +225,9 @@ export default defineComponent({
206
225
overlay : this . getOverlay ( ) ,
207
226
visible : sVisible ,
208
227
ref : 'tooltip' ,
228
+ overlayClassName : customOverlayClassName ,
229
+ overlayInnerStyle : formattedOverlayInnerStyle ,
230
+ arrowContent : < span class = { `${ prefixCls } -arrow-content` } style = { arrowContentStyle } > </ span > ,
209
231
onVisibleChange : this . handleVisibleChange ,
210
232
onPopupAlign : this . onPopupAlign ,
211
233
} ;
0 commit comments