tailwind.config.js: parse single-tint values in the matrix

This commit is contained in:
Alex Gleason
2022-03-23 16:51:42 -05:00
parent d57051c41c
commit e0e953647e
3 changed files with 50 additions and 17 deletions

View File

@ -30,6 +30,24 @@ describe('parseColorMatrix()', () => {
// Colors are mapped to functions which return CSS values
expect(result.primary[500]({})).toEqual('rgb(var(--color-primary-500))');
expect(result.accent[300]({ opacityValue: .5 })).toEqual('rgb(var(--color-accent-300) / 0.5)');
expect(result.accent[300]({ opacityValue: .3 })).toEqual('rgb(var(--color-accent-300) / 0.3)');
});
it('parses single-tint values', () => {
const colorMatrix = {
gray: [50, 100, 200, 300, 400, 500, 600, 700, 800, 900],
primary: [50, 100, 200, 300, 400, 500, 600, 700, 800, 900],
success: [50, 100, 200, 300, 400, 500, 600, 700, 800, 900],
danger: [50, 100, 200, 300, 400, 500, 600, 700, 800, 900],
accent: [300, 500],
'gradient-purple': true,
'gradient-blue': true,
'sea-blue': true,
};
const result = parseColorMatrix(colorMatrix);
expect(result['sea-blue']({})).toEqual('rgb(var(--color-sea-blue))');
expect(result['gradient-purple']({ opacityValue: .7 })).toEqual('rgb(var(--color-gradient-purple) / 0.7)');
});
});