How to use @emotion/is-prop-valid - 10 common examples

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 callstack / linaria / src / react / styled.js View on Github external
const render = (props, ref) => {
      const { as: component = tag, class: className, ...rest } = props;

      let filteredProps;

      // Check if it's an HTML tag and not a custom element
      if (typeof component === 'string' && component.indexOf('-') === -1) {
        filteredProps = {};

        // eslint-disable-next-line guard-for-in
        for (const key in rest) {
          if (key === 'as' || validAttr(key)) {
            // Don't pass through invalid attributes to HTML elements
            filteredProps[key] = rest[key];
          }
        }
      } else {
        filteredProps = rest;
      }

      filteredProps.ref = ref;
      filteredProps.className = cx(
        filteredProps.className || className,
        options.class
      );

      const { vars } = options;
github framer / motion / src / motion / functionality / dom.tsx View on Github external
isPropValid = (key: string) => {
        // Handle events explicitly as Emotion validates them all as true
        if (key.startsWith("on")) {
            return !isValidMotionProp(key)
        } else {
            return emotionIsPropValid(key)
        }
    }
} catch {
github styled-system / styled-system / packages / should-forward-prop / index.js View on Github external
module.exports = memoize(prop => isPropValid(prop) && !regex.test(prop))
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),
  })(

@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