<commit_before><!DOCTYPE html>
<!--
 .................................................................................................
:::BSDB'::BSDB'::BSDB':::::BSDB':::BSDBS'::BSDBS'::BSDB'::::BSD'::BSDBS'::BSDBS'::BSDB'::::::BSD'::
::BSDBSD BSDBSD :.BSDBS':BSDBS .:BSD ..BSD  ...BSD 'BSDBS':BSD .BSD ..BSD  ...BSD :BSDBS'::BSDB .::
::COPYRIGHT2017 ::.BS BSDB .BS :BSD .::.BSD :::.BSD :BS .BSDB .BSD .:::BSD ::::BSD :BS BSDB BS .:::
:::BSDSTYLEBSD .:::BS  BS .:BS :BSD ::::BSD ::::BSD :BS ::BSD :BSD :::::...::::BSD :BS :BS  BS ::::
::::.LICENSE .::::BSD .:..::BS 'BSD ::::BSD ::::BSD :BS :::BS :BSD ::BSDBS'::::BSD :BS ::..:BS ':::
:::::::BSD .::::BSDB .::::::BSD 'BSD'::BSD .:::BSD .BSD :::BSD':BSD'::.BSD :::BSD .BSD :::::BSDB'::
::::::::B .::::::BS .:::::::.BSD ::BSDBS .:BSDBS  :BSD .::::BSD :.BSDBS BS BSDB .:BSD .:::::.BS .::
`::::::::.::::::::..::::::::::...:::.....:::.....:::...::::::...:::.............:::...::::::::..::'
-->

<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="mg-common-styles.html">
<link rel="import" href="mg-input.html">

<dom-module id="mg-variant-cell">
<template strip-whitespace>
    <custom-style>
  <style is="custom-style" include="mg-common-styles iron-flex iron-flex-alignment">

  :host {
    display: inline-block;
    @apply --layout-horizontal;
    @apply --layout-end;
    @apply --layout-end-justified;
    border-radius: 5px;
  }

  :host(.iron-selected) {
    background-color: rgba(255,99,71, 0.2);
  }

  paper-icon-button {
    width: 37px;
  }

  :host(:not(.iron-selected)) #input {
    pointer-events: none;
  }

  </style>
    </custom-style>

  <mg-input
    id="input"
    value="{{variant.data}}"
    label="[[_formatLabel(variantType.name,variantType.custom)]]"
    min-width="176"
    icon="[[_formatIconType(variantType.name,variantType.custom)]]"
  > <template is="dom-if" if="[[hasChildren]]">
      <iron-icon slot="suffix" style="color:tomato" icon="chevron-right"></iron-icon>
    </template>
    <template is="dom-if" if="[[!hasChildren]]">
      <iron-icon slot="suffix" style="color:tomato"></iron-icon>
    </template>
  </mg-input>


</template>
<script>
class MGVariantCell extends Polymer.Element {
  static get is() { return 'mg-variant-cell'; }

  static get properties() { return {
    variant: {
      type: Object,
      notify: true,
    },
    variantType: {
      type: String,
    },
    selected: {
      type: Boolean,
      value: false,
      observer: '_selectedChanged'
    },
    hasChildren: {
      type: Boolean,
      value: false,
    },
  }}

  static get observers() { return [
    '_variantsChanged(variant.variants)',
  ]}

  _selectedChanged(selected) {
    if (selected) {
      this.$.input.focus();
    }
  }

  _variantsChanged(variants) {
    this.set('hasChildren',variants ? true : false);
  }

  _formatIconType(name,custom) {
    if (name == 'price') {
      switch (custom) {
        case 'usd':
          return 'editor:attach-money';
        default:
          return 'booed:attach-money-'+custom;
      }
    }
    return null;
  }

  _formatLabel(name,custom) {
    if (name == 'price' || name == 'custom') {
      return name+":"+custom;
    }
    return name;
  }

}

customElements.define(MGVariantCell.is, MGVariantCell);

</script>
</dom-module>
<commit_msg>Makes use of new color picker.<commit_after><!DOCTYPE html>
<!--
 .................................................................................................
:::BSDB'::BSDB'::BSDB':::::BSDB':::BSDBS'::BSDBS'::BSDB'::::BSD'::BSDBS'::BSDBS'::BSDB'::::::BSD'::
::BSDBSD BSDBSD :.BSDBS':BSDBS .:BSD ..BSD  ...BSD 'BSDBS':BSD .BSD ..BSD  ...BSD :BSDBS'::BSDB .::
::COPYRIGHT2017 ::.BS BSDB .BS :BSD .::.BSD :::.BSD :BS .BSDB .BSD .:::BSD ::::BSD :BS BSDB BS .:::
:::BSDSTYLEBSD .:::BS  BS .:BS :BSD ::::BSD ::::BSD :BS ::BSD :BSD :::::...::::BSD :BS :BS  BS ::::
::::.LICENSE .::::BSD .:..::BS 'BSD ::::BSD ::::BSD :BS :::BS :BSD ::BSDBS'::::BSD :BS ::..:BS ':::
:::::::BSD .::::BSDB .::::::BSD 'BSD'::BSD .:::BSD .BSD :::BSD':BSD'::.BSD :::BSD .BSD :::::BSDB'::
::::::::B .::::::BS .:::::::.BSD ::BSDBS .:BSDBS  :BSD .::::BSD :.BSDBS BS BSDB .:BSD .:::::.BS .::
`::::::::.::::::::..::::::::::...:::.....:::.....:::...::::::...:::.............:::...::::::::..::'
-->

