Skip to content

Commit d71e1f3

Browse files
committed
Add line-clamp mixin and text truncation helper classes
1 parent e0bee05 commit d71e1f3

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

assets/_sass/base/_helpers.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@
8787
margin: 0 !important;
8888
}
8989

90+
////////////////////
91+
// Truncation
92+
////////////////////
93+
94+
.text-truncate {
95+
overflow: hidden;
96+
text-overflow: ellipsis;
97+
white-space: nowrap;
98+
}
99+
100+
.clamp-2 {
101+
@include line-clamp(2);
102+
}
103+
104+
.clamp-3 {
105+
@include line-clamp(3);
106+
}
107+
90108
////////////////////
91109
// Logo
92110
////////////////////

assets/_sass/mixins/_line-clamp.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Limits a block of text to a certain number of lines
2+
// @include line-clamp(max-lines);
3+
4+
@mixin line-clamp($lines: 2) {
5+
// Use line-clamp if supported (will have a trailing ellipsis)
6+
@supports (-webkit-line-clamp: 1) {
7+
overflow: hidden;
8+
display: -webkit-box;
9+
-webkit-box-orient: vertical;
10+
-webkit-line-clamp: $lines;
11+
}
12+
}

assets/css/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Imports
77
////////////////////
88

9+
@import "mixins/line-clamp";
10+
911
@import "base/units";
1012
@import "base/colors";
1113
@import "base/normalize";

0 commit comments

Comments
 (0)