question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-Docs: Configurable Source snippetization

See original GitHub issue

Add the ability to configure Source block with per-framework snippetization, or even user-configurable snippetization. E.g.

  • @CodeByAlex wants just the template: field for Angular
  • etb (?) wants to remove the () => ...
  • HamHam wants to remove single quotes from:
    <Story name="heading" height="100px">
      {'<h1>Hello World</h1>'}
    </Story>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:22
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

9reactions
rijkvanzantencommented, Jan 16, 2020

You can use mdxSource on <Preview> as a temporary override. Not ideal, but provides the expected highlighted source code:

<Preview mdxSource={`
  <v-icon name="accessibility_new" color="--red" x-small />
  <v-icon name="warning" color="--purple" small />
  <v-icon name="gesture" color="--blue" />
  <v-icon name="security" color="--green" large />
  <v-icon name="person" color="--orange" x-large />
`}>

image

Full example
<Preview mdxSource={`
<v-icon name="accessibility_new" color="--red" x-small />
<v-icon name="warning" color="--purple" small />
<v-icon name="gesture" color="--blue" />
<v-icon name="security" color="--green" large />
<v-icon name="person" color="--orange" x-large />
`}>
	<Story name="x-small" height="50px">
		{{
			components: { VIcon },
			template: `<v-icon name="accessibility_new" color="--red" x-small />`
		}}
	</Story>
	<Story name="small" height="50px">
		{{
			components: { VIcon },
			template: `<v-icon name="warning" color="--purple" small />`
		}}
	</Story>
	<Story name="default" height="50px">
		{{
			components: { VIcon },
			template: `<v-icon name="gesture" color="--blue" />`
		}}
	</Story>
	<Story name="large" height="50px">
		{{
			components: { VIcon },
			template: `<v-icon name="security" color="--green" large />`
		}}
	</Story>
	<Story name="x-large" height="50px">
		{{
			components: { VIcon },
			template: `<v-icon name="person" color="--orange" x-large />`
		}}
	</Story>
</Preview>
</div>

Warning: adding multiple <Story> components inside <Preview> causes issue https://github.com/storybookjs/storybook/issues/6738#issuecomment-575369564 on my end

4reactions
shilmancommented, Mar 23, 2020

¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.28 containing PR #10184 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docs Addon | Storybook: Frontend workshop for UI development
DocsPage pulls information from your stories, components, source code, ... The addon-docs preset has a few configuration options that can be used to ......
Read more >
@storybook/addon-interactions: Versions | Openbase
Addon-docs : Fix React Profiler in source snippets #19004 ... Add a TypeScript check task and configure ci to run it #19471; Add...
Read more >
@storybook/addon-docs | Yarn - Package Manager
Storybook Docs · DocsPage · MDX · Framework support · Installation · Preset options · Manual configuration · TypeScript configuration · More resources....
Read more >
Top 5 @storybook/addon-docs Code Examples - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Custom documentation pages for storybookjs - Atanas Stoyanov
The Storybook addon-docs is a great feature to display documentation in… ... in .storybook/main.js — enable the plugin and configure the pages options ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found