Verbessern der Truncation (CSS Grid)

This commit is contained in:
reverend 2021-03-04 17:39:05 +01:00
parent 7e751d1078
commit c40ce19b9e
3 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,81 @@
/**
* This mixin is for truncating text. By now, this can only be done by container height.
* Because this is actually realy messed up in native CSS, you have to specify the line-height
* and container height manualy in Stylues. CSS-Variables can unfortunately not be used in this case.
*/
RV-Truncation--fade(background-color=white)
+RV-Block__Modifier--name('fade')
+RV-Element('Content')
&:last-child:after
background-image linear-gradient(180deg, rgba(255, 255, 255, 0), background-color)
display block
content '###'
color transparent
opacity 1
position absolute
top calc(var(--height) - 40px)
width 100%
height calc(1.5 * var(--line-height))
z-index 10
RV-Truncation--ellipsis(background-color=white)
+RV-Block__Modifier--name('ellipsis')
+RV-Element('Cutter')
&:after
position absolute
display block
right 0
content '...'
background-color background-color
padding-left 5px
padding-bottom 10px
box-shadow -10px 8px 6px 0px background-color;
line-height --line-height
top calc(var(--height) - 38px)
+RV-Element('Content')
&:after
display block
background-color background-color
content ''
position relative
right 0
height --height
width 100%
bottom -100%
z-index 30
RV-Truncation(line-height=1.3em, height=100%, background-color=white)
RV-CSSParameter({
line-height: line-height,
height: height,
background-color: background-color
})
display grid
align-content flex-start
height --height
grid-template-rows repeat(auto-fill, --line-height)
height calc_height(--height)
width calc_width()
position relative
*
overflow hidden
grid-row 1/-1
background --background-color
line-height --line-height
z-index -10
+RV-Block('RV-Truncation')
RV-Truncation()
+RV-Block__Modifier()
RV-Truncation--fade(--background-color)
+RV-Block__Modifier()
RV-Truncation--ellipsis(--background-color)

View File

@ -0,0 +1,17 @@
{
"name": "Truncation",
"variants": [
{
"name": "Fade",
"context": {
"modifier": "RV-Truncation--fade"
}
},
{
"name": "Ellipsis",
"context": {
"modifier": "RV-Truncation--ellipsis"
}
}
]
}

View File

@ -0,0 +1,7 @@
<div class="RV-Truncation {{#if modifier}}{{modifier}}{{/if}}" style="--height: 200px">
<div class="RV-Truncation__Cutter">
<p class="RV-Truncation__Content">
You could see there was text coming out of her eyes, text coming out of her wherever. . Does everybody know that pig named Lorem Ipsum? She's a disgusting pig, right? When other websites give you text, theyre not sending the best. Theyre not sending you, theyre sending words that have lots of problems and theyre bringing those problems with us. Theyre bringing mistakes. Theyre bringing misspellings. Theyre typists… And some, I assume, are good words. I'm speaking with myself, number one, because I have a very good brain and I've said a lot of things. Podcasting operational change management inside of workflows to establish a framework. Taking seamless key performance indicators offline to maximise the long tail. Keeping your eye on the ball while performing a deep dive on the start-up mentality to derive convergence on cross-platform integration.
</p>
</div>
</div>