|
6 | 6 |
|
7 | 7 | ## Making class-based themed components |
8 | 8 |
|
9 | | -Make a component themeable with the [withStyle](#withStyle) decorator. It adds a `makeStyles` function and the generated `styles` object to the decorated Component's props. |
| 9 | +Make a component themeable with the [withStyle](withStyle) decorator. It adds a `makeStyles` function and the generated `styles` object to the decorated Component's props. |
10 | 10 |
|
11 | 11 | Import the style generator (`generateStyle`) from `styles.js` and the component theme generator (`generateComponentTheme`) from `theme.js`, and pass them to the decorator. |
12 | 12 |
|
@@ -87,14 +87,14 @@ const generateComponentTheme = (theme) => { |
87 | 87 | export default generateComponentTheme |
88 | 88 | ``` |
89 | 89 |
|
90 | | -The arguments to the generator function are the [global theme variables](#canvas). In the above example, we've defined the default theme for the Button component. |
| 90 | +The arguments to the generator function are the [global theme variables](canvas). In the above example, we've defined the default theme for the Button component. |
91 | 91 |
|
92 | 92 | The purpose of the generator function is to take the global variables and apply them as values to the functional component level variables. |
93 | 93 | When coming up with names for the component level variables, try to make them describe how they are used in the component (vs describing the variable value). |
94 | 94 |
|
95 | 95 | ### Supporting multiple themes |
96 | 96 |
|
97 | | -If we want to make the Button transform the global theme variables differently with another theme, (e.g. [canvas-high-contrast](#canvas-high-contrast)) we can make specific styling for that theme: |
| 97 | +If we want to make the Button transform the global theme variables differently with another theme, (e.g. [canvas-high-contrast](canvas-high-contrast)) we can make specific styling for that theme: |
98 | 98 |
|
99 | 99 | ```js |
100 | 100 | --- |
@@ -134,7 +134,7 @@ The rest of the variables will pick up from the default Button theme generator ( |
134 | 134 |
|
135 | 135 | In the `styles.js` file, the `generateStyle` method receives the theme variable object (`componentTheme`) generated by `theme.js`. |
136 | 136 |
|
137 | | -Add your styling for each element in the component, and give them [labels](https://emotion.sh/docs/labels#gatsby-focus-wrapper) for easy readability and targetability. _Naming convention_: similar to [BEM naming convention](#http://getbem.com/naming/), use the name of the component in camelCase for the root element ('button'), and the double underscore suffix for children ('button\_\_icon'). |
| 137 | +Add your styling for each element in the component, and give them [labels](https://emotion.sh/docs/labels#gatsby-focus-wrapper) for easy readability and targetability. _Naming convention_: similar to [BEM naming convention](http://getbem.com/naming/), use the name of the component in camelCase for the root element ('button'), and the double underscore suffix for children ('button\_\_icon'). |
138 | 138 |
|
139 | 139 | Use [Emotion's Object Styles documentation](https://emotion.sh/docs/object-styles) as a guide to add styles. |
140 | 140 |
|
|
0 commit comments