Skip to content

Commit

Permalink
backend controlled for title component
Browse files Browse the repository at this point in the history
  • Loading branch information
brkcvn committed Sep 26, 2022
1 parent 0204f0c commit 06e669e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
46 changes: 46 additions & 0 deletions app/View/Components/Title.php
@@ -0,0 +1,46 @@
<?php

namespace App\View\Components;

use App\Abstracts\View\Component;

class Title extends Component
{
public $textSize;

/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $textSize = '',

) {
$this->textSize = $this->getTextSize($textSize);
}

/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.title');
}

protected function getTextSize($textSize)
{
switch ($textSize) {
case 'short':
$textSize = '15';
break;
default:
$textSize = '25';
break;
}

return $textSize;
}
}
4 changes: 3 additions & 1 deletion resources/views/components/title.blade.php
@@ -1,8 +1,10 @@
@php
$slot_isHtml = strlen(strip_tags($slot)) < strlen($slot);
$slot_is_string = strval(strlen($slot));
@endphp

@if (strlen($slot) >= 25 && ! $slot_isHtml)
@if ($slot_is_string >= $textSize && ! $slot_isHtml)
<x-tooltip id="page-title" placement="bottom" message="{!! $slot !!}">
<div class="truncate" style="width: 22rem;">
{!! $slot !!}
Expand Down

0 comments on commit 06e669e

Please sign in to comment.