İçeriğe geç
Tüm kodlar

ER3NSHOP

Kurulum sihirbazlı online mağaza sistemi

157 satır · 11,7 KBHamİndir
<?php
$sort = get('sirala', 'yeni');
$filter_count = count($chips);
$variants_selected = selected_variants();
$ranges = price_ranges($facets['min'], $facets['max']);
$price_selected = (get('min', '') !== '' || get('max', '') !== '') ? 1 : 0;
$status_selected = (get('stok') ? 1 : 0) + (get('indirim') ? 1 : 0);
?>
<form id="listing-form" data-listing-form class="hidden">
    <?php foreach ($keep as $name => $value): ?>
        <input type="hidden" name="<?= e($name) ?>" value="<?= e($value) ?>">
    <?php endforeach ?>
</form>

<div class="grid gap-10 lg:grid-cols-[280px_1fr] xl:gap-14">

    <aside data-drawer="filters" class="fixed inset-y-0 left-0 z-50 flex w-full max-w-sm -translate-x-full flex-col bg-white shadow-2xl transition duration-500 ease-out-soft data-open:translate-x-0 lg:static lg:z-auto lg:max-w-none lg:translate-x-0 lg:bg-transparent lg:shadow-none lg:transition-none">

        <div class="flex h-[72px] shrink-0 items-center justify-between border-b border-zinc-100 px-6 lg:hidden">
            <p class="font-display text-lg font-semibold tracking-tight">Filtrele</p>
            <button type="button" data-close class="btn-ghost -mr-2 p-2" aria-label="Kapat"><?= icon('x', 'size-5') ?></button>
        </div>

        <div class="flex-1 overflow-y-auto px-6 lg:overflow-visible lg:px-0">
            <div class="hidden items-end justify-between pb-2 lg:flex">
                <p class="font-display text-xl font-semibold tracking-tight text-ink">Filtrele</p>
                <?php if ($filter_count): ?>
                    <a href="<?= e(query_clear_filters()) ?>" data-listing-link class="text-[13px] font-medium text-zinc-500 transition hover:text-ink">Tümünü temizle</a>
                <?php endif ?>
            </div>

            <div class="lg:mt-4 lg:rounded-3xl lg:border lg:border-zinc-200/80 lg:bg-white lg:px-6">

                <?php foreach ($facets['variants'] as $group => $values): ?>
                    <?php filter_open('v-' . $group, $group, count($variants_selected[$group] ?? [])) ?>
                        <div class="grid grid-cols-4 gap-2">
                            <?php foreach ($values as $value => $total): ?>
                                <label class="cursor-pointer" title="<?= $total ?> ürün">
                                    <input type="checkbox" form="listing-form" name="f[<?= e($group) ?>][]" value="<?= e($value) ?>" class="peer sr-only" <?= is_variant_selected($group, $value) ? 'checked' : '' ?>>
                                    <span class="relative flex h-12 flex-col items-center justify-center rounded-xl border border-zinc-200 bg-white text-sm font-semibold text-ink transition peer-checked:border-ink peer-checked:bg-ink peer-checked:text-white peer-checked:shadow-lg peer-checked:shadow-zinc-900/20 peer-focus-visible:ring-4 peer-focus-visible:ring-zinc-900/10 hover:border-zinc-400">
                                        <?= e($value) ?>
                                        <span class="text-[10px] leading-none font-medium opacity-50"><?= $total ?></span>
                                    </span>
                                </label>
                            <?php endforeach ?>
                        </div>
                    <?php filter_close() ?>
                <?php endforeach ?>

                <?php filter_open('fiyat', 'Fiyat', $price_selected) ?>
                    <?php if ($ranges): ?>
                        <div class="space-y-1">
                            <?php foreach ($ranges as [$min, $max, $label]): ?>
                                <?php $active = is_price_range($min, $max) ?>
                                <a href="<?= e(query_with(['min' => $active ? null : $min, 'max' => $active ? null : $max, 'sayfa' => null])) ?>" data-listing-link
                                   class="flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm transition <?= $active ? 'bg-zinc-100 font-semibold text-ink' : 'text-zinc-600 hover:bg-zinc-50 hover:text-ink' ?>">
                                    <span class="flex size-[18px] shrink-0 items-center justify-center rounded-full border-2 transition <?= $active ? 'border-ink' : 'border-zinc-300' ?>">
                                        <?php if ($active): ?><span class="size-2 rounded-full bg-ink"></span><?php endif ?>
                                    </span>
                                    <?= $label ?>
                                </a>
                            <?php endforeach ?>
                        </div>
                    <?php endif ?>

                    <div class="<?= $ranges ? 'mt-4' : '' ?> flex items-center rounded-xl border border-zinc-200 bg-white transition focus-within:border-ink focus-within:ring-4 focus-within:ring-zinc-900/5">
                        <label class="flex-1 px-4 py-2">
                            <span class="block text-[11px] font-medium text-zinc-400">En az</span>
                            <input form="listing-form" name="min" value="<?= e(get('min')) ?>" inputmode="decimal" placeholder="<?= number_format(floor($facets['min']), 0, ',', '.') ?> ₺" class="w-full bg-transparent text-sm font-semibold text-ink placeholder:font-normal placeholder:text-zinc-300 focus:outline-none">
                        </label>
                        <span class="h-8 w-px bg-zinc-200"></span>
                        <label class="flex-1 px-4 py-2">
                            <span class="block text-[11px] font-medium text-zinc-400">En çok</span>
                            <input form="listing-form" name="max" value="<?= e(get('max')) ?>" inputmode="decimal" placeholder="<?= number_format(ceil($facets['max']), 0, ',', '.') ?> ₺" class="w-full bg-transparent text-sm font-semibold text-ink placeholder:font-normal placeholder:text-zinc-300 focus:outline-none">
                        </label>
                    </div>
                <?php filter_close() ?>

                <?php filter_open('puan', 'Değerlendirme', get_int('puan') ? 1 : 0) ?>
                    <div class="space-y-1">
                        <?php foreach ([4, 3, 0] as $score): ?>
                            <label class="group flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2.5 text-sm text-zinc-600 transition hover:bg-zinc-50 has-checked:bg-zinc-100 has-checked:text-ink">
                                <input type="radio" form="listing-form" name="puan" value="<?= $score ?: '' ?>" class="sr-only" <?= get_int('puan') === $score ? 'checked' : '' ?>>
                                <span class="flex size-[18px] shrink-0 items-center justify-center rounded-full border-2 border-zinc-300 transition group-has-checked:border-ink">
                                    <span class="size-2 scale-0 rounded-full bg-ink transition group-has-checked:scale-100"></span>
                                </span>
                                <?php if ($score): ?>
                                    <?= stars($score, 'size-4') ?>
                                    <span class="font-medium">ve üzeri</span>
                                    <span class="ml-auto rounded-full bg-white px-2 py-0.5 text-[11px] font-semibold text-zinc-500 ring-1 ring-zinc-200"><?= $facets['ratings'][$score] ?></span>
                                <?php else: ?>
                                    <span class="font-medium">Tümü</span>
                                <?php endif ?>
                            </label>
                        <?php endforeach ?>
                    </div>
                <?php filter_close() ?>

                <?php filter_open('durum', 'Durum', $status_selected) ?>
                    <div class="space-y-1">
                        <?php foreach ([['stok', 'Sadece stoktakiler', $facets['in_stock'], 'check-circle'], ['indirim', 'İndirimdekiler', $facets['on_sale'], 'tag']] as [$name, $label, $total, $symbol]): ?>
                            <label class="group flex cursor-pointer items-center gap-3 rounded-xl px-3 py-2.5 text-sm text-zinc-600 transition hover:bg-zinc-50 has-checked:text-ink">
                                <input type="checkbox" form="listing-form" name="<?= $name ?>" value="1" class="sr-only" <?= get($name) ? 'checked' : '' ?>>
                                <?= icon($symbol, 'size-[18px] text-zinc-400 group-has-checked:text-ink') ?>
                                <span class="flex-1 font-medium"><?= $label ?> <span class="text-xs font-normal text-zinc-400">(<?= $total ?>)</span></span>
                                <span class="relative h-6 w-10 shrink-0 rounded-full bg-zinc-200 transition group-has-checked:bg-ink">
                                    <span class="absolute top-0.5 left-0.5 size-5 rounded-full bg-white shadow-sm transition group-has-checked:translate-x-4"></span>
                                </span>
                            </label>
                        <?php endforeach ?>
                    </div>
                <?php filter_close() ?>
            </div>
        </div>

        <div class="grid shrink-0 grid-cols-2 gap-3 border-t border-zinc-100 bg-white px-6 py-4 lg:hidden">
            <a href="<?= e(query_clear_filters()) ?>" data-listing-link class="btn-light">Temizle</a>
            <button type="button" data-close class="btn-primary"><?= $pager['total'] ?> ürünü göster</button>
        </div>
    </aside>

    <div data-listing-results class="min-w-0 transition duration-200 aria-busy:pointer-events-none aria-busy:opacity-40">
        <div class="mb-6 flex flex-wrap items-center justify-between gap-3">
            <div class="flex items-center gap-3">
                <button type="button" data-open-drawer="filters" class="btn-light btn-sm lg:hidden">
                    <?= icon('filter', 'size-4') ?>Filtrele
                    <?php if ($filter_count): ?><span class="flex size-5 items-center justify-center rounded-full bg-ink text-[11px] font-bold text-white"><?= $filter_count ?></span><?php endif ?>
                </button>
                <p class="text-sm text-zinc-500"><strong class="font-semibold text-ink"><?= $pager['total'] ?></strong> ürün</p>
            </div>
            <label class="relative flex items-center rounded-full border border-zinc-200 bg-white pl-4 text-sm transition hover:border-zinc-300 focus-within:border-ink">
                <span class="text-zinc-500">Sırala:</span>
                <select form="listing-form" name="sirala" class="cursor-pointer appearance-none bg-transparent py-2.5 pr-10 pl-1.5 font-semibold text-ink focus:outline-none">
                    <?php foreach (product_sorts() as $key => [$label]): ?>
                        <option value="<?= $key ?>" <?= $sort === $key ? 'selected' : '' ?>><?= $label ?></option>
                    <?php endforeach ?>
                </select>
                <?= icon('down', 'pointer-events-none absolute right-4 size-4 text-zinc-400', '2') ?>
            </label>
        </div>

        <?php if ($chips): ?>
            <div class="mb-8 flex flex-wrap items-center gap-2">
                <?php foreach ($chips as [$label, $link]): ?>
                    <a href="<?= e($link) ?>" data-listing-link class="group inline-flex items-center gap-2 rounded-full bg-ink py-1.5 pr-2 pl-3.5 text-[13px] font-medium text-white transition hover:bg-zinc-700">
                        <?= e($label) ?>
                        <span class="flex size-5 items-center justify-center rounded-full bg-white/15 transition group-hover:bg-white/25"><?= icon('x', 'size-3', '2.5') ?></span>
                    </a>
                <?php endforeach ?>
                <a href="<?= e(query_clear_filters()) ?>" data-listing-link class="ml-1 text-[13px] font-medium text-zinc-500 underline underline-offset-4 hover:text-ink">Tümünü temizle</a>
            </div>
        <?php endif ?>

        <?php product_grid($products, $empty, 'xl:grid-cols-3') ?>
        <?php pagination($pager) ?>
    </div>
</div>

Lisans bilgisi projenin LICENSE dosyasında.