初始化仓库
This commit is contained in:
49
admin/components/UI/Table/Column/Images.php
Normal file
49
admin/components/UI/Table/Column/Images.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace admin\components\UI\Table\Column;
|
||||
|
||||
use admin\components\UI\Widget\Badge;
|
||||
|
||||
/**
|
||||
* Class Images
|
||||
*/
|
||||
class Images implements Component
|
||||
{
|
||||
|
||||
private int $size;
|
||||
|
||||
/**
|
||||
* Tags constructor.
|
||||
*/
|
||||
public function __construct(int $size = 3)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $label
|
||||
* @return array
|
||||
*/
|
||||
public function render($label): array
|
||||
{
|
||||
$node = [
|
||||
'nodeName' => 'div',
|
||||
'vFor' => "item in rowData.record['$label']",
|
||||
'class' => "flex-none bg-cover w-{$this->size} h-{$this->size}",
|
||||
'vBind:style' => "{'background-image': 'url(' + item + ')'}"
|
||||
];
|
||||
|
||||
return [
|
||||
'nodeName' => 'div',
|
||||
'class' => 'flex gap-2',
|
||||
'child' => $node
|
||||
];
|
||||
}
|
||||
|
||||
public function getData($rowData, $field, $value): array
|
||||
{
|
||||
return [$field => !is_array($value) ? json_decode($value, true) : $value];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user