File tree 2 files changed +90
-1
lines changed
2 files changed +90
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ export const theme = {
91
91
default : {
92
92
background : 'royalblue' ,
93
93
color : 'white'
94
+ } ,
95
+ danger : {
96
+ background : 'red' ,
97
+ color : 'white'
98
+ } ,
99
+ success : {
100
+ background : 'lime' ,
101
+ color : 'white'
94
102
}
95
103
} ,
96
104
Input,
Original file line number Diff line number Diff line change @@ -41,12 +41,93 @@ import { Button } from 'pss-components'
41
41
### Change element
42
42
43
43
<Playground >
44
- <Button variant = ' auto' as = ' a' href = ' http://example.com' target = ' _blank' >
44
+ <Button variant = ' auto' as = ' a' href = ' http://example.com' target = ' _blank' role = ' button ' >
45
45
Button
46
46
</Button >
47
47
</Playground >
48
48
49
49
50
+ ### Default styles
51
+
52
+ You can't change reset styles in ` Button ` , as in [ Box] ( /box ) , but you can provide additional default styles for all buttons:
53
+
54
+ ``` js
55
+ import { css } from ' @emotion/core'
56
+
57
+ const myTheme = {
58
+ // All Buttons will have border-radius and padding
59
+ Button: css`
60
+ border-radius: 5px;
61
+ padding: 10px 20px;
62
+ `
63
+ }
64
+ ```
65
+
66
+ Please note that if you provide default style, you will not be able to change it with props, so I will recommend to create your own button instead:
67
+
68
+ ``` js
69
+ // /my/components/button.js
70
+ import { Button as ButtonBase } from ' pss-components'
71
+
72
+ const Button = (props ) => (
73
+ < ButtonBase
74
+ px= ' 10px'
75
+ py= ' 20px'
76
+ borderRadius= {5 }
77
+ {... props}
78
+ / >
79
+ )
80
+ ```
81
+
82
+ ### Variants
83
+
84
+ You can add ` Button ` variants to theme for consistent usage:
85
+
86
+ ``` js
87
+ const myTheme = {
88
+ buttonStyle: {
89
+ default: {
90
+ background: ' royalblue' ,
91
+ color: ' white'
92
+ },
93
+ danger: {
94
+ background: ' red' ,
95
+ color: ' white'
96
+ },
97
+ success: {
98
+ background: ' lime' ,
99
+ color: ' white'
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ <Playground >
106
+ <Button variant = ' default' >
107
+ Default
108
+ </Button >
109
+ </Playground >
110
+
111
+ Auto is same as ` default ` , but dynamic (see [ ThemeDefaults] ( /theme-defaults ) )
112
+
113
+ <Playground >
114
+ <Button variant = ' auto' >
115
+ Auto
116
+ </Button >
117
+ </Playground >
118
+
119
+ <Playground >
120
+ <Button variant = ' danger' >
121
+ Danger
122
+ </Button >
123
+ </Playground >
124
+
125
+ <Playground >
126
+ <Button variant = ' success' >
127
+ Success
128
+ </Button >
129
+ </Playground >
130
+
50
131
## Props
51
132
52
133
<PropsTable of = { Button } />
You can’t perform that action at this time.
0 commit comments