Skip to content

Commit f19c2f9

Browse files
committed
Added new chipTheme prop:
1. as another ‘story’ 2. README 3. as another example in ‘site’
1 parent 0988107 commit f19c2f9

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class YourComponent extends Component {
5454
|`onChange`|Function||A function called when the value of chips changes, passes the chips value as an argument.|
5555
|`placeholder`|String||The placeholder to populate the input with|
5656
|`theme`|Object||A [react-themeable](https://github.com/markdalgleish/react-themeable) theme|
57+
|`chipTheme`|Object|| A [react-themeable](https://github.com/markdalgleish/react-themeable) theme that will override the default chip theme,
5758
|`suggestions`|Array||Data to fill the autocomplete list with|
5859
|`fetchSuggestions`|Function|| Delegate expecting to recive autocomplete suggestions (callback or promise)|
5960
|`fetchSuggestionsThrushold`|Number|| Maximum calls to fetchSuggestions per-second |

site/src/Root.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import React from 'react';
33
import BasicExample from './basic';
44
import CustomExample from './custom';
55
import AsyncExample from './async';
6+
import CustomChipThemeExample from './customChipTheme';
67

78
const Root = () => (
89
<div>
910
<h1>Basic</h1>
1011
<BasicExample />
1112
<h1>Custom</h1>
1213
<CustomExample />
14+
<h1>Custom Chip Theme</h1>
15+
<CustomChipThemeExample />
1316
<h1>Async</h1>
1417
<AsyncExample />
1518
</div>

site/src/customChipTheme.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { Component } from 'react';
2+
import Chips, { Chip } from '../../src'
3+
4+
const data = [
5+
'JavaScript',
6+
'Ruby',
7+
'Python',
8+
'Java',
9+
'Swift',
10+
'C++',
11+
'C',
12+
'Objective C',
13+
'Go'
14+
];
15+
16+
class CustomChipThemeExample extends Component {
17+
18+
constructor(props) {
19+
super(props);
20+
this.state = {
21+
value: []
22+
}
23+
}
24+
25+
onChange = value => {
26+
this.setState({ value });
27+
}
28+
29+
render() {
30+
return (
31+
<Chips
32+
value={this.state.value}
33+
onChange={this.onChange}
34+
chipTheme={{ chip: { margin: "3px", padding: 5, background: 'red' } }}
35+
createChipKeys={['a']}
36+
placeholder="Type a Programming Language"
37+
suggestions={data}
38+
shouldRenderSuggestions={value => value.length >= 0}
39+
fromSuggestionsOnly={false} />
40+
);
41+
}
42+
}
43+
44+
export default CustomChipThemeExample;

stories/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ storiesOf('Chips', module)
5050
highlightFirstSuggestion={true}
5151
/>
5252
))
53+
.add('Custom Chip Theme', () => (
54+
<Chips
55+
chipTheme={{ chip: { margin: "3px", padding: 5, background: 'red' } }}
56+
suggestions={suggestions}
57+
shouldRenderSuggestions={value => value.length >= 0}
58+
fromSuggestionsOnly={false} />
59+
))
5360
.add('Custom Chip', () => (
5461
<Chips
5562
placeholder="Type a Programming Language"

0 commit comments

Comments
 (0)