diff --git a/src/app/atoms/Input.react.js b/src/app/atoms/Input.react.js index 739a392..c90d9bd 100644 --- a/src/app/atoms/Input.react.js +++ b/src/app/atoms/Input.react.js @@ -8,7 +8,6 @@ import * as colors from '../styles/Colors'; export default class Input extends Component { static propTypes = { inheritedStyles: RPT.oneOfType([RPT.array, RPT.object]), - key: RPT.string, kind: RPT.oneOf([ 'inputDefault', 'inputSearch' diff --git a/src/app/component/Variants.react.js b/src/app/component/Variants.react.js index df4fed8..d9b9d84 100644 --- a/src/app/component/Variants.react.js +++ b/src/app/component/Variants.react.js @@ -1,12 +1,14 @@ +import _ from 'lodash'; import AtomPreview from '../atoms/AtomPreview.react'; import Component from 'react-pure-render/component'; -import {fromJS} from 'immutable'; import headingStyles from '../styles/Headings'; import Radium from 'radium'; import React, {PropTypes as RPT} from 'react'; import renderProp from '../../libraries/renderProp'; import SourceCode from './SourceCode.react'; import styles from '../styles/Sources'; +import variantChecksum from '../../libraries/variantChecksum'; +import {fromJS} from 'immutable'; @Radium export default class Variants extends Component { @@ -53,13 +55,36 @@ export default class Variants extends Component { renderEnumVariant(key, name, value) { if (typeof value === 'object') - return this.renderVariants(key, name, value.map(text => text.get('value').replace(/\'/g, ''))) + return this.renderVariants(key, name, value.map(text => text.get('value').replace(/\'/g, '')).toJS()) return null } + collectVariants(key, type, variants) { + const {atom, componentProps} = this.props + + return variants.map(variant => { + const variantProps = componentProps.set(key, variant) + + return { + atom, + key, + type, + variant, + variantProps, + checksum: variantChecksum({atom, variantProps, context: this.context}), + } + }) + } + renderVariants(key, type, variants) { const {headingColor} = this.props + const collection = this.collectVariants(key, type, variants); + const uniqCollection = _.uniqBy(collection, i => i.checksum); + + if (uniqCollection.length < 2) + return null; + return (