Add Badge component

This commit is contained in:
philipp lang 2024-10-24 23:05:12 +02:00
parent bc55d19ed0
commit 3199a2d5fb
5 changed files with 42 additions and 9 deletions

View File

@ -7,7 +7,7 @@ use Illuminate\View\Component;
class Header extends Component class Header extends Component
{ {
public function __construct(public string $title, public bool $closeable = false) public function __construct(public string $title)
{ {
} }
@ -15,17 +15,12 @@ class Header extends Component
{ {
return <<<'HTML' return <<<'HTML'
<div class="h-16 px-6 flex items-center justify-between border-b border-solid border-gray-600 group-[.is-bright]:border-gray-500"> <div class="h-16 px-6 flex items-center justify-between border-b border-solid border-gray-600 group-[.is-bright]:border-gray-500">
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-4">
{{ $beforeTitle ?? ''}} {{ $beforeTitle ?? ''}}
<span class="text-sm md:text-xl font-semibold leading-none text-white">{{ $title }}</span> <span class="text-sm md:text-xl font-semibold leading-none text-white">{{ $title }}</span>
{{ $toolbar ?? '' }} {{ $toolbar ?? '' }}
</div> </div>
<div class="flex items-center space-x-4 ml-2"> <div class="flex items-center space-x-4 ml-2">
@if ($closeable)
<a href="#" class="btn label btn-primary-light icon" wire:click="close">
<ui-sprite class="w-3 h-3" src="close"></ui-sprite>
</a>
@endif
{{ $right ?? '' }} {{ $right ?? '' }}
</div> </div>
</div> </div>

View File

@ -28,7 +28,7 @@ class Layout extends Component
<div class="grow bg-gray-900 flex flex-col duration-300 navbar:ml-60"> <div class="grow bg-gray-900 flex flex-col duration-300 navbar:ml-60">
<x-page::header title="{{ session()->get('title') }}"> <x-page::header title="{{ session()->get('title') }}">
<x-slot:beforeTitle> <x-slot:beforeTitle>
<a href="#" class="mr-2 lg:hidden" wire:click.prevent="dispatch('toggle-sidebar')"> <a href="#" class="lg:hidden" wire:click.prevent="dispatch('toggle-sidebar')">
<x-ui::sprite src="menu" class="text-gray-100 w-5 h-5"></x-ui::sprite> <x-ui::sprite src="menu" class="text-gray-100 w-5 h-5"></x-ui::sprite>
</a> </a>
</x-slot:beforeTitle> </x-slot:beforeTitle>

View File

@ -27,6 +27,9 @@ class SettingLayout extends Component
<x-slot:right> <x-slot:right>
{{ $right ?? '' }} {{ $right ?? '' }}
</x-slot:right> </x-slot:right>
<x-slot:toolbar>
{{ $toolbar ?? '' }}
</x-slot:toolbar>
<div class="flex grow relative"> <div class="flex grow relative">
<x-ui::menulist :entries="$entries"></x-ui::menulist> <x-ui::menulist :entries="$entries"></x-ui::menulist>
<div class="grow"> <div class="grow">

33
app/View/Ui/Badge.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace App\View\Ui;
use App\View\Traits\HasColors;
use Illuminate\View\Component;
class Badge extends Component
{
use HasColors;
public function __construct(
public string $icon,
public string $variant = 'primary'
) {
}
public function render()
{
return <<<'HTML'
<button type="button" href="#" {{ $attributes }} class="h-6 px-3 space-x-2 items-center rounded-full {{ $allColors($variant) }} hidden lg:flex">
<x-ui::sprite class="w-3 h-3 flex-none" :src="$icon"></x-ui::sprite>
<span class="text-sm">
{{$slot}}
</span>
</button>
<button type="button" x-tooltip.raw="{{$slot}}" href="#" {{ $attributes }} class="h-6 px-3 space-x-2 flex items-center rounded-full {{ $allColors($variant) }} lg:hidden">
<x-ui::sprite class="w-3 h-3 flex-none" :src="$icon"></x-ui::sprite>
</button>
HTML;
}
}

View File

@ -1,4 +1,7 @@
<x-page::setting-layout :active="$settingClass"> <x-page::setting-layout :active="$settingClass">
<x-slot:toolbar>
<x-ui::badge wire:click.prevent="$dispatch('openModal', {component: 'modules.mailgateway.components.form', props: {}, title: 'Verbindung erstellen'})" icon="plus">Neue Verbindung</x-ui::badge>
</x-slot:toolbar>
<div> <div>
<x-ui::table> <x-ui::table>
<thead> <thead>
@ -9,7 +12,6 @@
<th>Aktion</th> <th>Aktion</th>
</thead> </thead>
<x-ui::action wire:click.prevent="$dispatch('openModal', {component: 'modules.mailgateway.components.form', props: {}, title: 'Verbindung erstellen'})" icon="plus" variant="danger">Neu</x-ui::action>
@foreach ($data as $index => $gateway) @foreach ($data as $index => $gateway)
<tr wire:key="$index"> <tr wire:key="$index">