Skip to content

Modular logistics and supply chain operating system (LSOS)

3.9 KB
Raw Blame
<div class="admin-dashboard-widget flex h-full min-h-0 flex-col overflow-hidden rounded-md border bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800" ...attributes>
    <div class="flex items-center justify-between border-b border-gray-100 px-3 py-2.5 dark:border-gray-700">
        <div class="flex min-w-0 items-center gap-2">
            <div class="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-300">
                <FaIcon @icon={{this.icon}} />
            </div>
            <div class="min-w-0">
                <div class="truncate text-xs font-bold uppercase text-gray-900 dark:text-gray-100">{{this.title}}</div>
                {{#if this.subtitle}}
                    <div class="truncate text-[11px] text-gray-500 dark:text-gray-400">{{this.subtitle}}</div>
                {{/if}}
            </div>
        </div>
        <button type="button" class="flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200" {{on "click" (perform this.load)}}>
            <FaIcon @icon="rotate" />
        </button>
    </div>

    <div class="min-h-0 flex-1 overflow-y-auto">
        {{#if this.error}}
            <div class="flex h-full items-center justify-center p-4 text-center text-xs font-medium text-rose-600 dark:text-rose-300">{{this.error}}</div>
        {{else if this.load.isRunning}}
            <div class="flex h-full items-center justify-center p-4"><Spinner /></div>
        {{else if this.items.length}}
            <div class="divide-y divide-gray-100 dark:divide-gray-700">
                {{#each this.items as |item|}}
                    <button type="button" class="flex w-full items-start gap-3 px-3 py-2.5 text-left text-sm {{if item.route 'hover:bg-gray-50 dark:hover:bg-gray-700/50'}}" disabled={{not item.route}} {{on "click" (fn this.openItem item)}}>
                        <div class="mt-0.5 flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-gray-100 text-gray-500 dark:bg-gray-700 dark:text-gray-300">
                            <FaIcon @icon={{or item.icon "circle-info"}} />
                        </div>
                        <div class="min-w-0 flex-1">
                            <div class="truncate font-medium text-gray-900 dark:text-gray-100">{{item.title}}</div>
                            {{#if item.description}}
                                <div class="truncate text-xs text-gray-500 dark:text-gray-400">{{item.description}}</div>
                            {{/if}}
                        </div>
                        {{#if item.status}}
                            <Badge @status={{item.status}} @hideStatusDot={{true}}>{{or item.value item.status}}</Badge>
                        {{else if item.value}}
                            <span class="text-xs font-semibold text-gray-700 dark:text-gray-200">{{item.value}}</span>
                        {{/if}}
                        {{#if item.route}}
                            <FaIcon @icon="chevron-right" class="mt-1 text-[10px] text-gray-300 dark:text-gray-500" />
                        {{/if}}
                    </button>
                {{/each}}
            </div>
        {{else}}
            <div class="flex h-full items-center justify-center p-4 text-center text-xs text-gray-500 dark:text-gray-400">{{this.emptyText}}</div>
        {{/if}}
    </div>

    {{#if this.hasDrilldown}}
        <div class="border-t border-gray-100 px-3 py-2 dark:border-gray-700">
            <button type="button" class="inline-flex items-center gap-1 text-xs font-semibold text-blue-600 hover:text-blue-700 dark:text-blue-300 dark:hover:text-blue-200" {{on "click" this.openDrilldown}}>
                View all
                <FaIcon @icon="arrow-right" class="text-[10px]" />
            </button>
        </div>
    {{/if}}
</div>