How to use the @emotion/is-prop-valid function in @emotion/is-prop-valid

To help you get started, we’ve selected a few @emotion/is-prop-valid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmitrykrylov / bem-jsx / src / index.js View on Github external
const isTargetTag = isTag(as)

    let baseClassName = format(blockClassName)

    if (elementClassName) {
      baseClassName += `${elementSeparator}${format(elementClassName)}`
    }

    let fullClassName = baseClassName

    let key

    for (key in otherProps) {
      if (key === "forwardedComponent" || key === "as") continue
      else if (key === "forwardedRef") propsForElement.ref = otherProps[key]
      else if (!isTargetTag || validAttr(key)) {
        // Don't pass through non HTML tags through to HTML elements
        propsForElement[key] = otherProps[key]
      }

      if (modifiers.indexOf(key) > -1) {
        const mofifier = format(key)

        if (typeof otherProps[key] === "boolean") {
          if (otherProps[key]) {
            fullClassName += " "
            fullClassName += `${baseClassName}${modifierSeparator}${mofifier}`
          }
        } else {
          const value = otherProps[key]
          fullClassName += " "
          fullClassName += `${baseClassName}${modifierSeparator}${mofifier}${modifierValueSeparator}${value}`
github cssinjs / jss / packages / react-jss / src / styled.js View on Github external
const Styled = (props: StyledProps) => {
      const {as, className} = props
      // $FlowFixMe theming ThemeContext types need to be fixed.
      const theme = React.useContext(ThemeContext)
      const classes = useStyles({...props, theme})
      const childProps: StyledProps = ({}: any)

      for (const prop in props) {
        // We don't want to pass non-dom props to the DOM,
        // but we still want to forward them to a users component.
        if (isTagName && !isPropValid(prop)) continue
        if (shouldForwardProp && shouldForwardProp(prop) === false) continue
        childProps[prop] = props[prop]
      }
      // $FlowIgnore we don't care label might not exist in classes.
      const classNames = `${classes[label] || classes.css || ''} ${classes.cssd || ''}`.trim()
      childProps.className = className ? `${className} ${classNames}` : classNames

      return React.createElement(as || type, childProps)
    }
github Workday / canvas-kit / modules / icon / react / lib / SystemIconCircle.tsx View on Github external
  shouldForwardProp: prop => isPropValid(prop) && prop !== 'size',
})>(
github Workday / canvas-kit / modules / avatar / react / lib / Avatar.tsx View on Github external
  shouldForwardProp: prop => isPropValid(prop) && prop !== 'size',
})>(
github sumup-oss / circuit-ui / src / components / Heading / Heading.js View on Github external
  shouldForwardProp: prop => isPropValid(prop) && prop !== 'size'
})`
github mineral-ui / mineral-ui / src / library / Table / styled.js View on Github external
  shouldForwardProp: (prop) => prop !== 'direction' && isPropValid(prop)
})(({ isSorted, direction, theme: baseTheme }) => {
github JoshRosenstein / emotion-icons / scripts / templates / createIcon.js View on Github external
shouldForwardProp: name =>
      !['width', 'size', 'height', 'css', 'color'].includes(name) && isPropValid(name),
  })(
github system-ui / theme-ui / packages / mdx / src / index.js View on Github external
const Styled = React.forwardRef(({ as, ...props }, ref) => {
    const shouldForwardProps =
      typeof tag !== 'string' || (as && typeof as !== 'string')
    const theme = React.useContext(ThemeContext)
    let nextProps = shouldForwardProps ? props : {}
    let styles = {}
    args.forEach(arg => {
      const style = typeof arg === 'function' ? arg({ theme, ...props }) : arg
      Object.assign(styles, style)
    })

    if (!shouldForwardProps) {
      for (let key in props) {
        if (!isPropValid(key)) continue
        nextProps[key] = props[key]
      }
    }

    return jsx(as || tag, {
      ...nextProps,
      ref,
      css: styles,
    })
  })
  return Styled
github mineral-ui / mineral-ui / src / library / Dialog / styled.js View on Github external
  shouldForwardProp: (prop) => prop !== 'size' && isPropValid(prop)
})(({ size, theme: baseTheme }) => {
github mineral-ui / mineral-ui / src / library / Box / styled.js View on Github external
shouldForwardProp: (prop) =>
    ['height', 'width'].indexOf(prop) === -1 && isPropValid(prop)
})(({ breakpoints, height, inline, theme, width, ...restProps }) => {

@emotion/is-prop-valid

A function to check whether a prop is valid for HTML and SVG elements

MIT
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis

Popular @emotion/is-prop-valid functions

Similar packages