Skip to content

Commit 88724cd

Browse files
committed
Docs: Update examples syntax
1 parent c944683 commit 88724cd

File tree

21 files changed

+96
-50
lines changed

21 files changed

+96
-50
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<CounterButton/>
1+
```js
2+
<CounterButton/>
3+
```
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
Each example has its own state that you can access at the `state` variable and change with the `setState` function. Default state is `{}`.
22

3-
<div>
4-
<button onClick={() => setState({isOpen: true})}>Open</button>
5-
<Modal isOpen={state.isOpen}>
6-
<h1>Hallo!</h1>
7-
<button onClick={() => setState({isOpen: false})}>Close</button>
8-
</Modal>
9-
</div>
3+
```jsx
4+
<div>
5+
<button onClick={() => setState({isOpen: true})}>Open</button>
6+
<Modal isOpen={state.isOpen}>
7+
<h1>Hallo!</h1>
8+
<button onClick={() => setState({isOpen: false})}>Close</button>
9+
</Modal>
10+
</div>
11+
```
1012

1113
If you want to set the default state you can do something like that:
1214

13-
initialState = {count: 1};
14-
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
15+
```jsx
16+
initialState = {count: 1};
17+
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
18+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
You can `require` external files in your examples:
22

3-
const names = require('dog-names').all;
4-
<RandomButton variants={names}/>
3+
```jsx
4+
const names = require('dog-names').all;
5+
<RandomButton variants={names}/>
6+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Enhanced/Decorated components work as well:
22

3-
<WrappedButton>I'm a wrapped button</WrappedButton>
3+
```jsx
4+
<WrappedButton>I'm a wrapped button</WrappedButton>
5+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
You can `require` external files in your examples:
22

3-
const names = require('dog-names').all;
4-
<RandomButton variants={names}/>
3+
```jsx
4+
const names = require('dog-names').all;
5+
<RandomButton variants={names}/>
6+
```
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
Each example has its own state that you can access at the `state` variable and change with the `setState` function. Default state is `{}`.
22

3-
<div>
4-
<button onClick={() => setState({isOpen: true})}>Open</button>
5-
<Modal isOpen={state.isOpen}>
6-
<h1>Hallo!</h1>
7-
<button onClick={() => setState({isOpen: false})}>Close</button>
8-
</Modal>
9-
</div>
3+
```jsx
4+
<div>
5+
<button onClick={() => setState({isOpen: true})}>Open</button>
6+
<Modal isOpen={state.isOpen}>
7+
<h1>Hallo!</h1>
8+
<button onClick={() => setState({isOpen: false})}>Close</button>
9+
</Modal>
10+
</div>
11+
```
1012

1113
If you want to set the default state you can do something like that:
1214

13-
initialState = {count: 1};
14-
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
15+
```jsx
16+
initialState = {count: 1};
17+
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
18+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
You can `require` external files in your examples:
22

3-
const names = require('dog-names').all;
4-
<RandomButton variants={names}/>
3+
```jsx
4+
const names = require('dog-names').all;
5+
<RandomButton variants={names}/>
6+
```

examples/express/src/components/CustomEndpoint/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Custom Endpoint Example
22

33
The example component invokes an endpoint added to the running styleguide server.
44

5-
```example
5+
```js
66
<CustomEndpoint />
77
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<CounterButton/>
1+
```jsx
2+
<CounterButton/>
3+
```
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
Each example has its own state that you can access at the `state` variable and change with the `setState` function. Default state is `{}`.
22

3-
<div>
4-
<button onClick={() => setState({isOpen: true})}>Open</button>
5-
<Modal isOpen={state.isOpen}>
6-
<h1>Hallo!</h1>
7-
<button onClick={() => setState({isOpen: false})}>Close</button>
8-
</Modal>
9-
</div>
3+
```jsx
4+
<div>
5+
<button onClick={() => setState({isOpen: true})}>Open</button>
6+
<Modal isOpen={state.isOpen}>
7+
<h1>Hallo!</h1>
8+
<button onClick={() => setState({isOpen: false})}>Close</button>
9+
</Modal>
10+
</div>
11+
```
1012

1113
If you want to set the default state you can do something like that:
1214

13-
initialState = {count: 1};
14-
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
15+
```jsx
16+
initialState = {count: 1};
17+
<button onClick={() => setState({count: state.count+1})}>{state.count}</button>
18+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
You can `require` external files in your examples:
22

3-
const names = require('dog-names').all;
4-
<RandomButton variants={names}/>
3+
```jsx
4+
const names = require('dog-names').all;
5+
<RandomButton variants={names}/>
6+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Enhanced/Decorated components work as well:
22

3-
<WrappedButton>I'm a wrapped button</WrappedButton>
3+
```jsx
4+
<WrappedButton>I'm a wrapped button</WrappedButton>
5+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Should use the `fantasy` font inherited from `body`:
22

3-
<Label />
3+
```jsx
4+
<Label />
5+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Extra example file linked via `@example` doclet:
22

3-
<Placeholder type="bear"/>
3+
```jsx
4+
<Placeholder type="bear"/>
5+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<Placeholder type="beard"/>
1+
```jsx
2+
<Placeholder type="beard"/>
3+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
You can `require` external files in your examples:
22

3-
const names = require('dog-names').all;
4-
<RandomButton variants={names}/>
3+
```jsx
4+
const names = require('dog-names').all;
5+
<RandomButton variants={names}/>
6+
```

0 commit comments

Comments
 (0)