theme-vir
Version:
Create an entire web theme.
21 lines (20 loc) • 678 B
JavaScript
import { css, unsafeCSS } from 'element-vir';
export function createFontSizeCssValue(fontSize) {
if ('pixels' in fontSize) {
return unsafeCSS(`${fontSize.pixels}px`);
}
else if ('ratio' in fontSize) {
return unsafeCSS(`${fontSize.ratio}em`);
}
else {
throw new Error(`Invalid fontSize given: '${JSON.stringify(fontSize)}'`);
}
}
export function createFontStyleCss(fontStyle) {
return css `
font-family: ${unsafeCSS(fontStyle.family)};
font-size: ${createFontSizeCssValue(fontStyle.size)};
line-height: ${createFontSizeCssValue(fontStyle.lineHeight)};
font-weight: ${fontStyle.weight};
`;
}