@@ -42,7 +42,7 @@ as a new entry into the history stack;
42
42
the button. It is supposed to control button size, and although any values can
43
43
be used, it is recommended to stick with ` xs ` , ` sm ` , ` md ` , ` lg ` , and ` xl ` size
44
44
labels, with ` md ` size being the default, when no ` size ` property is passed in;
45
- - ** ` theme ` ** &mdash ; * Object* &mdash ; Button theme. This object is
45
+ - ** ` theme ` ** &mdash ; * Object* &mdash ; Optional. Button theme. This object is
46
46
supposed to have the following fields:
47
47
- ** ` button ` ** &mdash ; * String* &mdash ; The class to apply to the root element
48
48
of the button in all cases;
@@ -64,132 +64,11 @@ URL/location.
64
64
effect only when Button is rendered as ` <button> ` .
65
65
66
66
### <a name =" examples " >Examples</a >
67
- First of all, you want to define button theme, here is a good example to start from:
68
- ``` scss
69
- // theme.scss
70
-
71
- /* Base button style (medium size). */
72
- .button {
73
- align-items : center ;
74
- background : while;
75
- border : solid 1px black ;
76
- color : black ;
77
- display : inline-flex ;
78
- font : normal 15px arial ;
79
- justify-content : center ;
80
- min-height : 40px ;
81
- margin : 5px ;
82
- padding : 5px 23px ;
83
- vertical-align : middle ;
84
- }
85
-
86
- /* Extra styling for the disabled buttons. */
87
- .disabled {
88
- cursor : not-allowed ;
89
- opacity : 0.3 ;
90
- }
91
-
92
- /* .link and .regular classes are applied only to active buttons and button-like
93
- * links. Here we provide visual feedback for button "active", "focus", and
94
- * "hover" states. */
95
- .link ,
96
- .regular {
97
- /* To ensure that visited button-like links look the same as the non-visited
98
- * ones (as typical buttons should not look different if they used to be clicked
99
- * before). */
100
- & :visited {
101
- color : black ;
102
- font : normal 15px arial ;
103
- }
104
-
105
- & :focus {
106
- box-shadow : 0 0 2px 1px #cfe6ff ;
107
- border-color : #59a7ff ;
108
- outline : none ;
109
- }
110
-
111
- & :hover {
112
- background-image : linear-gradient (to top , #f5f5f5 , white 49% , white );
113
- border-color : $tc-gray-40 ;
114
- }
115
-
116
- /* We need both ":active" selector and ".active" class here, if we want to
117
- * properly support the "active" option of the <Button>. */
118
- & .active ,
119
- & :active {
120
- background-image : linear-gradient (to bottom , #f5f5f5 , white 49% , white );
121
- box-shadow : inset 0 1px 2px 0 rgba (0 , 0 , 0 , 0.2 );
122
- border-color : $tc-gray-40 ;
123
- }
124
- }
125
-
126
- /* And a few extra classes to support "xs", "sm", and "lg" button sizes. */
127
- .xs {
128
- font : normal 11px arial ;
129
- min-height : 20px ;
130
- padding : 1px 13px ;
131
- }
132
-
133
- .sm {
134
- font : normal 13px arial ;
135
- min-height : 30px ;
136
- padding : 4px 18px ;
137
- }
138
-
139
- .lg {
140
- font : normal 17px arial ;
141
- min-height : 50px ;
142
- padding : 5px 28px ;
143
- }
144
- ```
145
-
146
- You can apply this theme directly to your ` <Button> ` , but it is more
147
- convenient to use
148
- [ react-css-super-themr] ( https://www.npmjs.com/package/react-css-super-themr )
149
- for management of the button default / context / and ad-hoc theming. To use it,
150
- you should wrap the ` <Button> ` component with ` themr(..) ` decorator:
151
67
``` jsx
152
- // ThemedButton.js
153
- import { Button } from ' topcoder-react-utils' ;
154
- import { themr } from ' react-css-super-themr' ;
155
- import theme from ' ./theme.scss' ;
156
-
157
- export default const ThemedButton = themr (' ThemedButton' , theme)(Button);
158
- ```
159
-
160
- Now you can use the button in your code in multiple ways:
161
- ``` js
162
68
import React from ' react' ;
163
- import { ThemeProvider } from ' react-css-super-themr' ;
164
- import Button from ' ./ThemedButton' ;
165
-
166
- // Some themes we want to use for the ad-hoc and context theming.
167
- import adHocTheme from ' ./adHocStyle.scss' ;
168
- import contextTheme from ' ./contextTheme' ;
69
+ import { Button } from ' topcoder-react-utils' ;
169
70
170
71
export default function Example () {
171
- return (
172
- < div>
173
- < Button
174
- // Button with the default theme.
175
- onClick= {() => console .log (' Clicked!' )}
176
- > Click Me! < / Button>
177
-
178
- < Button
179
- // Button-like link with ad-hoc theming.
180
- theme= {adHocTheme}
181
- to= " https://www.topcoder.com"
182
- > Click Me! < / Button>
183
-
184
- < ThemeProvider
185
- theme= {{ ThemedButton: contextTheme }}
186
- >
187
- < Button
188
- // Button with context theming.
189
- onClick= {() => console .log (' Clicked!' )}
190
- > Click Me! < / Button>
191
- < / ThemeProvider>
192
- < / div>
193
- );
72
+ return < Button to= " https://topcoder.com" > Simple Button< / Button> ;
194
73
}
195
74
```
0 commit comments