<commit_before>import { isRemote } from 'worona-deps';
import React from 'react';
import { connect } from 'react-redux';
import * as deps from '../../deps';

class LinkCssClass extends React.Component {
  componentDidMount() {
    this.refs.link.addEventListener('load', this.props.assetsFileDownloaded);
  }
  render() {
    const { cdn, path } = this.props;
    return (
      <link rel="stylesheet" ref="link" type="text/css" href={`${cdn}${path}`} />
    );
  }
}
LinkCssClass.propTypes = ({
  cdn: React.PropTypes.string.isRequired,
  path: React.PropTypes.string.isRequired,
  assetsFileDownloaded: React.PropTypes.func.isRequired,
});


const mapDispatchToProps = (dispatch, { path, pkgName }) => ({
  assetsFileDownloaded: () =>
    dispatch(deps.actions.packageAssetFileDownloaded({ path, pkgName, assetType: 'css' })),
});

const LinkCss = connect(null, mapDispatchToProps)(LinkCssClass);

const CssLoader = ({ cssAssets }) => {
  const cdn = isRemote ? 'https://cdn.worona.io/packages/' : 'http://localhost:4000/packages/';
  return (
    <div>
      {cssAssets.map(asset =>
        <LinkCss cdn={cdn} pkgName={asset.pkgName} path={asset.path} key={asset.path} />
      )}
    </div>
  );
};

CssLoader.propTypes = {
  cssAssets: React.PropTypes.arrayOf(React.PropTypes.shape({
    path: React.PropTypes.string,
    pkgName: React.PropTypes.string,
  })).isRequired,
};

export const mapStateToProps = state => ({
  cssAssets: deps.selectors.getCssAssets(state),
});

export default connect(mapStateToProps)(CssLoader);<commit_msg>Fix problem with remote css loading.<commit_after>import { isRemote } from 'worona-deps';
import React from 'react';
import { connect } from 'react-redux';
import * as deps from '../../deps';

class LinkCssClass extends React.Component {
  componentDidMount() {
    this.refs.link.addEventListener('load', this.props.assetsFileDownloaded);
  }
  render() {
    const { cdn, path } = this.props;
    return (
      <link rel="stylesheet" ref="link" type="text/css" href={`${cdn}${path}`} />
    );
  }
}
LinkCssClass.propTypes = ({
  cdn: React.PropTypes.string.isRequired,
  path: React.PropTypes.string.isRequired,
  assetsFileDownloaded: React.PropTypes.func.isRequired,
});


const mapDispatchToProps = (dispatch, { path, pkgName }) => ({
  assetsFileDownloaded: () =>
    dispatch(deps.actions.packageAssetFileDownloaded({ path, pkgName, assetType: 'css' })),
});

const LinkCss = connect(null, mapDispatchToProps)(LinkCssClass);

const CssLoader = ({ cssAssets }) => {
  const cdn = 'https://cdn.worona.io/packages/';
  return (
    <div>
      {cssAssets.map(asset =>
        <LinkCss cdn={cdn} pkgName={asset.pkgName} path={asset.path} key={asset.path} />
      )}
    </div>
  );
};

CssLoader.propTypes = {
  cssAssets: React.PropTypes.arrayOf(React.PropTypes.shape({
    path: React.PropTypes.string,
    pkgName: React.PropTypes.string,
  })).isRequired,
};

export const mapStateToProps = state => ({
  cssAssets: deps.selectors.getCssAssets(state),
});

export default connect(mapStateToProps)(CssLoader);
{'fraction_non_alphanumeric': 0.1630718954248366, 'fraction_numerical': 0.00130718954248366, 'mean_word_length': 4.179357021996616, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '381869', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1024, 'n_words': 184}