Skip to content

Commit

Permalink
docs: add stories for how PrismFormatted handles long lines (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenltnguyen authored Sep 17, 2024
1 parent fc5e8a4 commit 109f823
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/prism-formatted/prism-formatted.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import { Meta, StoryObj } from "@storybook/react";

import { PrismFormatted } from "./prism-formatted";
Expand Down Expand Up @@ -68,4 +69,50 @@ export const WithLineNumbers: Story = {
},
};

export const WithLongLineOfCode: Story = {
args: {
text: `<pre><code class="language-html"><p>This story shows how PrismFormatted displays a long line of code. This line should not wrap to a new line, but instead, the overflow content is clipped and can be scrolled into view.</p></code></pre>`,
getCodeBlockAriaLabel: (codeName) => `${codeName} code example`,
},
parameters: {
docs: {
source: {
code: `<PrismFormatted
getCodeBlockAriaLabel={codeName => \`\${codeName} code example\`}
text={\`<pre><code class="language-html"><p>This story shows how PrismFormatted displays a long line of code. This line should not wrap to a new line, but instead, the overflow content is clipped and can be scrolled into view.</p></code></pre>\`}
/>`,
},
},
},
};

export const InsideDisclosureElement: Story = {
decorators: [
(Story) => (
<details>
<summary>Example code</summary>
<Story />
</details>
),
],
args: {
text: `<pre><code class="language-html"><p>This story shows how PrismFormatted displays a long line of code when it's rendered inside a disclosure element. This line should not wrap to a new line, but instead, the overflow content is clipped and can be scrolled into view.</p></code></pre>`,
getCodeBlockAriaLabel: (codeName) => `${codeName} code example`,
},
parameters: {
docs: {
source: {
code: `<details>
<summary>Example code</summary>
<PrismFormatted
getCodeBlockAriaLabel={codeName => \`\${codeName} code example\`}
text={\`<pre><code class="language-html"><p>This story shows how PrismFormatted displays a long line of code when it's rendered inside a disclosure element. This line should not wrap to a new line, but instead, the overflow content is clipped and can be scrolled into view.</p></code></pre>\`}
/>
</details>`,
},
},
},
};

export default story;

0 comments on commit 109f823

Please sign in to comment.