|
21 | 21 | - [7.0 feature flags removed](#70-feature-flags-removed)
|
22 | 22 | - [CLI option `--use-npm` deprecated](#cli-option---use-npm-deprecated)
|
23 | 23 | - [Vite builder uses vite config automatically](#vite-builder-uses-vite-config-automatically)
|
24 |
| - - [Vite cache moved to node_modules/.cache/.vite-storybook](#vite-cache-moved-to-node_modulescachevite-storybook) |
| 24 | + - [Vite cache moved to node\_modules/.cache/.vite-storybook](#vite-cache-moved-to-node_modulescachevite-storybook) |
25 | 25 | - [Removed docs.getContainer and getPage parameters](#removed-docsgetcontainer-and-getpage-parameters)
|
26 |
| - - [Removed STORYBOOK_REACT_CLASSES global](#removed-storybook_react_classes-global) |
| 26 | + - [Removed STORYBOOK\_REACT\_CLASSES global](#removed-storybook_react_classes-global) |
27 | 27 | - [Icons API changed](#icons-api-changed)
|
28 | 28 | - ['config' preset entry replaced with 'previewAnnotations'](#config-preset-entry-replaced-with-previewannotations)
|
29 | 29 | - [Dropped support for Angular 12 and below](#dropped-support-for-angular-12-and-below)
|
|
37 | 37 | - [Configuring the Docs Container](#configuring-the-docs-container)
|
38 | 38 | - [External Docs](#external-docs)
|
39 | 39 | - [MDX2 upgrade](#mdx2-upgrade)
|
| 40 | + - [Default docs styles will leak into non-story user components](#default-docs-styles-will-leak-into-non-story-user-components) |
| 41 | + - [Explicit `<code>` elements are no longer syntax highlighted](#explicit-code-elements-are-no-longer-syntax-highlighted) |
40 | 42 | - [Dropped source loader / storiesOf static snippets](#dropped-source-loader--storiesof-static-snippets)
|
41 | 43 | - [Dropped addon-docs manual configuration](#dropped-addon-docs-manual-configuration)
|
42 | 44 | - [Autoplay in docs](#autoplay-in-docs)
|
@@ -756,6 +758,47 @@ We will update this section with specific pointers based on user feedback during
|
756 | 758 |
|
757 | 759 | As part of the upgrade we deleted the codemod `mdx-to-csf` and will be replacing it with a more sophisticated version prior to release.
|
758 | 760 |
|
| 761 | +#### Default docs styles will leak into non-story user components |
| 762 | + |
| 763 | +Storybook's default styles in docs are now globally applied to any element instead of using classes. This means that any component that you add directly in a docs file will also get the default styles. |
| 764 | + |
| 765 | +To mitigate this you need to wrap any content you don't want styled with the `Unstyled` block like this: |
| 766 | + |
| 767 | +```mdx |
| 768 | +import { Unstyled } from '@storybook/blocks'; |
| 769 | +import { MyComponent } from './MyComponent'; |
| 770 | + |
| 771 | +# This is a header |
| 772 | + |
| 773 | +<Unstyled> |
| 774 | + <MyComponent /> |
| 775 | +</Unstyled> |
| 776 | +``` |
| 777 | + |
| 778 | +Components that are part of your stories or in a canvas will not need this mitigation, as the `Story` and `Canvas` blocks already have this built-in. |
| 779 | + |
| 780 | +#### Explicit `<code>` elements are no longer syntax highlighted |
| 781 | + |
| 782 | +Due to how MDX2 works differently from MDX1, manually defined `<code>` elements are no longer transformed to the `Code` component, so it will not be syntax highlighted. This is not the case for markdown \`\`\` code-fences, that will still end up as `Code` with syntax highlighting. |
| 783 | + |
| 784 | +Luckily [MDX2 supports markdown (like code-fences) inside elements better now](https://mdxjs.com/blog/v2/#improvements-to-the-mdx-format), so most cases where you needed a `<code>` element before, you can use code-fences instead: |
| 785 | + |
| 786 | +<!-- prettier-ignore-start --> |
| 787 | +````md |
| 788 | +<code>This will now be an unstyled line of code</code> |
| 789 | + |
| 790 | +```js |
| 791 | +const a = 'This is still a styled code block.'; |
| 792 | +``` |
| 793 | + |
| 794 | +<div style={{ background: 'red', padding: '10px' }}> |
| 795 | + ```js |
| 796 | + const a = 'MDX2 supports markdown in elements better now, so this is possible.'; |
| 797 | + ``` |
| 798 | +</div> |
| 799 | +```` |
| 800 | +<!-- prettier-ignore-end --> |
| 801 | + |
759 | 802 | #### Dropped source loader / storiesOf static snippets
|
760 | 803 |
|
761 | 804 | In SB 6.x, Storybook Docs used a webpack loader called `source-loader` to help display static code snippets. This was configurable using the `options.sourceLoaderOptions` field.
|
@@ -3621,3 +3664,7 @@ If you **are** using these addons, it takes two steps to migrate:
|
3621 | 3664 | ```
|
3622 | 3665 |
|
3623 | 3666 | <!-- markdown-link-check-enable -->
|
| 3667 | +
|
| 3668 | +``` |
| 3669 | + |
| 3670 | +``` |
0 commit comments