mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-24 15:38:45 +08:00
fix: getAlphaColor should ignore alpha color (#37720)
This commit is contained in:
parent
5d37e6264d
commit
06d2c48c31
9
components/theme/__tests__/util.test.tsx
Normal file
9
components/theme/__tests__/util.test.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import getAlphaColor from '../util/getAlphaColor';
|
||||
|
||||
describe('util', () => {
|
||||
describe('getAlphaColor', () => {
|
||||
it('should not process color with alpha', () => {
|
||||
expect(getAlphaColor('rgba(0, 0, 0, 0.5)', 'rgba(255, 255, 255)')).toBe('rgba(0, 0, 0, 0.5)');
|
||||
});
|
||||
});
|
||||
});
|
@ -5,7 +5,11 @@ function isStableColor(color: number): boolean {
|
||||
}
|
||||
|
||||
function getAlphaColor(frontColor: string, backgroundColor: string): string {
|
||||
const { r: fR, g: fG, b: fB } = new TinyColor(frontColor).toRgb();
|
||||
const { r: fR, g: fG, b: fB, a: originAlpha } = new TinyColor(frontColor).toRgb();
|
||||
if (originAlpha < 1) {
|
||||
return frontColor;
|
||||
}
|
||||
|
||||
const { r: bR, g: bG, b: bB } = new TinyColor(backgroundColor).toRgb();
|
||||
|
||||
for (let fA = 0.01; fA <= 1; fA += 0.01) {
|
||||
|
Loading…
Reference in New Issue
Block a user