truncate html created only truncated text

This commit is contained in:
Burak Civan 2022-10-17 18:24:44 +03:00
parent d9218eff7f
commit f5f69139d5
2 changed files with 15 additions and 6 deletions

View File

@ -362,10 +362,6 @@ if (navigator.userAgent.search("Firefox") >= 0) {
document.querySelectorAll('[data-truncate]').forEach((truncate) => { document.querySelectorAll('[data-truncate]').forEach((truncate) => {
let truncateText = truncate.innerText.split(" ").join(""); let truncateText = truncate.innerText.split(" ").join("");
if (truncateText.length > 30) {
truncate.classList.add('truncate');
}
truncate.addEventListener('mouseover', function () { truncate.addEventListener('mouseover', function () {
if (truncateText.length > 30) { if (truncateText.length > 30) {
truncate.style.animationPlayState = 'running'; truncate.style.animationPlayState = 'running';

View File

@ -1,8 +1,21 @@
@php
$slot_text_length = strlen($slot);
$slot_isHtml = strlen(strip_tags($slot)) < strlen($slot);
@endphp
@if ($slot_text_length >= '30' && ! $slot_isHtml)
<div data-truncate-parent class="flex lg:block truncate"> <div data-truncate-parent class="flex lg:block truncate">
<div <div
@class([ $width ]) @class([
$width,
'truncate',
])
data-truncate data-truncate
> >
{!! $slot !!} {!! $slot !!}
</div> </div>
</div> </div>
@else
{!! $slot !!}
@endif