Files
Virtnet.bond/extensions/Servers/Proxmox/views/components/ui/icon-picker.blade.php
Joseph.Rawlings b4e2923a2c refactor: update Proxmox UI components to use TailAdmin styling
- Changed component styles and classes to align with TailAdmin design patterns.
- Updated color schemes, typography, and layout for consistency across components.
- Refactored Info Row, Network Address Card, Notice Banner, Progress Bar, Resource Gauge, Section Header, Server Status, Spinner, Stat Card, and Tab Panel components.
- Enhanced responsiveness and accessibility features in various components.
2025-12-17 12:33:10 -05:00

170 lines
8.2 KiB
PHP

{{--
Icon Picker Component - TailAdmin styled
Modal-based icon picker with search and categories
Usage:
<x-proxmox::ui.icon-picker :icons="$icons" wire:model="selectedIcon" />
--}}
@props([
'icons' => [],
'categories' => [],
'selected' => null,
])
<div
x-data="{
open: false,
search: '',
activeCategory: 'all',
icons: @js($icons),
selected: @entangle($attributes->wire('model')),
get filteredIcons() {
let filtered = this.icons;
if (this.search) {
const search = this.search.toLowerCase();
filtered = filtered.filter(icon =>
icon.name.toLowerCase().includes(search) ||
(icon.keywords && icon.keywords.some(k => k.toLowerCase().includes(search)))
);
}
if (this.activeCategory !== 'all') {
filtered = filtered.filter(icon => icon.category === this.activeCategory);
}
return filtered;
}
}"
{{ $attributes->whereDoesntStartWith('wire:model') }}
>
<!-- Trigger Button -->
<button
type="button"
@click="open = true"
class="flex items-center gap-2 px-3 py-2.5 rounded-lg border border-gray-300 bg-white hover:bg-gray-50 shadow-theme-xs dark:border-gray-700 dark:bg-gray-900 dark:hover:bg-gray-800 transition-colors duration-150"
>
<template x-if="selected">
<x-dynamic-component x-bind:component="selected" class="size-5 text-brand-500" />
</template>
<template x-if="!selected">
<x-ri-image-add-line class="size-5 text-gray-400 dark:text-gray-500" />
</template>
<span class="text-theme-sm text-gray-700 dark:text-gray-300">Select Icon</span>
</button>
<!-- Modal -->
<div
x-show="open"
x-cloak
@keydown.escape.window="open = false"
class="fixed inset-0 z-50 overflow-y-auto"
>
<div class="flex items-center justify-center min-h-screen p-4">
<!-- Backdrop -->
<div
x-show="open"
x-transition:enter="ease-out duration-150"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="ease-in duration-100"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
@click="open = false"
class="fixed inset-0 bg-gray-900/50 dark:bg-gray-950/70"
></div>
<!-- Modal Content -->
<div
x-show="open"
x-transition:enter="ease-out duration-150"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="ease-in duration-100"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
class="relative rounded-2xl border border-gray-200 bg-white shadow-theme-lg dark:border-gray-800 dark:bg-gray-900 w-full max-w-2xl max-h-[80vh] overflow-hidden"
>
<!-- Header -->
<div class="p-4 border-b border-gray-200 dark:border-gray-800">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-semibold text-gray-800 dark:text-white/90">Select Icon</h3>
<button @click="open = false" class="p-1.5 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:text-gray-500 dark:hover:text-gray-300 dark:hover:bg-gray-800 transition-colors duration-150">
<x-ri-close-line class="size-5" />
</button>
</div>
<!-- Search -->
<div class="relative">
<x-ri-search-line class="absolute left-3 top-1/2 -translate-y-1/2 size-4 text-gray-400 dark:text-gray-500" />
<input
type="text"
x-model="search"
placeholder="Search icons..."
class="w-full pl-10 pr-4 py-2.5 rounded-lg border border-gray-300 bg-white text-theme-sm text-gray-800 placeholder:text-gray-400 shadow-theme-xs focus:outline-none focus:border-brand-300 focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:placeholder:text-gray-500"
/>
</div>
</div>
<!-- Categories -->
@if(count($categories) > 0)
<div class="flex gap-2 p-4 border-b border-gray-200 dark:border-gray-800 overflow-x-auto">
<button
@click="activeCategory = 'all'"
:class="activeCategory === 'all' ? 'bg-brand-500 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700'"
class="px-3 py-1.5 rounded-full text-theme-xs font-medium transition-colors duration-150 whitespace-nowrap"
>
All
</button>
@foreach($categories as $category)
<button
@click="activeCategory = '{{ $category['id'] }}'"
:class="activeCategory === '{{ $category['id'] }}' ? 'bg-brand-500 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700'"
class="px-3 py-1.5 rounded-full text-theme-xs font-medium transition-colors duration-150 whitespace-nowrap"
>
{{ $category['name'] }}
</button>
@endforeach
</div>
@endif
<!-- Icons Grid -->
<div class="p-4 overflow-y-auto max-h-80">
<div class="grid grid-cols-8 gap-2">
<template x-for="icon in filteredIcons" :key="icon.name">
<button
@click="selected = icon.component; open = false;"
:class="selected === icon.component ? 'ring-2 ring-brand-500 bg-brand-500/10 dark:bg-brand-500/20' : 'hover:bg-gray-100 dark:hover:bg-gray-800'"
class="flex items-center justify-center p-3 rounded-lg transition-colors duration-150"
:title="icon.name"
>
<x-dynamic-component x-bind:component="icon.component" class="size-6" />
</button>
</template>
</div>
<!-- Empty State -->
<div x-show="filteredIcons.length === 0" class="py-8 text-center">
<x-ri-search-line class="size-12 mx-auto text-gray-300 dark:text-gray-700 mb-3" />
<p class="text-theme-sm text-gray-500 dark:text-gray-400">No icons found matching your search.</p>
</div>
</div>
<!-- Footer -->
<div class="p-4 border-t border-gray-200 dark:border-gray-800 flex items-center justify-between">
<button
@click="selected = null"
class="px-3 py-1.5 text-theme-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors duration-150"
>
Clear Selection
</button>
<button
@click="open = false"
class="px-4 py-2.5 bg-brand-500 text-white rounded-lg text-theme-sm font-medium shadow-theme-xs hover:bg-brand-600 transition-colors duration-150"
>
Done
</button>
</div>
</div>
</div>
</div>
</div>