Skip to content

Commit 29cc18d

Browse files
authored
chore(docs): group text truncation doc with other text utilities (#6349)
## πŸ“„ Description group text truncation doc with other text utilities ## πŸš€ Demo If applicable, please add a screenshot or video to illustrate the changes. --- ## πŸ“ Checklist - βœ… My code follows the style guidelines of this project - πŸ› οΈ I have performed a self-review of my own code - πŸ“„ I have made corresponding changes to the documentation - ⚠️ My changes generate no new warnings or errors - πŸ§ͺ I have added tests that prove my fix is effective or that my feature works - βœ”οΈ New and existing unit tests pass locally with my changes Co-authored-by: Machado da Silva Hugo <[email protected]>
1 parent b614408 commit 29cc18d

File tree

8 files changed

+33
-96
lines changed

8 files changed

+33
-96
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@swisspost/design-system-documentation': patch
3+
---
4+
5+
Grouped the text truncation documentation with other text utilities.

β€Žpackages/documentation/cypress/snapshots/utilities/text-truncation.snapshot.tsβ€Ž

Lines changed: 0 additions & 7 deletions
This file was deleted.

β€Žpackages/documentation/src/stories/utilities/text-truncation/text-truncation.docs.mdxβ€Ž

Lines changed: 0 additions & 15 deletions
This file was deleted.

β€Žpackages/documentation/src/stories/utilities/text-truncation/text-truncation.snapshot.stories.tsβ€Ž

Lines changed: 0 additions & 37 deletions
This file was deleted.

β€Žpackages/documentation/src/stories/utilities/text-truncation/text-truncation.stories.tsβ€Ž

Lines changed: 0 additions & 36 deletions
This file was deleted.

β€Žpackages/documentation/src/stories/utilities/text/text.docs.mdxβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ Transform text with the following text capitalization classes: `.text-lowercase`
109109
Decorate text with the following text decoration classes: `text-decoration-underline`, `.text-decoration-line-through` and `.text-decoration-none`.
110110

111111
<Canvas of={TextStories.TextDecoration} sourceState="shown" />
112+
113+
### Text Truncation
114+
115+
The `.text-truncate` class helps in truncating long text when it exceeds a specified width.
116+
117+
<Canvas sourceState="shown" of={TextStories.TextTruncation} />

β€Žpackages/documentation/src/stories/utilities/text/text.snapshot.stories.tsβ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,19 @@ function getTextUtility(type: string) {
8282
`,
8383
)}
8484
`;
85+
case 'Text Truncation':
86+
return html`
87+
${[100, 200, 300, 400].map(
88+
val =>
89+
html`
90+
<p class="text-truncate" style="max-width: ${val}px">
91+
This is a long text that should be truncated when it exceeds the defined max-width.
92+
</p>
93+
`,
94+
)}
95+
`;
8596
}
8697
}
87-
8898
export const Text: Story = {
8999
render: () => {
90100
return schemes(
@@ -101,6 +111,7 @@ export const Text: Story = {
101111
'Text transform',
102112
'White space',
103113
'Word wrap break',
114+
'Text Truncation',
104115
].map(
105116
val => html`
106117
<h2>${val}</h2>

β€Žpackages/documentation/src/stories/utilities/text/text.stories.tsβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,20 @@ export const TextDecoration: Story = {
109109
<a href="#" class="text-decoration-none">This link has its text decoration removed.</a>
110110
`,
111111
};
112+
113+
export const TextTruncation: StoryObj = {
114+
render: () => html`
115+
<p class="text-truncate" style="max-width: 200px">
116+
This is a long text that should be truncated when it exceeds the defined max-width.
117+
</p>
118+
`,
119+
};
120+
112121
export const SmallText: StoryObj = {
113122
render: () => html`
114123
<p>This is normal text</p>
115124
<p class="small">This is small text (80% of parent font size)</p>
116125
<h2>This is a title with <span class="small">smaller text inside</span></h2>
117126
`,
118127
};
128+

0 commit comments

Comments
Β (0)