ant-design/components/_util/wave/util.ts
ice badfbe3cfe
feat(Button): support variant and color (#50051)
* feat(button): variant & color types

* feat: type -> color/variant

* feat: type -> color/variant

* feat: add variant filled

* test: snap

* refactor(button): rename type -> variant

* docs: add demo

* feat: add danger ghost style

* refactor: remove deprecated

* refactor: eslint

* docs: change color&variant

* test: updated snap

* docs: color-variant

* docs: add debug color&variant

* feat: global token

* refactor: remove comment

* docs: add color&variant docs

* docs: remove default

* docs: add space

* docs: code

* test: update snap

* test: fix snap

* test: btn querySelect

* feat: change filled hoverStyle

* test: fix

* feat: support grey wave

* refactor: enhance

* docs: color/variant -> v 5.21

* test: snap

* feat: add token

* test: to do

* test: fix test

* ci: rebuild

* style: remove

* style: space

* docs: add note & FQA

* feat: add componentsToken

* refactor: remove isNotGrey

* test: add case

* docs: tile button

* test: snap

* docs: site & snap

* Update components/button/index.en-US.md

Co-authored-by: lijianan <574980606@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* fix: token color & undef

* docs: site

* docs: responsive

* docs: enhance FAQ

* docs: gap middle

* test: snap

* Update components/theme/interface/maps/colors.ts

Co-authored-by: MadCcc <1075746765@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* Update components/theme/interface/maps/colors.ts

Co-authored-by: MadCcc <1075746765@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* Update components/theme/interface/maps/colors.ts

Co-authored-by: MadCcc <1075746765@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* Update components/button/style/token.ts

Co-authored-by: MadCcc <1075746765@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* Update components/button/style/token.ts

Co-authored-by: MadCcc <1075746765@qq.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* refactor: rename

* docs: prettier

* chore: eslint

* refactor: cls

* test: add solidTextColor case

* refactor: genVariantButtonStyle

* refactor: genVariantButtonStyle

* refactor: genVariantButtonStyle

* fix: rename

* docs: text

* fix: remove border

* feat: add token colorErrorBgFilledHover

* chore: add size-limit

* refactor: rename

---------

Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>
Co-authored-by: lijianan <574980606@qq.com>
Co-authored-by: MadCcc <1075746765@qq.com>
2024-09-03 17:39:02 +08:00

26 lines
686 B
TypeScript

export function isValidWaveColor(color: string) {
return (
color &&
color !== '#fff' &&
color !== '#ffffff' &&
color !== 'rgb(255, 255, 255)' &&
color !== 'rgba(255, 255, 255, 1)' &&
!/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;
}