1
1
import type { ExtractPropTypes } from 'vue' ;
2
- import { defineComponent } from 'vue' ;
3
- import classNames from '../_util/classNames' ;
2
+ import { computed , defineComponent } from 'vue' ;
4
3
import PropTypes from '../_util/vue-types' ;
5
4
import initDefaultProps from '../_util/props-util/initDefaultProps' ;
6
5
import { tuple , booleanType } from '../_util/type' ;
@@ -27,24 +26,28 @@ export default defineComponent({
27
26
slots : [ 'dot' , 'label' ] ,
28
27
setup ( props , { slots } ) {
29
28
const { prefixCls } = useConfigInject ( 'timeline' , props ) ;
30
- return ( ) => {
31
- const { color = '' , pending, label = slots . label ?.( ) , dot = slots . dot ?.( ) } = props ;
32
- const itemClassName = classNames ( {
33
- [ `${ prefixCls . value } -item` ] : true ,
34
- [ `${ prefixCls . value } -item-pending` ] : pending ,
35
- } ) ;
29
+ const itemClassName = computed ( ( ) => ( {
30
+ [ `${ prefixCls . value } -item` ] : true ,
31
+ [ `${ prefixCls . value } -item-pending` ] : props . pending ,
32
+ } ) ) ;
36
33
37
- const dotClassName = classNames ( {
38
- [ `${ prefixCls . value } -item-head` ] : true ,
39
- [ `${ prefixCls . value } -item-head-custom` ] : dot ,
40
- [ `${ prefixCls . value } -item-head-${ color } ` ] : true ,
41
- } ) ;
42
- const customColor = / b l u e | r e d | g r e e n | g r a y / . test ( color || '' ) ? undefined : color ;
34
+ const customColor = computed ( ( ) =>
35
+ / b l u e | r e d | g r e e n | g r a y / . test ( props . color || '' ) ? undefined : props . color || 'blue' ,
36
+ ) ;
37
+ const dotClassName = computed ( ( ) => ( {
38
+ [ `${ prefixCls . value } -item-head` ] : true ,
39
+ [ `${ prefixCls . value } -item-head-${ props . color || 'blue' } ` ] : ! customColor . value ,
40
+ } ) ) ;
41
+ return ( ) => {
42
+ const { label = slots . label ?.( ) , dot = slots . dot ?.( ) } = props ;
43
43
return (
44
- < li class = { itemClassName } >
44
+ < li class = { itemClassName . value } >
45
45
{ label && < div class = { `${ prefixCls . value } -item-label` } > { label } </ div > }
46
46
< div class = { `${ prefixCls . value } -item-tail` } />
47
- < div class = { dotClassName } style = { { borderColor : customColor , color : customColor } } >
47
+ < div
48
+ class = { [ dotClassName . value , ! ! dot && `${ prefixCls . value } -item-head-custom` ] }
49
+ style = { { borderColor : customColor . value , color : customColor . value } }
50
+ >
48
51
{ dot }
49
52
</ div >
50
53
< div class = { `${ prefixCls . value } -item-content` } > { slots . default ?.( ) } </ div >
0 commit comments