Sha256: 869754eae898b5524d248445b7a0a90bd817e24c8b573e84ad964c8b8cc3cc81

Contents?: true

Size: 1.93 KB

Versions: 31

Compression:

Stored size: 1.93 KB

Contents

// Prop categories
const spacingProps = ({
  marginRight,
  marginLeft,
  marginTop,
  marginBottom,
  marginX,
  marginY,
  margin,
  paddingRight,
  paddingLeft,
  paddingTop,
  paddingBottom,
  paddingX,
  paddingY,
  padding,
}) => {
  let css = ''
  css += marginRight ? `mr_${marginRight} ` : ''
  css += marginLeft ? `ml_${marginLeft} ` : ''
  css += marginTop ? `mt_${marginTop} ` : ''
  css += marginBottom ? `mb_${marginBottom} ` : ''
  css += marginX ? `mx_${marginX} ` : ''
  css += marginY ? `my_${marginY} ` : ''
  css += margin ? `m_${margin} ` : ''
  css += paddingRight ? `pr_${paddingRight} ` : ''
  css += paddingLeft ? `pl_${paddingLeft} ` : ''
  css += paddingTop ? `pt_${paddingTop} ` : ''
  css += paddingBottom ? `pb_${paddingBottom} ` : ''
  css += paddingX ? `px_${paddingX} ` : ''
  css += paddingY ? `py_${paddingY} ` : ''
  css += padding ? `p_${padding} ` : ''
  return css
}

const darkProps = ({ dark }) => {
  let css = ''
  css += dark ? 'dark' : ''
  return css
}

const numberSpacingProps = ({ numberSpacing }) => {
  let css = ''
  css += numberSpacing ? `ns_${numberSpacing} ` : ''
  return css
}

const maxWidthProps = ({ maxWidth }) => {
  let css = ''
  css += maxWidth ? `max_width_${maxWidth } ` : ''
  return css
}

const zIndexProps = ({ zIndex }) => {
  let css = ''
  css += zIndex ? `z_index_${zIndex } ` : ''
  return css
}

// All Exported as a single function
export const globalProps = (props, defaultProps = {}) => {
  const allProps = { ...props, ...defaultProps }
  return spacingProps(allProps) + darkProps(allProps) + maxWidthProps(allProps) + zIndexProps(allProps) + numberSpacingProps(allProps)
}

export const deprecatedProps = (kit, props = []) => {
  if (process.env.NODE_ENV === 'development') {
    /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
    props.forEach((prop) => {
      console.warn(`${kit} Kit: The prop '${prop}' is deprecated and will be removed in a future release!`)
    })
  }
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
playbook_ui-10.16.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.15.1 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.15.1.pre.alpha.rubocop.deps app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.15.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.14.1.pre.alpha2 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.14.1.pre.alpha1 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.14.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.13.1 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.13.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.13.0.pre.node.update app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.12.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.11.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.10.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.9.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.8.1.pre.alpha.flexdeps app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.9.0.pre.alpha1 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.8.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.7.1 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.7.0 app/pb_kits/playbook/utilities/globalProps.js
playbook_ui-10.6.2.pre.alpha.dep app/pb_kits/playbook/utilities/globalProps.js