1- import  type  {  CSSObject  }  from  '../../_util/cssinjs' ; 
2- import  type  {  FullToken ,  GenerateStyle  }  from  '../../theme/internal' ; 
3- import  {  genComponentStyleHook ,  mergeToken  }  from  '../../theme/internal' ; 
1+ import  {  unit  }  from  '../../_util/cssinjs' ; 
2+ import  { 
3+  FullToken , 
4+  GenerateStyle , 
5+  genStyleHooks , 
6+  GetDefaultToken , 
7+  mergeToken , 
8+ }  from  '../../theme/internal' ; 
49import  {  resetComponent ,  textEllipsis  }  from  '../../style' ; 
510
6- export  interface  ComponentToken  { } 
11+ export  interface  ComponentToken  { 
12+  /** 
13+  * @desc  链接纵向内间距 
14+  * @descEN  Vertical padding of link 
15+  */ 
16+  linkPaddingBlock : number ; 
17+  /** 
18+  * @desc  链接横向内间距 
19+  * @descEN  Horizontal padding of link 
20+  */ 
21+  linkPaddingInlineStart : number ; 
22+ } 
723
24+ /** 
25+  * @desc  Anchor 组件的 Token 
26+  * @descEN  Token for Anchor component 
27+  */ 
828interface  AnchorToken  extends  FullToken < 'Anchor' >  { 
29+  /** 
30+  * @desc  容器块偏移量 
31+  * @descEN  Holder block offset 
32+  */ 
933 holderOffsetBlock : number ; 
10-  anchorPaddingBlock : number ; 
11-  anchorPaddingBlockSecondary : number ; 
12-  anchorPaddingInline : number ; 
13-  anchorBallSize : number ; 
14-  anchorTitleBlock : number ; 
34+  /** 
35+  * @desc  次级锚点块内间距 
36+  * @descEN  Secondary anchor block padding 
37+  */ 
38+  anchorPaddingBlockSecondary : number  |  string ; 
39+  /** 
40+  * @desc  锚点球大小 
41+  * @descEN  Anchor ball size 
42+  */ 
43+  anchorBallSize : number  |  string ; 
44+  /** 
45+  * @desc  锚点标题块 
46+  * @descEN  Anchor title block 
47+  */ 
48+  anchorTitleBlock : number  |  string ; 
1549} 
1650
1751// ============================== Shared ============================== 
18- const  genSharedAnchorStyle : GenerateStyle < AnchorToken >  =  ( token ) :  CSSObject  =>  { 
52+ const  genSharedAnchorStyle : GenerateStyle < AnchorToken >  =  token  =>  { 
1953 const  { 
2054 componentCls, 
2155 holderOffsetBlock, 
@@ -24,26 +58,25 @@ const genSharedAnchorStyle: GenerateStyle<AnchorToken> = (token): CSSObject => {
2458 colorPrimary, 
2559 lineType, 
2660 colorSplit, 
61+  calc, 
2762 }  =  token ; 
2863
2964 return  { 
3065 [ `${ componentCls }  -wrapper` ] : { 
31-  marginBlockStart : - holderOffsetBlock , 
66+  marginBlockStart : calc ( holderOffsetBlock ) . mul ( - 1 ) . equal ( ) , 
3267 paddingBlockStart : holderOffsetBlock , 
3368
3469 // delete overflow: auto 
3570 // overflow: 'auto', 
3671
37-  backgroundColor : 'transparent' , 
38- 3972 [ componentCls ] : { 
4073 ...resetComponent ( token ) , 
4174 position : 'relative' , 
4275 paddingInlineStart : lineWidthBold , 
4376
4477 [ `${ componentCls }  -link` ] : { 
45-  paddingBlock : token . anchorPaddingBlock , 
46-  paddingInline : `${ token . anchorPaddingInline } px  0` , 
78+  paddingBlock : token . linkPaddingBlock , 
79+  paddingInline : `${ unit ( token . linkPaddingInlineStart ) }   0` , 
4780
4881 '&-title' : { 
4982 ...textEllipsis , 
@@ -73,28 +106,21 @@ const genSharedAnchorStyle: GenerateStyle<AnchorToken> = (token): CSSObject => {
73106 [ componentCls ] : { 
74107 '&::before' : { 
75108 position : 'absolute' , 
76-  left : { 
77-  _skip_check_ : true , 
78-  value : 0 , 
79-  } , 
109+  insetInlineStart : 0 , 
80110 top : 0 , 
81111 height : '100%' , 
82-  borderInlineStart : `${ lineWidthBold } px  ${ lineType }   ${ colorSplit }  ` , 
112+  borderInlineStart : `${ unit ( lineWidthBold ) }   ${ lineType }   ${ colorSplit }  ` , 
83113 content : '" "' , 
84114 } , 
85115
86116 [ `${ componentCls }  -ink` ] : { 
87117 position : 'absolute' , 
88-  left : { 
89-  _skip_check_ : true , 
90-  value : 0 , 
91-  } , 
118+  insetInlineStart : 0 , 
92119 display : 'none' , 
93120 transform : 'translateY(-50%)' , 
94121 transition : `top ${ motionDurationSlow }   ease-in-out` , 
95122 width : lineWidthBold , 
96123 backgroundColor : colorPrimary , 
97- 98124 [ `&${ componentCls }  -ink-visible` ] : { 
99125 display : 'inline-block' , 
100126 } , 
@@ -109,7 +135,7 @@ const genSharedAnchorStyle: GenerateStyle<AnchorToken> = (token): CSSObject => {
109135 } ; 
110136} ; 
111137
112- const  genSharedAnchorHorizontalStyle : GenerateStyle < AnchorToken >  =  ( token ) :  CSSObject  =>  { 
138+ const  genSharedAnchorHorizontalStyle : GenerateStyle < AnchorToken >  =  token  =>  { 
113139 const  {  componentCls,  motionDurationSlow,  lineWidthBold,  colorPrimary }  =  token ; 
114140
115141 return  { 
@@ -127,7 +153,7 @@ const genSharedAnchorHorizontalStyle: GenerateStyle<AnchorToken> = (token): CSSO
127153 value : 0 , 
128154 } , 
129155 bottom : 0 , 
130-  borderBottom : `1px  ${ token . lineType }   ${ token . colorSplit }  ` , 
156+  borderBottom : `${ unit ( token . lineWidth ) }   ${ token . lineType }   ${ token . colorSplit }  ` , 
131157 content : '" "' , 
132158 } , 
133159
@@ -157,17 +183,23 @@ const genSharedAnchorHorizontalStyle: GenerateStyle<AnchorToken> = (token): CSSO
157183 } ; 
158184} ; 
159185
160- // ============================== Export ============================== 
161- export  default  genComponentStyleHook ( 'Anchor' ,  token  =>  { 
162-  const  {  fontSize,  fontSizeLG,  padding,  paddingXXS }  =  token ; 
163- 164-  const  anchorToken  =  mergeToken < AnchorToken > ( token ,  { 
165-  holderOffsetBlock : paddingXXS , 
166-  anchorPaddingBlock : paddingXXS , 
167-  anchorPaddingBlockSecondary : paddingXXS  /  2 , 
168-  anchorPaddingInline : padding , 
169-  anchorTitleBlock : ( fontSize  /  14 )  *  3 , 
170-  anchorBallSize : fontSizeLG  /  2 , 
171-  } ) ; 
172-  return  [ genSharedAnchorStyle ( anchorToken ) ,  genSharedAnchorHorizontalStyle ( anchorToken ) ] ; 
186+ export  const  prepareComponentToken : GetDefaultToken < 'Anchor' >  =  token  =>  ( { 
187+  linkPaddingBlock : token . paddingXXS , 
188+  linkPaddingInlineStart : token . padding , 
173189} ) ; 
190+ 191+ // ============================== Export ============================== 
192+ export  default  genStyleHooks ( 
193+  'Anchor' , 
194+  token  =>  { 
195+  const  {  fontSize,  fontSizeLG,  paddingXXS,  calc }  =  token ; 
196+  const  anchorToken  =  mergeToken < AnchorToken > ( token ,  { 
197+  holderOffsetBlock : paddingXXS , 
198+  anchorPaddingBlockSecondary : calc ( paddingXXS ) . div ( 2 ) . equal ( ) , 
199+  anchorTitleBlock : calc ( fontSize ) . div ( 14 ) . mul ( 3 ) . equal ( ) , 
200+  anchorBallSize : calc ( fontSizeLG ) . div ( 2 ) . equal ( ) , 
201+  } ) ; 
202+  return  [ genSharedAnchorStyle ( anchorToken ) ,  genSharedAnchorHorizontalStyle ( anchorToken ) ] ; 
203+  } , 
204+  prepareComponentToken , 
205+ ) ; 
0 commit comments