@@ -10,6 +10,35 @@ Install with [npm](https://www.npmjs.com/):
10
10
11
11
## Usage
12
12
13
+ Put ` <YourComponent /> ` into ` <TogglePattern /> ` .
14
+
15
+ ``` js
16
+ class ToggleButton extends React .Component {
17
+ render (){
18
+ return (
19
+ < TogglePattern isEditing= {this .props .isEditing }>
20
+ < LeaveEditingButton isEditing= {true } / >
21
+ < EnterEditingButton isEditing= {false } / >
22
+ < / TogglePattern>
23
+ );
24
+ }
25
+ }
26
+ ```
27
+
28
+ It means that
29
+
30
+ - if ` this.props.isEditing ` is ` true ` , show ` <LeaveEditingButton /> `
31
+ - if ` this.props.isEditing ` is ` false ` , show ` <EnterEditingButton /> `
32
+ - In the other case, show ` null `
33
+
34
+ ### ` <TogglePattern /> ` Interface
35
+
36
+ - ` <TogglePattern anyAttribute=anyValue /> `
37
+ - ` anyAttribute ` is any name.
38
+ - ` anyValue ` is any type.
39
+
40
+ ### Example
41
+
13
42
Show component that has truly attribute with ` <TogglePattern attribute /> `
14
43
15
44
``` js
@@ -36,6 +65,17 @@ Show component that match attribute and value with `<TogglePattern attribute=val
36
65
37
66
Result to ` <ComponentY /> `
38
67
68
+ Also, it is ok that ` value ` it ` string ` type.
69
+
70
+ ``` js
71
+ < TogglePattern pattern= " one" >
72
+ < ComponentX pattern= " one" / >
73
+ < ComponentY pattern= " two" / >
74
+ < / TogglePattern>
75
+ ```
76
+
77
+ Result to ` <ComponentY /> `
78
+
39
79
-----
40
80
41
81
Show component** s** that match attribute and value with ` <TogglePattern attribute=value /> ` .
@@ -62,6 +102,8 @@ Not show when not match
62
102
63
103
Result to ` null ` .
64
104
105
+
106
+
65
107
## Changelog
66
108
67
109
See [ Releases page] ( https://github.com/azu/react-toggle-pattern/releases ) .
0 commit comments