Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/modules / ___dist / view-container / styles / _unused / postcss.AsyncStyledComponent.js
Size: Mime:
/**
 * @deprecated
 * @file was required for postcss since it's async
 */

/*
import React from 'react'
import { EMPTY_STRING } from 'exotic'
import { fromStringToStyle } from '../deps/fromStringToStyleTag'
import { toComponentName } from '../deps/toComponentName'
import { transpileStyles } from './transpileStyles'

const styleRegistry = new Map()
const styleBlockRegistry = new Map()

function getFromRegistry(css) {
  if (css === '') {
    return false
  } else if (styleBlockRegistry.has(css)) {
    return styleBlockRegistry.get(css)
  } else {
    return false
  }
}

let hashed = 0
let HOT_RELOAD_STYLES = true

class StyledComponent extends React.Component {
  css = EMPTY_STRING
  selector = EMPTY_STRING

  static types = {
    styles: String,
    className: String.optional,
  }
  componentWillMount() {
    this.hasMounted = true
    this.loadStyles(this.props.styles)
  }
  componentWillUnmount() {
    this.hasMounted = false
  }
  loadStyles(styles) {
    // load from registry if we've already transpiled
    if (styleRegistry.has(styles)) {
      this.css = styleRegistry.get(styles)
      return Promise.resolve(true)
    }
    // transpile as needed,
    // see handle styles returns a promise,
    // and updates state
    return transpileStyles(styles, this.handleStyles)
  }
  handleStyles = css => {
    // save to global registry cache
    styleRegistry.set(this.props.styles, css)
    // set property, if observable
    this.css = css
    // if we can set state, do it
    if (this.hasMounted || HOT_RELOAD_STYLES) {
      this.setState({ css })
    }
    // successfully loaded async done
    return Promise.resolve(true)
  }
  render() {
    const found = getFromRegistry(this.css)
    if (HOT_RELOAD_STYLES) {
      hashed += 1
      const rendered = fromStringToStyle(this.css, { key: hashed })
      styleBlockRegistry.set(this.css, rendered)
      return rendered
    } else if (found) {
      return found
    } else {
      const rendered = fromStringToStyle(this.css)
      styleBlockRegistry.set(this.css, rendered)
      return rendered
    }
  }
}
function asStyledComponent(css, Target = undefined) {
  if (styleRegistry.has(css)) {
    console.warn('already had these styles connected. update state with an observable, or refresh (should connect HMR.accept to this module) ')
  }
  return <StyledComponent styles={css} data-for-component={toComponentName(Target)} />
}
export { StyledComponent, asStyledComponent }
export default asStyledComponent
*/
"use strict";