Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Fix newline handling in ArgsTable code blocks #12882

11 changes: 10 additions & 1 deletion examples/cra-kitchen-sink/src/components/Container.js
Expand Up @@ -10,7 +10,16 @@ const Container = ({ children, title, age, isAmazing }) => (
);

Container.propTypes = {
/** The nodes to be rendered in the button */
/**
* The nodes to be rendered in the button
*
* Example value:
*
* ```
* <h1>Node 1</h1>
* <h2>Node 2</h2>
* ```
*/
children: PropTypes.node.isRequired,
/** Show exclamation marks */
isAmazing: PropTypes.bool,
Expand Down
13 changes: 10 additions & 3 deletions examples/cra-kitchen-sink/src/stories/test.stories.mdx
@@ -1,7 +1,14 @@
import { Story, Meta } from '@storybook/addon-docs/blocks';
import { Story, Meta, ArgsTable } from '@storybook/addon-docs/blocks';
import Container from '../components/Container'

<Meta title="Docs/Test" />
<Meta title="Docs/Test" component={Container} />

<Story name="NewStory123">
<h2> Hello </h2>
<Container>
<h1>Hello</h1>
</Container>
</Story>

## Arguments

<ArgsTable story="NewStory123" />
11 changes: 10 additions & 1 deletion examples/cra-ts-kitchen-sink/src/components/Button.tsx
Expand Up @@ -4,7 +4,16 @@ export type Type = 'default' | 'action';

interface Props {
/**
* Click event handler
* Click event `handler`
*
* Example function:
*
* ```
* () => {
* doThis();
* }
* ```
*
* @default null
*/
onClick?: () => void;
Expand Down
4 changes: 4 additions & 0 deletions lib/components/src/blocks/ArgsTable/ArgRow.tsx
Expand Up @@ -41,6 +41,10 @@ const Description = styled.div(({ theme }) => ({
margin: 0,
display: 'inline-block',
},

'& pre > code': {
whiteSpace: 'pre-wrap',
},
}));

const Type = styled.div<{ hasDescription: boolean }>(({ theme, hasDescription }) => ({
Expand Down