I am currently not using the latest version of Radicle 1.2.0. I wanted to quickly set up an environment with the latest Radicle version, but I realized that there are dependencies that require PHP 8.1.0, while the server is running PHP 8. I cannot easily switch the server’s PHP version as there are other sites hosted on it.
I can look into it on Monday to see if the default components work with the new version.
However, what I noticed is that the example components do not have files in the “app/view/Components/{ComponentName}.php” directory. The logic for these example components is included in the view itself.
The issue I’m facing is that I have the logic in the “app/view/Components/{ComponentName}.php” file, which only works locally on my PC and not on the server.
So, this example is one of the components I created, and it only works locally.
This is view path “/resources/views/components/resolve-points-card.blade.php”
<div
class="item ll:w-[405px] flex h-max w-full flex-col gap-4 sm:w-[286px] xl:w-[352px] 2xl:w-[426.5px] min-[1750px]:w-[498px] min-[1920px]:w-[525px]">
@if ($title || $icon['iconName'] !== 'none')
<div class="h-max space-y-4">
@if ($icon['iconName'] !== 'none')
<div
class="{{ $color ?? 'bg-[#3D348B]/10 text-[#3D348B]' }} flex h-10 w-10 items-center justify-center rounded-md p-4">
<x-icon :data=$icon class="text-base" />
</div>
@endif
@if ($title)
<h3 class="text-primary-dark w-full text-xl font-bold leading-6 tracking-[0.48px]">
{{ $title }}
</h3>
@endif
</div>
@endif
@if ($text)
<p class="text-dark self-start text-xs leading-6 tracking-[0.32px] xl:w-9/12">
{{ $text }}
</p>
@endif
</div>
And I have logic here “/app/View/Components/resolvePointsCard.php”
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class resolvePointsCard extends Component
{
protected $data;
protected $processData;
public $title;
public $icon;
public $color;
public $text;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
$this->title = $this->processData($data)['title'];
$this->icon = $this->processData($data)['icon'];
$this->color = $this->processData($data)['color'];
$this->text = $this->processData($data)['text'];
}
private function processData($data)
{
$processData = $data;
switch ($data['color']) {
case '#3D348B':
$processData['color'] = 'bg-[#3D348B]/10 text-[#3D348B]';
break;
case '#F5B300':
$processData['color'] = 'bg-[#F5B300]/10 text-[#F5B300]';
break;
case '#F35B04':
$processData['color'] = 'bg-[#F35B04]/10 text-[#F35B04]';
break;
case '#7678ED':
$processData['color'] = 'bg-[#7678ED]/10 text-[#7678ED]';
break;
case '#00BDB0':
$processData['color'] = 'bg-[#00BDB0]/10 text-[#00BDB0]';
break;
case '#E71D36':
$processData['color'] = 'bg-[#E71D36]/10 text-[#E71D36]';
break;
case '#4361EE':
$processData['color'] = 'bg-[#4361EE]/10 text-[#4361EE]';
break;
default:
break;
}
return $processData;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.resolve-points-card');
}
}
I invoke this component within a block and pass an array to it, which is then processed by the component’s logic. In some cases, such as this one, certain values like the color code are converted into Tailwind CSS classes.
Here is how I call the component in my block:
@foreach ($items as $item)
<x-resolve-points-card :data=$item />
@endforeach
I expect that when I test the example components on the server, they should work fine since they do not rely on the “app/view/Components/{ComponentName}.php” file.