How to use substyle - 10 common examples

To help you get started, we’ve selected a few substyle 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 jfschwarz / substyle / packages / substyle-jss / src / createPropsDecorator.js View on Github external
const decorateProps = stylingProps => {
    const decoratedStylingProps = defaultPropsDecorator(stylingProps)
    const { style, className: baseClassName, ...rest } = decoratedStylingProps

    if (!style) {
      return decoratedStylingProps
    }

    const ruleName = hash(style)

    // prepend rule to the sheet if it does not already exist
    const rule =
      sheet.getRule(ruleName) ||
      sheet.addRule(ruleName, mapPseudoSelectors(style), { index: 0 })

    const className = rule.options.classes[ruleName]

    return {
github signavio / react-mentions / src / MentionsInput.js View on Github external
/**
 * Returns the computed length property value for the provided element.
 * Note: According to spec and testing, can count on length values coming back in pixels. See https://developer.mozilla.org/en-US/docs/Web/CSS/used_value#Difference_from_computed_value
 */
const getComputedStyleLengthProp = (forElement, propertyName) => {
  const length = parseFloat(
    window.getComputedStyle(forElement, null).getPropertyValue(propertyName)
  )
  return isFinite(length) ? length : 0
}

const isMobileSafari =
  typeof navigator !== 'undefined' &&
  /iPhone|iPad|iPod/i.test(navigator.userAgent)

const styled = defaultStyle(
  {
    position: 'relative',
    overflowY: 'visible',

    input: {
      display: 'block',
      position: 'absolute',
      top: 0,
      left: 0,
      boxSizing: 'border-box',
      backgroundColor: 'transparent',
      width: 'inherit',
      fontFamily: 'inherit',
      fontSize: 'inherit',
      letterSpacing: 'inherit',
    },
github signavio / react-mentions / src / Suggestion.js View on Github external
if (i === -1) {
      return <span>{display}</span>
    }

    return (
      <span>
        {display.substring(0, i)}
        <b>{display.substring(i, i + query.length)}</b>
        {display.substring(i + query.length)}
      </span>
    )
  }
}

const styled = defaultStyle(
  {
    cursor: 'pointer',
  },
  props =&gt; ({ '&amp;focused': props.focused })
)

export default styled(Suggestion)
github jfschwarz / substyle / packages / example-page / src / ExampleComponent.js View on Github external
type PropsT = {
  style: Substyle,
}

function ExampleComponent({ style }: PropsT) {
  return (
    <div>
      <h1>Title</h1>

      <div>Some text...</div>
    </div>
  )
}

const enhance = defaultStyle({
  title: {
    fontSize: 20,
  },
})

export default enhance(ExampleComponent)
github signavio / react-mentions / src / Highlighter.js View on Github external
renderHighlighterCaret(children) {
    return (
      <span> {
          this.caretRef = el
        }}
        key="caret"
      &gt;
        {children}
      </span>
    )
  }
}

const styled = defaultStyle(
  {
    position: 'relative',
    width: 'inherit',
    color: 'transparent',

    overflow: 'hidden',

    whiteSpace: 'pre-wrap',
    wordWrap: 'break-word',

    '&amp;singleLine': {
      whiteSpace: 'pre',
      wordWrap: null,
    },

    substring: {
github signavio / react-mentions / src / SuggestionsOverlay.js View on Github external
return 
  }

  handleMouseEnter(index, ev) {
    if (this.props.onMouseEnter) {
      this.props.onMouseEnter(index)
    }
  }

  select(suggestion, queryInfo) {
    this.props.onSelect(suggestion, queryInfo)
  }
}

const styled = defaultStyle(({ position }) =&gt; ({
  position: 'absolute',
  zIndex: 1,
  backgroundColor: 'white',
  marginTop: 14,
  minWidth: 100,
  ...position,

  list: {
    margin: 0,
    padding: 0,
    listStyleType: 'none',
  },
}))

export default styled(SuggestionsOverlay)
github signavio / react-mentions / src / Mention.js View on Github external
import React, { PropTypes } from 'react';
import { defaultStyle } from 'substyle';

const styled = defaultStyle({
  fontWeight: "inherit"
});

const Mention = styled(({ display, style }) =&gt; (
  <strong>
    { display }
  </strong>
));

Mention.propTypes = {
  /**
   * Called when a new mention is added in the input
   *
   * Example:
   *
   * ```js
github jfschwarz / substyle / packages / substyle-jss / src / injectSheet.js View on Github external
const SubstyleJss = ({ classes, sheet, style, className, ...rest }) => {
      return createElement(WrappedComponent, {
        style: createSubstyle(
          {
            style,
            className,
            classNames: classes,
          },
          createPropsDecorator(sheet)
        ),
        ...rest,
      })
    }
github jfschwarz / substyle / packages / substyle-glamor / src / index.js View on Github external
export const asDataClasses = style =>
  createSubstyle({ style }, decorateAsClasses)
github jfschwarz / substyle / packages / substyle-glamor / src / index.js View on Github external
export const asDataAttributes = style =>
  createSubstyle({ style }, decorateAsDataAttributes)

substyle

Universal styling for reusable React components

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis