mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 09:21:22 +08:00
9f7b129c41
* fix: Button wave follow issue * test: update test case * chore: fix lint
36 lines
1016 B
TypeScript
36 lines
1016 B
TypeScript
export function isNotGrey(color: string) {
|
|
// eslint-disable-next-line no-useless-escape
|
|
const match = (color || '').match(/rgba?\((\d*), (\d*), (\d*)(, [\d.]*)?\)/);
|
|
if (match && match[1] && match[2] && match[3]) {
|
|
return !(match[1] === match[2] && match[2] === match[3]);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
export function isValidWaveColor(color: string) {
|
|
return (
|
|
color &&
|
|
color !== '#fff' &&
|
|
color !== '#ffffff' &&
|
|
color !== 'rgb(255, 255, 255)' &&
|
|
color !== 'rgba(255, 255, 255, 1)' &&
|
|
isNotGrey(color) &&
|
|
!/rgba\((?:\d*, ){3}0\)/.test(color) && // any transparent rgba color
|
|
color !== 'transparent'
|
|
);
|
|
}
|
|
|
|
export function getTargetWaveColor(node: HTMLElement) {
|
|
const { borderTopColor, borderColor, backgroundColor } = getComputedStyle(node);
|
|
if (isValidWaveColor(borderTopColor)) {
|
|
return borderTopColor;
|
|
}
|
|
if (isValidWaveColor(borderColor)) {
|
|
return borderColor;
|
|
}
|
|
if (isValidWaveColor(backgroundColor)) {
|
|
return backgroundColor;
|
|
}
|
|
return null;
|
|
}
|