Migrate existing (finished) base components

This commit is contained in:
rijkvanzanten
2020-02-05 15:11:40 -05:00
parent eb011906e7
commit 55e56e30ec
77 changed files with 8530 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import parseCSSVar from './parse-css-var';
describe('Utils / parseCSSVar', () => {
it('Wraps CSS variables in var()', () => {
const result = parseCSSVar('--red');
expect(result).toBe('var(--red)');
});
it('Passes through regular CSS', () => {
const result = parseCSSVar('#abcabc');
expect(result).toBe('#abcabc');
});
});

View File

@@ -0,0 +1,6 @@
// If the passed color string starts with --, it will be returned wrapped in `var()`, so it can be
// used in CSS.
export default function parseCSSVar(color: string): string {
if (color.startsWith('--')) return `var(${color})`;
return color;
}