<commit_before>import React from 'react';
import View from './View';
import CSS from './utils/css';

CSS.register({
  '.view.icon': {
    position: 'relative',
    alignItems: 'center',
  }
});

export default class Icon extends View {

  static propTypes = {
    ...View.propTypes,
    // Use stroke rather than fill color
    outline: React.PropTypes.bool,
    // color is a CSS color value (default is to calculate the color from the palette)
    color: React.PropTypes.string,
  }

  getBackgroundColor(){
    return 'transparent';
  }

  getClassNames(){
    let cs = super.getClassNames();
    cs.icon = true;
    return cs;
  }

  // Extend this
  getSVG(){
    return <svg viewBox="0 0 48 48"></svg>;
  }

  // getSize of the icon to display. Unless overrided by size prop
  // icon size is determined by container size and scale
  getSize(){
    // user set fixed size
    let size = super.getSize();
    if( typeof size == 'number' ){
      return size * this.getScale();
    }
    // The 'intrinsic' size of an icon is to maintain the aspect ratio
    // of the cross-axis ie. if container's height=10 then icon's width=10
    if( this.props.size == 'intrinsic' ){
      let parent = this.getParent();
      if( parent ){
        let parentSize = parent.getSize();
        if( typeof parentSize == 'number' ){
          return parentSize;
        }
      }
    }
    return 1.6 * this.getScale();
  }

  getColor(){
    if( this.props.color ){
      return this.props.color;
    }
    return this.getTheme().getColoredTextColor(false, this.getLayer(), this.getTopLayer(), 'primary');
  }

  getBorderWidth(){
    return this.getTheme().getBorderWidth();
  }

  render(){
    let style = {
      padding: this.getBorderWidth(),
    };
    if( this.props.outline ){
      style.stroke = this.getColor();
      style.strokeWidth = this.getBorderWidth();
      style.fill = this.getBackgroundColor();<commit_msg>update icon sizing after parent change<commit_after>import React from 'react';
import View from './View';
import CSS from './utils/css';

CSS.register({
  '.view.icon': {
    position: 'relative',
    alignItems: 'center',
  }
});

export default class Icon extends View {

  static propTypes = {
    ...View.propTypes,
    // Use stroke rather than fill color
    outline: React.PropTypes.bool,
    // color is a CSS color value (default is to calculate the color from the palette)
    color: React.PropTypes.string,
  }

  getBackgroundColor(){
    return 'transparent';
  }

  getClassNames(){
    let cs = super.getClassNames();
    cs.icon = true;
    return cs;
  }

  // Extend this
  getSVG(){
    return <svg viewBox="0 0 48 48"></svg>;
  }

  // getSize of the icon to display. Unless overrided by size prop
  // icon size is determined by container size and scale
  getSize(){
    // user set fixed size
    let size = super.getSize();
    if( typeof size == 'number' ){
      return size * this.getScale();
    }
    // The 'intrinsic' size of an icon is to maintain the aspect ratio
    // of the cross-axis ie. if container's height=10 then icon's width=10
    if( this.props.size == 'intrinsic' ){
      if( this.context && this.context.size ){
        let parentSize = this.context.size;
        if( typeof parentSize == 'number' ){
          return parentSize;
        }
      }
    }
    return 1.6 * this.getScale();
  }

  getColor(){
    if( this.props.color ){
      return this.props.color;
    }
    return this.getTheme().getColoredTextColor(false, this.getLayer(), this.getTopLayer(), 'primary');
  }

  getBorderWidth(){
    return this.getTheme().getBorderWidth();
  }

  render(){
    let style = {
      padding: this.getBorderWidth(),
    };
    if( this.props.outline ){
      style.stroke = this.getColor();
      style.strokeWidth = this.getBorderWidth();
      style.fill = this.getBackgroundColor();
{'fraction_non_alphanumeric': 0.13103269330565645, 'fraction_numerical': 0.006227296315516347, 'mean_word_length': 2.5860465116279068, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7094594', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1149, 'n_words': 352}