2022-03-25 13:20:42 +08:00
/* eslint-disable import/prefer-default-export */
2022-05-09 22:20:07 +08:00
import type { CSSObject } from '@ant-design/cssinjs' ;
2022-03-25 13:20:42 +08:00
2022-08-19 10:10:51 +08:00
export const roundedArrow = (
width : number ,
innerRadius : number ,
outerRadius : number ,
bgColor : string ,
2022-08-25 19:39:26 +08:00
boxShadow : string ,
2022-08-19 10:10:51 +08:00
) : CSSObject = > {
2022-08-25 19:39:26 +08:00
const unitWidth = width / 2 ;
2022-03-25 13:20:42 +08:00
2023-02-03 14:36:46 +08:00
const ax = 0 ;
2022-08-25 19:39:26 +08:00
const ay = unitWidth ;
2023-02-03 14:36:46 +08:00
const bx = ( outerRadius * 1 ) / Math . sqrt ( 2 ) ;
2022-08-25 19:39:26 +08:00
const by = unitWidth - outerRadius * ( 1 - 1 / Math . sqrt ( 2 ) ) ;
2023-02-03 14:36:46 +08:00
const cx = unitWidth - innerRadius * ( 1 / Math . sqrt ( 2 ) ) ;
const cy = outerRadius * ( Math . sqrt ( 2 ) - 1 ) + innerRadius * ( 1 / Math . sqrt ( 2 ) ) ;
const dx = 2 * unitWidth - cx ;
2022-08-25 19:39:26 +08:00
const dy = cy ;
2023-02-03 14:36:46 +08:00
const ex = 2 * unitWidth - bx ;
2022-08-25 19:39:26 +08:00
const ey = by ;
2023-02-03 14:36:46 +08:00
const fx = 2 * unitWidth - ax ;
2022-08-25 19:39:26 +08:00
const fy = ay ;
2022-03-25 13:20:42 +08:00
2023-02-03 14:36:46 +08:00
const shadowWidth = unitWidth * Math . sqrt ( 2 ) + outerRadius * ( Math . sqrt ( 2 ) - 2 ) ;
2022-03-25 13:20:42 +08:00
return {
pointerEvents : 'none' ,
2023-02-03 14:36:46 +08:00
width ,
height : width ,
2022-08-25 19:39:26 +08:00
overflow : 'hidden' ,
2023-02-03 14:36:46 +08:00
'&::before' : {
position : 'absolute' ,
bottom : 0 ,
insetInlineStart : 0 ,
width ,
height : width / 2 ,
background : bgColor ,
clipPath : ` path('M ${ ax } ${ ay } A ${ outerRadius } ${ outerRadius } 0 0 0 ${ bx } ${ by } L ${ cx } ${ cy } A ${ innerRadius } ${ innerRadius } 0 0 1 ${ dx } ${ dy } L ${ ex } ${ ey } A ${ outerRadius } ${ outerRadius } 0 0 0 ${ fx } ${ fy } Z') ` ,
content : '""' ,
} ,
2022-08-25 19:39:26 +08:00
'&::after' : {
content : '""' ,
position : 'absolute' ,
2023-02-03 14:36:46 +08:00
width : shadowWidth ,
height : shadowWidth ,
2022-08-25 19:39:26 +08:00
bottom : 0 ,
insetInline : 0 ,
margin : 'auto' ,
borderRadius : {
_skip_check_ : true ,
value : ` 0 0 ${ innerRadius } px 0 ` ,
} ,
transform : 'translateY(50%) rotate(-135deg)' ,
boxShadow ,
zIndex : 0 ,
background : 'transparent' ,
} ,
2022-03-25 13:20:42 +08:00
} ;
2022-03-25 17:54:57 +08:00
} ;