File tree 4 files changed +55
-0
lines changed
4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class YourComponent extends Component {
54
54
| ` onChange ` | Function| ✓| A function called when the value of chips changes, passes the chips value as an argument.|
55
55
| ` placeholder ` | String|| The placeholder to populate the input with|
56
56
| ` 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,
57
58
| ` suggestions ` | Array|| Data to fill the autocomplete list with|
58
59
| ` fetchSuggestions ` | Function|| Delegate expecting to recive autocomplete suggestions (callback or promise)|
59
60
| ` fetchSuggestionsThrushold ` | Number|| Maximum calls to fetchSuggestions per-second |
Original file line number Diff line number Diff line change @@ -3,13 +3,16 @@ import React from 'react';
3
3
import BasicExample from './basic' ;
4
4
import CustomExample from './custom' ;
5
5
import AsyncExample from './async' ;
6
+ import CustomChipThemeExample from './customChipTheme' ;
6
7
7
8
const Root = ( ) => (
8
9
< div >
9
10
< h1 > Basic</ h1 >
10
11
< BasicExample />
11
12
< h1 > Custom</ h1 >
12
13
< CustomExample />
14
+ < h1 > Custom Chip Theme</ h1 >
15
+ < CustomChipThemeExample />
13
16
< h1 > Async</ h1 >
14
17
< AsyncExample />
15
18
</ div >
Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ storiesOf('Chips', module)
50
50
highlightFirstSuggestion = { true }
51
51
/>
52
52
) )
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
+ ) )
53
60
. add ( 'Custom Chip' , ( ) => (
54
61
< Chips
55
62
placeholder = "Type a Programming Language"
You can’t perform that action at this time.
0 commit comments