UNPKG

@equinor/eds-utils

Version:

Utility functions and hooks for the Equinor Design System

54 lines (51 loc) 1.35 kB
import { css } from 'styled-components'; const typographyTemplate = (typography, link) => { if (!typography) { return ''; } let base = ` margin: 0; color: ${typography.color}; font-family: ${typography.fontFamily}; font-size: ${typography.fontSize}; font-weight: ${typography.fontWeight}; line-height: ${typography.lineHeight}; `; if (typography.fontStyle) { base += `\nfont-style: ${typography.fontStyle};`; } if (typography.letterSpacing) { base += `\nletter-spacing: ${typography.letterSpacing};`; } if (typography.textTransform) { base += `\ntext-transform: ${typography.textTransform};`; } if (typography.textDecoration) { base += `\ntext-decoration: ${typography.textDecoration};`; } if (typography.textAlign) { base += `\ntext-align: ${typography.textAlign};`; } if (typography.fontFeature) { base += `\nfont-feature-settings: ${typography.fontFeature};`; } if (link) { base += `\ncursor: pointer;`; } return base; }; const spacingsTemplate = ({ left, right, top, bottom }) => css({ paddingLeft: left, paddingTop: top, paddingRight: right, paddingBottom: bottom }); const boxshadowTemplate = border => css({ boxShadow: `inset 0 -${border.width} 0 0 ${border.color};` }); export { boxshadowTemplate, spacingsTemplate, typographyTemplate };