<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../bower_components/paper-swatch-picker/paper-swatch-picker.html">
<link rel="import" href="mg-common-styles.html">
<link rel="import" href="mg-input.html">
<link rel="import" href="mg-color-picker.html">

<dom-module id="mg-variant-cell">
<template strip-whitespace>
    <custom-style>
  <style is="custom-style" include="mg-common-styles iron-flex iron-flex-alignment">

  :host {
    display: block;
    @apply --layout-horizontal;
    @apply --layout-center;
    @apply --layout-justified;
    border-radius: 5px;
  }

  :host(.iron-selected) {
    background-color: rgba(255,99,71, 0.2);
  }

  paper-icon-button {
    width: 37px;
  }

  :host(:not(.iron-selected)) #input {
    pointer-events: none;
  }

  mg-color-picker {
    width: 50px;
    height: 50px;
    margin: 3px;
    border-radius: 50%;
    box-shadow: inset 1px 1px 5px var(--app-shadow-color);
  }

  </style>
    </custom-style>

  <mg-color-picker id="color-picker" value="{{variant.data}}" hidden$="[[!isColor]]">
  </mg-color-picker>
  
  <div class="flex"></div>

  <mg-input
    id="input"
    value="{{variant.data}}"
    label="[[_formatLabel(variantType.name,variantType.custom)]]"
    min-width="[[_computeInputWidth(variantType.name)]]"
    icon="[[_formatIconType(variantType.name,variantType.custom)]]"
  > <template is="dom-if" if="[[hasChildren]]">
      <iron-icon slot="suffix" style="color:tomato" icon="chevron-right"></iron-icon>
    </template>
    <template is="dom-if" if="[[!hasChildren]]">
      <iron-icon slot="suffix" style="color:tomato"></iron-icon>
    </template>
  </mg-input>

</template>
<script>
class MGVariantCell extends Polymer.Element {
  static get is() { return 'mg-variant-cell'; }

  static get properties() { return {
    variant: {
      type: Object,
      notify: true,
    },
    variantType: {
      type: String,
    },
    selected: {
      type: Boolean,
      value: false,
      observer: '_selectedChanged'
    },
    hasChildren: {
      type: Boolean,
      computed: '_computeHasChildren(variant.variants)',
    },
    isColor: {
      type: Boolean,
      computed: '_computeIsColor(variantType.name)',
    },
  }}

  static get observers() { return [
    '_dataChanged(variant.data)'
  ]}

  _dataChanged(data) {
    if (this.variantType.name == 'color') {
      this.$['color-picker'].style.backgroundColor = data;
    }
  }

  _selectedChanged(selected) {
    if (selected) {
      this.$.input.focus();
    }
  }

  _computeHasChildren(variants) {
    return variants ? true : false;
  }

  _computeIsColor(name) {
    return name == 'color' ? true : false;
  }

  _computeInputWidth(name) {
    if (name == 'color') {
      return 120;
    }
    else if (name == 'price') {
      return 150;
    }
    return 176;
  }

  _formatIconType(name,custom) {
    if (name == 'price') {
      switch (custom) {
        case 'usd':
          return 'editor:attach-money';
        default:
          return 'booed:attach-money-'+custom;
      }
    }
    return null;
  }

  _formatLabel(name,custom) {
    if (name == 'price' || name == 'custom') {
      return name+":"+custom;
    }
    return name;
  }

}

customElements.define(MGVariantCell.is, MGVariantCell);

</script>
</dom-module>

{'fraction_non_alphanumeric': 0.2592732302275871, 'fraction_numerical': 0.0067898906073179935, 'mean_word_length': 2.8240384615384615, 'pattern_counts': {'":': 2, '<': 63, '<?xml version=': 0, '>': 63, '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': '7565795', 'n_tokens_mistral': 3041, 'n_tokens_neox': 2759, 'n_words': 515}