Skip to content

Commit f6ce290

Browse files
authored
feat: add text-wrap and text-nowrap css mixins (#124)
Also fix safari not breaking long words.
1 parent eeec4d5 commit f6ce290

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

www/shared/styles/global/typography.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ html {
1111
body {
1212
@mixin typography-body-1;
1313
@mixin text-smooth;
14+
@mixin text-wrap;
1415

1516
color: var(--color-black);
16-
overflow-wrap: break-word; /* Break long words, while keeping them together if possible (fallback) */
17-
overflow-wrap: anywhere; /* Break long words, while keeping them together if possible */
1817
-webkit-tap-highlight-color: transparent; /* Do not show a highlight (rectangle around the link) while tapping it */
1918
}
2019

www/shared/styles/imports/mixins/text.css

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,32 @@
1313
}
1414

1515
/* ==========================================================================
16-
Ellipsis mixin
16+
Text wrap related mixins
1717
18-
The container needs to have a width for it to work
18+
Please note that for text-ellipsis and text-ellipsis-multiline to work,
19+
they most likely need to be restricted in width
1920
========================================================================== */
2021

22+
@define-mixin text-wrap {
23+
white-space: normal;
24+
word-wrap: anywhere;
25+
word-break: break-word; /* Needed for iOS Safari, since it does not support `word-wrap: anywhere` */
26+
}
27+
28+
@define-mixin text-nowrap {
29+
white-space: nowrap;
30+
word-wrap: normal;
31+
word-break: normal;
32+
}
33+
2134
@define-mixin text-ellipsis {
35+
@mixin text-nowrap;
2236
overflow: hidden; /* "overflow" value must be different from "visible" */
2337
text-overflow: ellipsis;
24-
white-space: nowrap;
25-
overflow-wrap: normal;
2638
}
2739

2840
@define-mixin text-ellipsis-multiline $maxLineCount, $maxHeight {
41+
@mixin text-wrap;
2942
max-height: $maxHeight;
3043
overflow: hidden;
3144
/* stylelint-disable */

0 commit comments

Comments
 (0)