feat: Add tags as classes to items (#1079)

This commit is contained in:
Attila Kerekes 2022-12-19 13:40:38 +00:00 committed by GitHub
parent 9e6321e500
commit df70dcc521
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -153,6 +153,23 @@ class Item extends Model
return $tagdetails; return $tagdetails;
} }
/**
* @return string
*/
public function getTagClass(): string
{
$tags = $this->tags();
$slugs = [];
foreach ($tags as $tag) {
if ($tag->url) {
$slugs[] = 'tag-'.$tag->url;
}
}
return implode(' ', $slugs);
}
/** /**
* @return BelongsToMany * @return BelongsToMany
*/ */

View file

@ -1,4 +1,4 @@
<section class="item-container{{ $app->droppable }}" data-name="{{ $app->title }}" data-id="{{ $app->id }}"> <section class="item-container{{ $app->droppable . ' ' . $app->getTagClass()}}" data-name="{{ $app->title }}" data-id="{{ $app->id }}">
<div class="item" style="background-color: {{ $app->colour }}"> <div class="item" style="background-color: {{ $app->colour }}">
<div class="app-icon-container"> <div class="app-icon-container">
@if($app->icon) @if($app->icon)