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 ,
) : CSSObject = > {
2022-03-25 13:20:42 +08:00
const cornerHeight = outerRadius * ( 1 - 1 / Math . sqrt ( 2 ) ) ;
const ax = width - cornerHeight ;
const ay = 2 * width + cornerHeight ;
const bx = ax + outerRadius * ( 1 / Math . sqrt ( 2 ) ) ;
const by = 2 * width ;
2022-08-19 10:10:51 +08:00
const cx = 2 * width - innerRadius ;
2022-03-25 13:20:42 +08:00
const cy = 2 * width ;
const dx = 2 * width ;
2022-08-19 10:10:51 +08:00
const dy = 2 * width - innerRadius ;
2022-03-25 13:20:42 +08:00
const fx = 2 * width + cornerHeight ;
const fy = width - cornerHeight ;
const ex = 2 * width ;
const ey = fy + outerRadius * ( 1 / Math . sqrt ( 2 ) ) ;
return {
2022-04-19 11:27:09 +08:00
borderRadius : { _skip_check_ : true , value : ` 0 0 2px ` } ,
2022-03-25 13:20:42 +08:00
pointerEvents : 'none' ,
'&::before' : {
position : 'absolute' ,
top : - width ,
insetInlineStart : - width ,
width : width * 3 ,
height : width * 3 ,
2022-05-07 15:19:54 +08:00
background : bgColor ,
// Hack firefox: https://github.com/ant-design/ant-design/pull/33710#issuecomment-1015287825
backgroundRepeat : 'no-repeat' ,
backgroundPosition : ` ${ Math . ceil ( - width + 1 ) } px ${ Math . ceil ( - width + 1 ) } px ` ,
2022-03-25 13:20:42 +08:00
content : '""' ,
2022-08-19 10:10:51 +08:00
clipPath : ` path('M ${ ax } ${ ay } A ${ outerRadius } ${ outerRadius } 0 0 1 ${ bx } ${ by } L ${ cx } ${ cy } A ${ innerRadius } ${ innerRadius } 0 0 0 ${ dx } ${ dy } L ${ ex } ${ ey } A ${ outerRadius } ${ outerRadius } 0 0 1 ${ fx } ${ fy } Z') ` ,
2022-03-25 13:20:42 +08:00
} ,
} ;
2022-03-25 17:54:57 +08:00
} ;