diff --git a/comparisons/components/show_hide_truncated_text/caniuse.txt b/comparisons/components/show_hide_truncated_text/caniuse.txt new file mode 100644 index 0000000..e23a0c0 --- /dev/null +++ b/comparisons/components/show_hide_truncated_text/caniuse.txt @@ -0,0 +1,3 @@ +Target: http://caniuse.com/#feat=css-sel3 +line-camp: http://caniuse.com/#search=line-clamp +Flex: http://caniuse.com/#search=flex diff --git a/comparisons/components/show_hide_truncated_text/codepen.html b/comparisons/components/show_hide_truncated_text/codepen.html new file mode 100644 index 0000000..26f2a30 --- /dev/null +++ b/comparisons/components/show_hide_truncated_text/codepen.html @@ -0,0 +1 @@ +

See the Pen show/hide text with row truncate by Vangel Tzo (@srekoble) on CodePen.

diff --git a/comparisons/components/show_hide_truncated_text/html.html b/comparisons/components/show_hide_truncated_text/html.html new file mode 100644 index 0000000..16b70d0 --- /dev/null +++ b/comparisons/components/show_hide_truncated_text/html.html @@ -0,0 +1,7 @@ +
+ Show less + Show more +

+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. +

+
diff --git a/comparisons/components/show_hide_truncated_text/resources.txt b/comparisons/components/show_hide_truncated_text/resources.txt new file mode 100644 index 0000000..ecfabc3 --- /dev/null +++ b/comparisons/components/show_hide_truncated_text/resources.txt @@ -0,0 +1 @@ +Vangel Tzo show/hide text: http://codepen.io/srekoble/pen/WGBzZa diff --git a/comparisons/components/show_hide_truncated_text/scss.scss b/comparisons/components/show_hide_truncated_text/scss.scss new file mode 100644 index 0000000..92c9a93 --- /dev/null +++ b/comparisons/components/show_hide_truncated_text/scss.scss @@ -0,0 +1,79 @@ +@mixin row-truncate($rows, $line-height, $background: '') { + position: relative; + overflow: hidden; + max-height: $line-height * $rows; + line-height: $line-height; + + &:after { + content: ""; + position: absolute; + right: 0; + bottom: 0; + width: 100px; + height: $line-height; + + @if $background != '' { + background: -moz-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); + background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba($background, 0)), color-stop(100%, rgba($background, 1))); + background: -webkit-linear-gradient(left, rgba($background, 0) 0%,rgba($background, 1) 100%); + background: -o-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); + background: -ms-linear-gradient(left, rgba($background, 0) 0%, rgba($background, 1) 100%); + background: linear-gradient(to right, rgba($background, 0) 0%, rgba($background, 1) 100%); + } + } + + // If supports line-clamp then add an ellipsis overflow and hide the gradient + // This will work in Chrome and Opera, otherwise a gradient will gradually hide the text. + + @supports (-webkit-line-clamp: $rows) { + display: -webkit-box; + -webkit-line-clamp: $rows; + -webkit-box-orient: vertical; + + &:after { + display: none; + } + } +} + +.show-hide-text { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + + a { + -webkit-box-ordinal-group: 3; + -webkit-order: 2; + -ms-flex-order: 2; + order: 2; + } + + p { + @include truncate(3, 20px, #fff); // rows, line-height, gradient fallback + } +} + +.show-less { + display: none; + + &:target { + display: block; + + ~ p { + display: block; + max-height: 100%; + + &:after { + display: none; + } + } + + + a { + display: none; + } + } +}