Skip to content

Commit

Permalink
docs: added live examples to migration from docz
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Sep 7, 2020
1 parent 7cbba59 commit 8ef1021
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
48 changes: 38 additions & 10 deletions examples/stories/src/blogs/docz-migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ tags:
- docz
- gatsby
---
import { Playground, Props, Story } from '@component-controls/blocks';
import { Button } from '../components/Button'


# Migration

Expand Down Expand Up @@ -101,10 +104,6 @@ The **files** field is mapped to the **stories** configuration field

component-controls provides a similar component to docz's `<Playground />` and it can be imported from the `@component-controls/blocks`

```
import { Playground } from '@component-controls/blocks';
```

```js:title=playground.mdx
---
name: Playground
Expand All @@ -116,23 +115,48 @@ import { Button } from '../src/components/Button'

# Button

## Basic usage
<Playground>
<Button kind="secondary">Click me</Button>
</Playground>
```
live example:

<Playground>
<Button>Click me</Button>
<Button kind="secondary">Click me</Button>
</Playground>

You can also wrap the component code in a `<Story />` component in order to display the source code

```js:title=playground.mdx
---
name: Playground
menu: Components
---

import { Playground, Story } from '@component-controls/blocks';
import { Button } from '../src/components/Button'

# Button

<Playground>
<Story name='example'>
<Button kind="secondary">Click me</Button>
</Story>
</Playground>
```
live example:

<Playground>
<Story name='example'>
<Button kind="secondary">Click me</Button>
</Story>
</Playground>


## Props

component-controls provides a similar component to docz's `<Props />` and it can be imported from the `@component-controls/blocks`

```
import { Props } from '@component-controls/blocks';
```

```js:title=props.mdx
---
name: Props
Expand All @@ -145,3 +169,7 @@ import { Button } from '../src/components/Button'
# Button

<Props of={Button} />
```
live example:

<Props of={Button} />
8 changes: 7 additions & 1 deletion ui/blocks/src/Playground/BasePlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export type PlaygroundProps = PlaygroundOwnProps &

export type BasePlaygroundProps = PlaygroundProps & {
story?: Story;
wrapper?: boolean;
};

export const BasePlayground: FC<BasePlaygroundProps> = ({
children,
story,
wrapper = true,
...props
}) => {
const custom = useCustomProps<PlaygroundProps>(NAME, props);
Expand Down Expand Up @@ -132,7 +134,11 @@ export const BasePlayground: FC<BasePlaygroundProps> = ({
>
<Zoom scale={scale || 1}>
<PlaygroundContext.Provider value={{ useDescription: true }}>
<Box variant="playground.container">{children}</Box>
{wrapper ? (
<Box variant="playground.container">{children}</Box>
) : (
children
)}
</PlaygroundContext.Provider>
</Zoom>
</PanelContainer>
Expand Down
8 changes: 7 additions & 1 deletion ui/blocks/src/Playground/StoryPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@ export const StoryPlayground: FC<StoryPlaygroundProps> = ({
/>
),
});
return <BasePlayground actions={[...actions, ...storyActions]} {...props} />;
return (
<BasePlayground
wrapper={false}
actions={[...actions, ...storyActions]}
{...props}
/>
);
};

0 comments on commit 8ef1021

Please sign in to comment.