From 06e669e2638253b838ab15a2bf5a53fc5f7156df Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Mon, 26 Sep 2022 16:42:13 +0300 Subject: [PATCH] backend controlled for title component --- app/View/Components/Title.php | 46 ++++++++++++++++++++++ resources/views/components/title.blade.php | 4 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 app/View/Components/Title.php diff --git a/app/View/Components/Title.php b/app/View/Components/Title.php new file mode 100644 index 000000000..ce424d479 --- /dev/null +++ b/app/View/Components/Title.php @@ -0,0 +1,46 @@ +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; + } +} diff --git a/resources/views/components/title.blade.php b/resources/views/components/title.blade.php index 63e9532c7..13d910f79 100644 --- a/resources/views/components/title.blade.php +++ b/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)
{!! $slot !!}