How to use the theming.channel function in theming

To help you get started, we’ve selected a few theming 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 skbkontur / retail-ui / packages / retail-ui / components / internal / JssStyled.js View on Github external
}
  return defaultTheme;
};

type Props = {
  styles: Styles,
  // eslint-disable-next-line flowtype/no-weak-types
  children: (classes: any) => React.Node
};

const createStylesCreator = (styles: Styles) =>
  typeof styles === 'function' ? styles : (theme: mixed) => styles;

class JssStyled extends React.Component {
  static contextTypes = {
    [theming.channel]: PropTypes.object
  };

  static _sheetsManager = new Map();
  _unsubscribe = null;
  _theme = null;
  _broadcast = brcast();
  _stylesCreator;

  get _inThemeContext() {
    return !!this.context[theming.channel];
  }

  constructor(props: Props, context: mixed) {
    super(props, context);
    this._theme = this._getThemeFromContext() || getDefaultTheme();
github skbkontur / retail-ui / components / internal / JssStyled.js View on Github external
componentDidMount() {
    if (this._inThemeContext) {
      this._unsubscribe = this.context[theming.channel].subscribe(theme => {
        const oldTheme = this._theme;
        this._theme = theme;
        this._attach(this._theme);
        this.forceUpdate(() => {
          this._detach(oldTheme);
        });
      });
    }
  }
github skbkontur / retail-ui / components / internal / JssStyled.js View on Github external
_getThemeFromContext = () =>
    this.context[theming.channel] && this.context[theming.channel].getState();
github skbkontur / retail-ui / packages / retail-ui / components / internal / JssStyled.js View on Github external
_getThemeFromContext = () =>
    this.context[theming.channel] && this.context[theming.channel].getState();