diff --git a/src/ChipInput.js b/src/ChipInput.js index faa9cd4..035e402 100644 --- a/src/ChipInput.js +++ b/src/ChipInput.js @@ -13,6 +13,7 @@ import FormHelperText from 'material-ui/Form/FormHelperText' import cx from 'classnames' const styles = (theme) => ({ + root: {}, inputRoot: { display: 'inline-block', marginTop: 0 @@ -99,18 +100,18 @@ const styles = (theme) => ({ backgroundColor: theme.palette.error.A400, transform: 'scaleX(1)' // error is always underlined in red } + }, + chip: { + margin: '0 8px 8px 0', + float: 'left' } }) -const defaultChipStyle = { - margin: '0 8px 8px 0', - float: 'left' -} - -const defaultChipRenderer = ({ value, text, isFocused, isDisabled, handleClick, handleRequestDelete, defaultStyle }, key) => ( +const defaultChipRenderer = ({ value, text, isFocused, isDisabled, handleClick, handleRequestDelete, className }, key) => ( this.setState({ focusedChip: i }), handleRequestDelete: () => this.handleDeleteChip(value, i), - defaultStyle: defaultChipStyle + className: classes.chip }, i) })} { value: 'a', text: 'a', chip: 'a', + className: expect.any(String), isDisabled: false, isFocused: false, handleClick: expect.any(Function), - handleRequestDelete: expect.any(Function), - defaultStyle: expect.any(Object) + handleRequestDelete: expect.any(Function) }) }) }) diff --git a/src/__snapshots__/ChipInput.spec.js.snap b/src/__snapshots__/ChipInput.spec.js.snap index d86b826..408f5ba 100644 --- a/src/__snapshots__/ChipInput.spec.js.snap +++ b/src/__snapshots__/ChipInput.spec.js.snap @@ -13,18 +13,20 @@ exports[`uncontrolled mode matches the snapshot 1`] = ` allowDuplicates={false} classes={ Object { - "chipContainer": "ChipInput-chipContainer-3", - "disabled": "ChipInput-disabled-10", - "error": "ChipInput-error-12", - "focused": "ChipInput-focused-9", - "helperText": "ChipInput-helperText-7", - "inkbar": "ChipInput-inkbar-8", - "input": "ChipInput-input-2", - "inputRoot": "ChipInput-inputRoot-1", - "label": "ChipInput-label-5", - "labelShrink": "ChipInput-labelShrink-6", - "labeled": "ChipInput-labeled-4", - "underline": "ChipInput-underline-11", + "chip": "ChipInput-chip-14", + "chipContainer": "ChipInput-chipContainer-4", + "disabled": "ChipInput-disabled-11", + "error": "ChipInput-error-13", + "focused": "ChipInput-focused-10", + "helperText": "ChipInput-helperText-8", + "inkbar": "ChipInput-inkbar-9", + "input": "ChipInput-input-3", + "inputRoot": "ChipInput-inputRoot-2", + "label": "ChipInput-label-6", + "labelShrink": "ChipInput-labelShrink-7", + "labeled": "ChipInput-labeled-5", + "root": "ChipInput-root-1", + "underline": "ChipInput-underline-12", } } clearOnBlur={true} @@ -41,15 +43,17 @@ exports[`uncontrolled mode matches the snapshot 1`] = ` } >
foo
bar
+ ) + } +} + +export default withStyles(styles)(CustomChipInput) diff --git a/stories/index.js b/stories/index.js index e344919..629d405 100644 --- a/stories/index.js +++ b/stories/index.js @@ -6,6 +6,7 @@ import Chip from 'material-ui/Chip' // import AutoComplete from 'material-ui/AutoComplete' import { green } from 'material-ui/colors' import ChipInput from '../src/ChipInput' +import CustomizedChipInput from './CustomizedChipInput' // import ControlledChipInput from './ControlledChipInput' // import ClipboardExample from './ClipboardExample' @@ -29,16 +30,9 @@ storiesOf('ChipInput', module) fullWidth /> ) - /* - .add('with custom chip container styles', () => - `Chip ${c}`)} - /> + .add('with custom styles', () => + ) - */ .add('with placeholder', () =>