You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* accept styles as a function
* fix error
* update typings
* add test for function
* remove console.log
* fix typings
* avoid using custom styles
* update documentation
* update customized example
* add cooment in example
* typo in documentation
Co-Authored-By: Artem Sapegin <[email protected]>
* force rebuild for testing
Copy file name to clipboardExpand all lines: docs/Configuration.md
+34-17Lines changed: 34 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -599,12 +599,29 @@ Folder for static HTML style guide generated with `styleguidist build` command.
599
599
600
600
#### `styles`
601
601
602
-
Type: `object`, optional
602
+
Type: `Object` or `Function`, optional
603
603
604
604
Customize styles of any Styleguidist’s component.
605
605
606
606
See example in the [cookbook](Cookbook.md#how-to-change-styles-of-a-style-guide).
607
607
608
+
> **Note:** Using a function allows access to theme variables as seen in the example below. See available [theme variables](https://github.com/styleguidist/react-styleguidist/blob/master/src/client/styles/theme.ts). The returned object folows the same format as when configured as a litteral.
609
+
610
+
```javascript
611
+
module.exports= {
612
+
styles:function(theme) {
613
+
return {
614
+
Logo: {
615
+
logo: {
616
+
// we can now change the color used in the logo item to use the theme's `link` color
617
+
color:theme.color.link
618
+
}
619
+
}
620
+
}
621
+
}
622
+
}
623
+
```
624
+
608
625
#### `template`
609
626
610
627
Type: `Object` or `Function`, optional.
@@ -690,22 +707,22 @@ Function that modifies code example (Markdown fenced code block). For example, y
Copy file name to clipboardExpand all lines: docs/Cookbook.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,6 +266,23 @@ module.exports = {
266
266
267
267
> **Note:** Use [React Developer Tools](https://github.com/facebook/react) to find component and style names. For example a component `<LogoRenderer><h1 className="rsg--logo-53">` corresponds to an example above.
268
268
269
+
> **Note:** Use a function instead of an object for [styles](Configuration.md#styles) to access all heme variables in your custom styles.
270
+
271
+
```javascript
272
+
module.exports= {
273
+
styles:function(theme) {
274
+
return {
275
+
Logo: {
276
+
logo: {
277
+
// we can now change the color used in the logo item to use the theme's `link` color
278
+
color:theme.color.link
279
+
}
280
+
}
281
+
}
282
+
}
283
+
}
284
+
```
285
+
269
286
## How to change the layout of a style guide?
270
287
271
288
You can replace any Styleguidist React component. But in most of the cases you’ll want to replace `*Renderer` components — all HTML is rendered by these components. For example `ReactComponentRenderer`, `ComponentsListRenderer`, `PropsRenderer`, etc. — [check the source](https://github.com/styleguidist/react-styleguidist/tree/master/src/client/rsg-components) to see what components are available.
0 commit comments