diff --git a/.changeset/loose-times-attend.md b/.changeset/loose-times-attend.md new file mode 100644 index 0000000000..231833732d --- /dev/null +++ b/.changeset/loose-times-attend.md @@ -0,0 +1,5 @@ +--- +'@swisspost/design-system-documentation': patch +--- + +Grouped the text truncation documentation with other text utilities. diff --git a/packages/documentation/cypress/snapshots/utilities/text-truncation.snapshot.ts b/packages/documentation/cypress/snapshots/utilities/text-truncation.snapshot.ts deleted file mode 100644 index 571de0a52d..0000000000 --- a/packages/documentation/cypress/snapshots/utilities/text-truncation.snapshot.ts +++ /dev/null @@ -1,7 +0,0 @@ -describe('Text Truncation', () => { - it('text truncation', () => { - cy.visit('/iframe.html?id=snapshots--text-truncation'); - cy.get('.text-truncation-example', { timeout: 30000 }).should('be.visible'); - cy.percySnapshot('Text Truncation', { widths: [1440] }); - }); -}); diff --git a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.docs.mdx b/packages/documentation/src/stories/utilities/text-truncation/text-truncation.docs.mdx deleted file mode 100644 index fdcae0d212..0000000000 --- a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.docs.mdx +++ /dev/null @@ -1,15 +0,0 @@ -import { Canvas, Controls, Meta } from '@storybook/addon-docs/blocks'; -import * as TextTruncationStories from './text-truncation.stories'; - - - -# Text Truncation - -The `.text-truncate` class helps in truncating long text when it exceeds a specified width. - -## Usage - - -
- -
diff --git a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.snapshot.stories.ts b/packages/documentation/src/stories/utilities/text-truncation/text-truncation.snapshot.stories.ts deleted file mode 100644 index 7627823f6e..0000000000 --- a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.snapshot.stories.ts +++ /dev/null @@ -1,37 +0,0 @@ -import meta from '@/stories/introduction.stories'; -import type { StoryObj } from '@storybook/web-components-vite'; -import { html } from 'lit'; -import { schemes } from '@/shared/snapshots/schemes'; - -const { id, ...metaWithoutId } = meta; - -export default { - ...metaWithoutId, - title: 'Snapshots', -}; - -type Story = StoryObj; - -export const TextTruncation: Story = { - render: () => { - return schemes( - () => html` -
-
- ${[100, 200, 300, 400].map(width => { - return html` - Width: ${width}px -
-

- This is a long text that should be truncated when it exceeds the defined - max-width. -

-
- `; - })} -
-
- `, - ); - }, -}; diff --git a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.stories.ts b/packages/documentation/src/stories/utilities/text-truncation/text-truncation.stories.ts deleted file mode 100644 index 696125d5e1..0000000000 --- a/packages/documentation/src/stories/utilities/text-truncation/text-truncation.stories.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { StoryObj } from '@storybook/web-components-vite'; -import { html } from 'lit/static-html.js'; -import { MetaExtended } from '@root/types'; - -const meta: MetaExtended = { - id: '83fd4b10-9010-435a-be42-c1e7236068cc', - title: 'Utilities/Text Truncation', - argTypes: { - truncateWidth: { - name: 'max-width', - description: 'Sets the maximum width for truncation.', - control: { - type: 'number', - }, - table: { - category: 'Text Truncation', - }, - }, - }, - args: { - truncateWidth: 200, - }, - render: args => { - return html` -

- This is a long text that should be truncated when it exceeds the defined max-width. -

- `; - }, -}; - -export default meta; - -type Story = StoryObj; - -export const Default: Story = {}; diff --git a/packages/documentation/src/stories/utilities/text/text.docs.mdx b/packages/documentation/src/stories/utilities/text/text.docs.mdx index 9ce94814ca..1ce20149d0 100644 --- a/packages/documentation/src/stories/utilities/text/text.docs.mdx +++ b/packages/documentation/src/stories/utilities/text/text.docs.mdx @@ -109,3 +109,9 @@ Transform text with the following text capitalization classes: `.text-lowercase` Decorate text with the following text decoration classes: `text-decoration-underline`, `.text-decoration-line-through` and `.text-decoration-none`. + +### Text Truncation + +The `.text-truncate` class helps in truncating long text when it exceeds a specified width. + + diff --git a/packages/documentation/src/stories/utilities/text/text.snapshot.stories.ts b/packages/documentation/src/stories/utilities/text/text.snapshot.stories.ts index b794c6f01b..201b364260 100644 --- a/packages/documentation/src/stories/utilities/text/text.snapshot.stories.ts +++ b/packages/documentation/src/stories/utilities/text/text.snapshot.stories.ts @@ -82,9 +82,19 @@ function getTextUtility(type: string) { `, )} `; + case 'Text Truncation': + return html` + ${[100, 200, 300, 400].map( + val => + html` +

+ This is a long text that should be truncated when it exceeds the defined max-width. +

+ `, + )} + `; } } - export const Text: Story = { render: () => { return schemes( @@ -101,6 +111,7 @@ export const Text: Story = { 'Text transform', 'White space', 'Word wrap break', + 'Text Truncation', ].map( val => html`

${val}

diff --git a/packages/documentation/src/stories/utilities/text/text.stories.ts b/packages/documentation/src/stories/utilities/text/text.stories.ts index 905932d76e..ae2c493648 100644 --- a/packages/documentation/src/stories/utilities/text/text.stories.ts +++ b/packages/documentation/src/stories/utilities/text/text.stories.ts @@ -109,6 +109,15 @@ export const TextDecoration: Story = { This link has its text decoration removed. `, }; + +export const TextTruncation: StoryObj = { + render: () => html` +

+ This is a long text that should be truncated when it exceeds the defined max-width. +

+ `, +}; + export const SmallText: StoryObj = { render: () => html`

This is normal text

@@ -116,3 +125,4 @@ export const SmallText: StoryObj = {

This is a title with smaller text inside

`, }; +