You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
63 lines
1.7 KiB
3 years ago
|
/* eslint-disable import/prefer-default-export */
|
||
3 years ago
|
import type { CSSObject } from '@ant-design/cssinjs';
|
||
3 years ago
|
|
||
2 years ago
|
export const roundedArrow = (
|
||
|
width: number,
|
||
|
innerRadius: number,
|
||
|
outerRadius: number,
|
||
|
bgColor: string,
|
||
2 years ago
|
boxShadow: string,
|
||
2 years ago
|
): CSSObject => {
|
||
2 years ago
|
const unitWidth = width / 2;
|
||
3 years ago
|
|
||
2 years ago
|
const ax = unitWidth - outerRadius * (Math.sqrt(2) - 1);
|
||
|
const ay = unitWidth;
|
||
|
const bx = unitWidth + outerRadius * (1 - 1 / Math.sqrt(2));
|
||
|
const by = unitWidth - outerRadius * (1 - 1 / Math.sqrt(2));
|
||
|
const cx = 2 * unitWidth - innerRadius * (1 / Math.sqrt(2));
|
||
|
const cy = innerRadius * (1 / Math.sqrt(2));
|
||
|
const dx = 4 * unitWidth - cx;
|
||
|
const dy = cy;
|
||
|
const ex = 4 * unitWidth - bx;
|
||
|
const ey = by;
|
||
|
const fx = 4 * unitWidth - ax;
|
||
|
const fy = ay;
|
||
3 years ago
|
|
||
|
return {
|
||
2 years ago
|
borderRadius: { _skip_check_: true, value: `0 0 ${innerRadius}px` },
|
||
3 years ago
|
pointerEvents: 'none',
|
||
2 years ago
|
width: width * 2,
|
||
|
height: width * 2,
|
||
|
overflow: 'hidden',
|
||
|
|
||
|
'&::after': {
|
||
|
content: '""',
|
||
|
position: 'absolute',
|
||
|
width: width / Math.sqrt(2),
|
||
|
height: width / Math.sqrt(2),
|
||
|
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',
|
||
|
},
|
||
3 years ago
|
|
||
|
'&::before': {
|
||
|
position: 'absolute',
|
||
2 years ago
|
bottom: 0,
|
||
|
insetInlineStart: 0,
|
||
|
width: width * 2,
|
||
|
height: width / 2,
|
||
3 years ago
|
background: bgColor,
|
||
2 years ago
|
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')`,
|
||
3 years ago
|
content: '""',
|
||
|
},
|
||
|
};
|
||
3 years ago
|
};
|