UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

31 lines (27 loc) 898 B
'use strict'; var constants = require('../constants.js'); const COMMON_PROP_NAMES = new Set(Object.keys(constants.COMMON)); const TYPOGRAPHY_PROP_NAMES = new Set(Object.keys(constants.TYPOGRAPHY)); const includesSystemProps = props => { if (props.sx) { return true; } return Object.keys(props).some(prop => { return TYPOGRAPHY_PROP_NAMES.has(prop) || COMMON_PROP_NAMES.has(prop); }); }; const getTypographyAndCommonProps = props => { let typographyAndCommonProps = {}; for (const prop of Object.keys(props)) { if (TYPOGRAPHY_PROP_NAMES.has(prop) || COMMON_PROP_NAMES.has(prop)) { const p = prop; typographyAndCommonProps = { ...typographyAndCommonProps, [p]: props[p] }; } } return typographyAndCommonProps; }; exports.getTypographyAndCommonProps = getTypographyAndCommonProps; exports.includesSystemProps = includesSystemProps;