mirror of
https://github.com/shadoll/sLogos.git
synced 2026-02-04 11:03:24 +00:00
Refactor Home and Preview pages for improved data handling and UI components
- Updated Home.svelte to streamline app data initialization and reactivity. - Removed unnecessary intervals and checks for app data updates. - Enhanced data binding for logos, view modes, and themes. - Simplified the structure of the Header and Footer components. - Introduced CardList and CardSquare components for better logo display. - Improved routing with a NotFound page for unmatched routes. - Added a RouteHeader component for search functionality and theme switching. - Enhanced styling for better user experience across components.
This commit is contained in:
@@ -37,15 +37,40 @@
|
||||
|
||||
function toggleDownloadMenu() {
|
||||
showDownloadMenu = !showDownloadMenu;
|
||||
if (showDownloadMenu) showCopyMenu = false;
|
||||
if (showDownloadMenu) {
|
||||
showCopyMenu = false;
|
||||
// Position the dropdown menu
|
||||
setTimeout(() => {
|
||||
const anchor = downloadMenuAnchor;
|
||||
const dropdown = document.querySelector('.download-group .dropdown-menu');
|
||||
if (anchor && dropdown) {
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
dropdown.style.top = rect.bottom + 5 + 'px';
|
||||
dropdown.style.left = rect.left + 'px';
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
function closeDownloadMenu() {
|
||||
showDownloadMenu = false;
|
||||
}
|
||||
function toggleCopyMenu() {
|
||||
showCopyMenu = !showCopyMenu;
|
||||
if (showCopyMenu) showDownloadMenu = false;
|
||||
if (showCopyMenu) {
|
||||
showDownloadMenu = false;
|
||||
// Position the dropdown menu
|
||||
setTimeout(() => {
|
||||
const anchor = copyMenuAnchor;
|
||||
const dropdown = document.querySelector('.dropdown-menu');
|
||||
if (anchor && dropdown) {
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
dropdown.style.top = rect.bottom + 5 + 'px';
|
||||
dropdown.style.left = rect.left + 'px';
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function closeCopyMenu() {
|
||||
showCopyMenu = false;
|
||||
}
|
||||
@@ -230,7 +255,7 @@
|
||||
<svg width="18" height="18" viewBox="0 0 20 20" fill="none"><circle cx="10" cy="4" r="1.5" fill="currentColor"/><circle cx="10" cy="10" r="1.5" fill="currentColor"/><circle cx="10" cy="16" r="1.5" fill="currentColor"/></svg>
|
||||
</button>
|
||||
{#if showCopyMenu}
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-menu" style="position: fixed">
|
||||
<button class="dropdown-item" on:click={handleSourceClick}>
|
||||
<span class="icon-wrapper">
|
||||
<svg style="margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M14.5 4H17a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3v-5m2-7L4 7l2 2"/><path d="m10 9l2-2l-2-2"/></g></svg>
|
||||
@@ -259,7 +284,7 @@
|
||||
<svg width="18" height="18" viewBox="0 0 20 20" fill="none"><circle cx="10" cy="4" r="1.5" fill="currentColor"/><circle cx="10" cy="10" r="1.5" fill="currentColor"/><circle cx="10" cy="16" r="1.5" fill="currentColor"/></svg>
|
||||
</button>
|
||||
{#if showDownloadMenu}
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-menu" style="position: fixed">
|
||||
<button class="dropdown-item" on:click={handleDownloadPngClick}>
|
||||
<span class="icon-wrapper"></span>
|
||||
<span class="dropdown-text">Download PNG</span>
|
||||
@@ -374,7 +399,7 @@
|
||||
border: 1px solid var(--color-border, #ddd);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 16px 4px rgba(0,0,0,0.18);
|
||||
z-index: 9999;
|
||||
z-index: 10;
|
||||
padding: 0.3em 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -382,11 +407,7 @@
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* Position the download menu on the right side */
|
||||
.download-group .dropdown-menu {
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
/* Dropdown menus are positioned with JavaScript instead of CSS */
|
||||
.dropdown-item {
|
||||
background: none;
|
||||
color: var(--color-text, #222);
|
||||
@@ -423,7 +444,7 @@
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 10000;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
288
src/components/CardList.svelte
Normal file
288
src/components/CardList.svelte
Normal file
@@ -0,0 +1,288 @@
|
||||
<script>
|
||||
import InlineSvg from './InlineSvg.svelte';
|
||||
import Actions from './Actions.svelte';
|
||||
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
||||
import { generateColorSetCircle } from '../utils/colorCircles.js';
|
||||
|
||||
export let logo;
|
||||
export let theme;
|
||||
export let onCopy;
|
||||
export let onDownload;
|
||||
export let setSearchQuery;
|
||||
export let allLogos = [];
|
||||
export const setTheme = () => {};
|
||||
|
||||
function openPreview(logo) {
|
||||
// Navigate to preview page using router
|
||||
const routerPath = `/preview/${encodeURIComponent(logo.name.replace(/\s+/g, '-').toLowerCase())}`;
|
||||
window.location.hash = routerPath;
|
||||
}
|
||||
|
||||
function isSvgLogo(logo) {
|
||||
return logo && logo.format && logo.format.toLowerCase() === 'svg';
|
||||
}
|
||||
|
||||
$: getLogoThemeColor = (logo) => getDefaultLogoColor(logo.colors, theme);
|
||||
</script>
|
||||
|
||||
<div class="logo-list-item">
|
||||
<div
|
||||
class="logo-image-container"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Preview {logo.name}"
|
||||
on:click={() => {
|
||||
console.log('CardList: Logo clicked, calling openPreview');
|
||||
openPreview(logo);
|
||||
}}
|
||||
on:keydown={(e) => (e.key === 'Enter' || e.key === ' ') && openPreview(logo)}
|
||||
style="cursor:pointer;"
|
||||
>
|
||||
{#if isSvgLogo(logo)}
|
||||
{#key theme + (logo._activeColor || '')}
|
||||
<InlineSvg
|
||||
path={logo.path}
|
||||
color={logo.colors ? (logo._activeColor || getLogoThemeColor(logo)) : undefined}
|
||||
colorConfig={logo.colors ? logo.colorConfig : undefined}
|
||||
targets={logo.targets}
|
||||
sets={logo.sets}
|
||||
colors={logo.colors}
|
||||
activeSet={logo._activeSet}
|
||||
alt={logo.name}
|
||||
/>
|
||||
{/key}
|
||||
{:else}
|
||||
<img src={logo.path} alt={logo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-content">
|
||||
<div class="logo-header">
|
||||
<h3>{logo.name}</h3>
|
||||
{#if logo.brand}
|
||||
<button
|
||||
class="brand-filter-btn"
|
||||
title="Filter by brand"
|
||||
on:click={() => {
|
||||
console.log('CardList: Filtering by brand:', logo.brand);
|
||||
setSearchQuery(logo.brand);
|
||||
// Update URL with search param
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set('search', logo.brand);
|
||||
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
|
||||
history.replaceState(null, '', newUrl);
|
||||
}}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
|
||||
<path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z" />
|
||||
</svg>
|
||||
{#if allLogos && allLogos.filter((l) => l.brand === logo.brand).length > 1}
|
||||
<span class="brand-count">{allLogos.filter((l) => l.brand === logo.brand).length}</span>
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="logo-details">
|
||||
{#if logo.colors}
|
||||
<div class="color-switcher-container">
|
||||
<div class="color-switcher-preview">
|
||||
<span
|
||||
class="color-circle color-reset"
|
||||
title="Reset to theme color"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
aria-label="Reset to theme color"
|
||||
style="background: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: none;"
|
||||
on:click|stopPropagation={() => (logo._activeColor = undefined)}
|
||||
on:keydown|stopPropagation={(e) => (e.key === 'Enter' || e.key === ' ') && (logo._activeColor = undefined)}
|
||||
>
|
||||
<svg width="100%" height="100%" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M400,0c220.766,0 400,179.234 400,400c0,220.766 -179.234,400 -400,400c-220.766,0 -400,-179.234 -400,-400c0,-220.766 179.234,-400 400,-400Zm-251.006,583.082l434.088,-434.088c-51.359,-37.541 -114.652,-59.71 -183.082,-59.71c-171.489,0 -310.716,139.227 -310.716,310.716c0,68.43 22.169,131.723 59.71,183.082Zm502.495,-365.501l-433.908,433.908c51.241,37.248 114.283,59.227 182.419,59.227c171.489,-0 310.716,-139.227 310.716,-310.716c-0,-68.136 -21.979,-131.178 -59.227,-182.419Z"
|
||||
fill="#33363f"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
{#if logo.sets}
|
||||
{#each Object.entries(logo.sets) as [setName, setConfig], i}
|
||||
<span
|
||||
class="color-circle set-circle"
|
||||
title={`Color Set ${i + 1}: ${setName}`}
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}}
|
||||
on:keydown|stopPropagation={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}
|
||||
}}
|
||||
style="padding: 0; overflow: hidden;"
|
||||
>
|
||||
{@html generateColorSetCircle(logo.colors, setConfig)}
|
||||
</span>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each Object.entries(logo.colors) as [colorName, colorValue], i}
|
||||
<span
|
||||
class="color-circle"
|
||||
title={colorName.replace('_', ' ')}
|
||||
style="background:{colorValue}"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => (logo._activeColor = colorValue)}
|
||||
on:keydown|stopPropagation={(e) =>
|
||||
(e.key === 'Enter' || e.key === ' ') && (logo._activeColor = colorValue)}
|
||||
></span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="logo-actions">
|
||||
<Actions {logo} {onCopy} {onDownload} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.logo-list-item {
|
||||
display: flex;
|
||||
background: var(--color-card);
|
||||
color: var(--color-text);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 0.75rem;
|
||||
overflow: hidden;
|
||||
height: 130px;
|
||||
}
|
||||
|
||||
.logo-image-container {
|
||||
width: 180px;
|
||||
min-width: 180px;
|
||||
height: 100%;
|
||||
border-right: 1px solid var(--color-border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.logo-image-container img,
|
||||
.logo-image-container :global(svg) {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.logo-content {
|
||||
flex: 1;
|
||||
padding: 1rem 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.logo-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.logo-details {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.logo-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-top: auto;
|
||||
position: relative;
|
||||
z-index: 20; /* Higher than the list item */
|
||||
}
|
||||
|
||||
/* Apply higher z-index to the dropdown menus */
|
||||
/* :global(.logo-list-item .dropdown-menu) { */
|
||||
/* z-index: 100000 !important; */
|
||||
/* } */
|
||||
|
||||
.brand-filter-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
padding: 0.2em 0.5em;
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.brand-filter-btn:hover {
|
||||
background: var(--color-accent, #4f8cff);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.brand-count {
|
||||
font-size: 0.75em;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
/* For mobile view */
|
||||
@media (max-width: 600px) {
|
||||
.logo-details {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.color-switcher-container {
|
||||
margin-left: 0;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.logo-actions {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
/* Responsive grid for the list view */
|
||||
@media (max-width: 900px) {
|
||||
:global(.list-view) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
:global(.list-item) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
:global(.list-item:hover) {
|
||||
z-index: 2; /* Raise the z-index when hovered */
|
||||
}
|
||||
|
||||
</style>
|
||||
219
src/components/CardSquare.svelte
Normal file
219
src/components/CardSquare.svelte
Normal file
@@ -0,0 +1,219 @@
|
||||
<script>
|
||||
import InlineSvg from './InlineSvg.svelte';
|
||||
import Actions from './Actions.svelte';
|
||||
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
||||
import { generateColorSetCircle } from '../utils/colorCircles.js';
|
||||
|
||||
export let logo;
|
||||
export let theme;
|
||||
export let onCopy;
|
||||
export let onDownload;
|
||||
export let setSearchQuery;
|
||||
export let allLogos = [];
|
||||
export let setTheme = () => {};
|
||||
|
||||
function openPreview(logo) {
|
||||
// Navigate to preview page using router
|
||||
const routerPath = `/preview/${encodeURIComponent(logo.name.replace(/\s+/g, '-').toLowerCase())}`;
|
||||
window.location.hash = routerPath;
|
||||
}
|
||||
|
||||
function isSvgLogo(logo) {
|
||||
return logo && logo.format && logo.format.toLowerCase() === 'svg';
|
||||
}
|
||||
|
||||
$: getLogoThemeColor = (logo) => getDefaultLogoColor(logo.colors, theme);
|
||||
</script>
|
||||
|
||||
<div class="logo-card">
|
||||
<div
|
||||
class="logo-image"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Preview {logo.name}"
|
||||
on:click={() => {
|
||||
console.log('CardSquare: Logo clicked, calling openPreview');
|
||||
openPreview(logo);
|
||||
}}
|
||||
on:keydown={(e) => (e.key === 'Enter' || e.key === ' ') && openPreview(logo)}
|
||||
style="cursor:pointer;"
|
||||
>
|
||||
{#if isSvgLogo(logo)}
|
||||
{#key theme + (logo._activeColor || '')}
|
||||
<InlineSvg
|
||||
path={logo.path}
|
||||
color={logo.colors ? (logo._activeColor || getLogoThemeColor(logo)) : undefined}
|
||||
colorConfig={logo.colors ? logo.colorConfig : undefined}
|
||||
targets={logo.targets}
|
||||
sets={logo.sets}
|
||||
colors={logo.colors}
|
||||
activeSet={logo._activeSet}
|
||||
alt={logo.name}
|
||||
/>
|
||||
{/key}
|
||||
{:else}
|
||||
<img src={logo.path} alt={logo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-info">
|
||||
<div class="logo-title-row">
|
||||
<h3>{logo.name}</h3>
|
||||
{#if logo.brand}
|
||||
<button
|
||||
class="brand-filter-btn"
|
||||
title="Filter by brand"
|
||||
on:click={() => {
|
||||
console.log('CardSquare: Filtering by brand:', logo.brand);
|
||||
setSearchQuery(logo.brand);
|
||||
// Update URL with search param
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set('search', logo.brand);
|
||||
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
|
||||
history.replaceState(null, '', newUrl);
|
||||
}}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
|
||||
<path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z" />
|
||||
</svg>
|
||||
{#if allLogos && allLogos.filter((l) => l.brand === logo.brand).length > 1}
|
||||
<span class="brand-count">{allLogos.filter((l) => l.brand === logo.brand).length}</span>
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="format-row">
|
||||
<span><strong>Format:</strong> {logo.format}</span>
|
||||
{#if logo.colors}
|
||||
<div class="color-switcher-preview align-right">
|
||||
<span
|
||||
class="color-circle color-reset"
|
||||
title="Reset to theme color"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
aria-label="Reset to theme color"
|
||||
style="background: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: none;"
|
||||
on:click|stopPropagation={() => (logo._activeColor = undefined)}
|
||||
on:keydown|stopPropagation={(e) => (e.key === 'Enter' || e.key === ' ') && (logo._activeColor = undefined)}
|
||||
>
|
||||
<svg width="100%" height="100%" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M400,0c220.766,0 400,179.234 400,400c0,220.766 -179.234,400 -400,400c-220.766,0 -400,-179.234 -400,-400c0,-220.766 179.234,-400 400,-400Zm-251.006,583.082l434.088,-434.088c-51.359,-37.541 -114.652,-59.71 -183.082,-59.71c-171.489,0 -310.716,139.227 -310.716,310.716c0,68.43 22.169,131.723 59.71,183.082Zm502.495,-365.501l-433.908,433.908c51.241,37.248 114.283,59.227 182.419,59.227c171.489,-0 310.716,-139.227 310.716,-310.716c-0,-68.136 -21.979,-131.178 -59.227,-182.419Z"
|
||||
fill="#33363f"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
{#if logo.sets}
|
||||
{#each Object.entries(logo.sets) as [setName, setConfig], i}
|
||||
<span
|
||||
class="color-circle set-circle"
|
||||
title={`Color Set ${i + 1}: ${setName}`}
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}}
|
||||
on:keydown|stopPropagation={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}
|
||||
}}
|
||||
style="padding: 0; overflow: hidden;"
|
||||
>
|
||||
{@html generateColorSetCircle(logo.colors, setConfig)}
|
||||
</span>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each Object.entries(logo.colors) as [colorName, colorValue], i}
|
||||
<span
|
||||
class="color-circle"
|
||||
title={colorName.replace('_', ' ')}
|
||||
style="background:{colorValue}"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => (logo._activeColor = colorValue)}
|
||||
on:keydown|stopPropagation={(e) =>
|
||||
(e.key === 'Enter' || e.key === ' ') && (logo._activeColor = colorValue)}
|
||||
></span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-actions">
|
||||
<Actions {logo} {onCopy} {onDownload} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.logo-card {
|
||||
background: var(--color-card);
|
||||
color: var(--color-text);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.logo-image {
|
||||
height: 260px;
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logo-info {
|
||||
padding: 1rem;
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.logo-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.brand-filter-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
padding: 0.3em 0.8em 0.1em 0.3em;
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
z-index: 2;
|
||||
margin-left: 0.5em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.brand-filter-btn:hover {
|
||||
background: var(--color-accent, #4f8cff);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.brand-count {
|
||||
font-size: 0.85em;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
/* Format row styling */
|
||||
.format-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
margin-bottom: 0.5em;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1.2rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
</style>
|
||||
@@ -1,239 +0,0 @@
|
||||
<script>
|
||||
import Preview from './Preview.svelte';
|
||||
import Actions from './Actions.svelte';
|
||||
import InlineSvg from './InlineSvg.svelte';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { getDefaultLogoColor, getThemeColor } from '../utils/colorTheme.js';
|
||||
import { generateColorSetCircle } from "../utils/colorCircles.js";
|
||||
|
||||
export let logos = [];
|
||||
export let onCopy;
|
||||
export let onDownload;
|
||||
export let setSearchQuery;
|
||||
export let allLogos = [];
|
||||
|
||||
let showModal = false;
|
||||
let selectedLogo = null; function openPreview(logo) {
|
||||
// Navigate to preview page using router
|
||||
const routerPath = `/preview/${encodeURIComponent(logo.name.replace(/\s+/g, '-').toLowerCase())}`;
|
||||
window.location.hash = routerPath;
|
||||
}
|
||||
|
||||
function isSvgLogo(logo) {
|
||||
return logo && logo.format && logo.format.toLowerCase() === 'svg';
|
||||
}
|
||||
|
||||
export let theme;
|
||||
$: getLogoThemeColor = logo => getDefaultLogoColor(logo.colors, theme);
|
||||
|
||||
$: {
|
||||
if (logos && logos.length) {
|
||||
logos.forEach(logo => {
|
||||
if (logo.colors) {
|
||||
const themeColor = getDefaultLogoColor(logo.colors, theme);
|
||||
const fallbackColor = getThemeColor(logo.colors, theme);
|
||||
const activeColor = logo._activeColor || themeColor;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Preview is now handled via the standalone page, no longer needed here -->
|
||||
|
||||
<div class="logo-grid">
|
||||
{#each logos as logo}
|
||||
<!-- For debugging: {console.log("Grid: rendering logo", logo)} -->
|
||||
<div class="logo-card">
|
||||
<div class="logo-image"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Preview {logo.name}"
|
||||
on:click={() => {
|
||||
console.log("Logo clicked, calling openPreview");
|
||||
openPreview(logo);
|
||||
}}
|
||||
on:keydown={(e) => (e.key === 'Enter' || e.key === ' ') && openPreview(logo)}
|
||||
style="cursor:pointer;"
|
||||
>
|
||||
{#if isSvgLogo(logo)}
|
||||
{#key theme + (logo._activeColor || '')}
|
||||
<InlineSvg
|
||||
path={logo.path}
|
||||
color={logo.colors ? (logo._activeColor || getLogoThemeColor(logo)) : undefined}
|
||||
colorConfig={logo.colors ? logo.colorConfig : undefined}
|
||||
targets={logo.targets}
|
||||
sets={logo.sets}
|
||||
colors={logo.colors}
|
||||
activeSet={logo._activeSet}
|
||||
alt={logo.name}
|
||||
/>
|
||||
{/key}
|
||||
{:else}
|
||||
<img src={logo.path} alt={logo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-info">
|
||||
<div class="logo-title-row">
|
||||
<h3>{logo.name}</h3>
|
||||
<button class="brand-filter-btn" title="Filter by brand" on:click={() => {
|
||||
console.log("Grid: Filtering by brand:", logo.brand);
|
||||
setSearchQuery(logo.brand);
|
||||
// Update URL with search param
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set('search', logo.brand);
|
||||
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
|
||||
history.replaceState(null, '', newUrl);
|
||||
}}>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z"/></svg>
|
||||
{#if allLogos && allLogos.filter(l => l.brand === logo.brand).length > 1}
|
||||
<span class="brand-count">{allLogos.filter(l => l.brand === logo.brand).length}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
<div class="format-row">
|
||||
<span><strong>Format:</strong> {logo.format}</span>
|
||||
{#if logo.colors}
|
||||
<div class="color-switcher-preview align-right">
|
||||
<span
|
||||
class="color-circle color-reset"
|
||||
title="Reset to theme color"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
aria-label="Reset to theme color"
|
||||
style="background: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: none;"
|
||||
on:click|stopPropagation={() => logo._activeColor = undefined}
|
||||
on:keydown|stopPropagation={(e) => (e.key === 'Enter' || e.key === ' ') && (logo._activeColor = undefined)}
|
||||
>
|
||||
<svg width="100%" height="100%" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg"><path d="M400,0c220.766,0 400,179.234 400,400c0,220.766 -179.234,400 -400,400c-220.766,0 -400,-179.234 -400,-400c0,-220.766 179.234,-400 400,-400Zm-251.006,583.082l434.088,-434.088c-51.359,-37.541 -114.652,-59.71 -183.082,-59.71c-171.489,0 -310.716,139.227 -310.716,310.716c0,68.43 22.169,131.723 59.71,183.082Zm502.495,-365.501l-433.908,433.908c51.241,37.248 114.283,59.227 182.419,59.227c171.489,-0 310.716,-139.227 310.716,-310.716c-0,-68.136 -21.979,-131.178 -59.227,-182.419Z" fill="#33363f"/></svg>
|
||||
</span>
|
||||
{#if logo.sets}
|
||||
{#each Object.entries(logo.sets) as [setName, setConfig], i}
|
||||
<span
|
||||
class="color-circle set-circle"
|
||||
title={`Color Set ${i + 1}: ${setName}`}
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}}
|
||||
on:keydown|stopPropagation={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}
|
||||
}}
|
||||
style="padding: 0; overflow: hidden;"
|
||||
>
|
||||
{@html generateColorSetCircle(logo.colors, setConfig)}
|
||||
</span>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each Object.entries(logo.colors) as [colorName, colorValue], i}
|
||||
<span
|
||||
class="color-circle"
|
||||
title={colorName.replace('_', ' ')}
|
||||
style="background:{colorValue}"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => logo._activeColor = colorValue}
|
||||
on:keydown|stopPropagation={(e) => (e.key === 'Enter' || e.key === ' ') && (logo._activeColor = colorValue)}
|
||||
></span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-actions">
|
||||
<Actions {logo} {onCopy} {onDownload} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="no-results">No logos found matching your search criteria.</p>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
.logo-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: 1.5rem;
|
||||
}
|
||||
.logo-image {
|
||||
height: 260px;
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
position: relative;
|
||||
}
|
||||
.logo-info {
|
||||
padding: 1rem;
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.no-results {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.color-switcher-preview.align-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* Removed unused styles */
|
||||
|
||||
.logo-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.brand-filter-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
padding: 0.3em 0.8em 0.1em 0.3em;
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
z-index: 2;
|
||||
margin-left: 0.5em;
|
||||
position: relative;
|
||||
}
|
||||
.brand-filter-btn:hover {
|
||||
background: var(--color-accent, #4f8cff);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.brand-count {
|
||||
font-size: 0.85em;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
} .set-circle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.logo-card {
|
||||
background: var(--color-card);
|
||||
color: var(--color-text);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||
min-width: 320px;
|
||||
}
|
||||
|
||||
.logo-grid .logo-item .logo-image {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
export let logos = [];
|
||||
export let displayLogos = [];
|
||||
export let theme;
|
||||
export let setTheme;
|
||||
export let theme = "system";
|
||||
export let setTheme = () => {}; // Added default function to prevent errors
|
||||
export let viewMode;
|
||||
export let setGridView;
|
||||
export let setListView;
|
||||
@@ -187,7 +187,7 @@
|
||||
+ Tag{selectedTags.length ? "" : "s"}
|
||||
</button>
|
||||
{#if tagDropdownOpen}
|
||||
<div class="dropdown-list">
|
||||
<div class="dropdown-list" style="z-index: 100;">
|
||||
{#each allTags.filter((t) => !selectedTags.includes(t.text)) as tagObj}
|
||||
<button
|
||||
class="dropdown-tag"
|
||||
|
||||
@@ -1,290 +1,69 @@
|
||||
<script>
|
||||
import Preview from "./Preview.svelte";
|
||||
import Actions from "./Actions.svelte";
|
||||
import InlineSvg from "./InlineSvg.svelte";
|
||||
import { getThemeColor, getDefaultLogoColor } from "../utils/colorTheme.js";
|
||||
import { generateColorSetCircle } from "../utils/colorCircles.js";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
import CardList from './CardList.svelte';
|
||||
import CardSquare from './CardSquare.svelte';
|
||||
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
||||
|
||||
export let logos = [];
|
||||
export let allLogos = [];
|
||||
export let onCopy;
|
||||
export let onDownload;
|
||||
export let setSearchQuery;
|
||||
export let allLogos = [];
|
||||
export let theme;
|
||||
export let viewMode = "grid"; // "grid" or "list"
|
||||
export let setTheme = () => {}; // Add setTheme prop with default no-op function
|
||||
|
||||
let showModal = false;
|
||||
let selectedLogo = null;
|
||||
|
||||
let theme = getTheme(); function openPreview(logo) {
|
||||
// Navigate to preview page instead of showing modal
|
||||
const previewUrl = `#/preview/${encodeURIComponent(logo.name.replace(/\s+/g, '-').toLowerCase())}`;
|
||||
window.location.href = previewUrl;
|
||||
}
|
||||
|
||||
function isSvgLogo(logo) {
|
||||
return logo.format && logo.format.toLowerCase() === "svg";
|
||||
}
|
||||
|
||||
function getTheme() {
|
||||
if (typeof window !== "undefined" && window.matchMedia) {
|
||||
return window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light";
|
||||
}
|
||||
return "light";
|
||||
}
|
||||
|
||||
function handleThemeChange(e) {
|
||||
theme = e.matches ? "dark" : "light";
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
mql.addEventListener("change", handleThemeChange);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
mql.removeEventListener("change", handleThemeChange);
|
||||
});
|
||||
|
||||
$: getLogoThemeColor = (logo) => getDefaultLogoColor(logo.colors, theme);
|
||||
|
||||
$: {
|
||||
if (logos && logos.length) {
|
||||
logos.forEach((logo) => {
|
||||
if (logo.colors) {
|
||||
const themeColor = getDefaultLogoColor(logo.colors, theme);
|
||||
const activeColor = logo._activeColor || themeColor;
|
||||
console.log(
|
||||
"[LogoList] Logo:",
|
||||
logo.name,
|
||||
"| Theme:",
|
||||
theme,
|
||||
"| Theme color:",
|
||||
themeColor,
|
||||
"| Active color:",
|
||||
activeColor,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
$: getLogoThemeColor = logo => getDefaultLogoColor(logo.colors, theme);
|
||||
</script>
|
||||
|
||||
<div class="logo-list">
|
||||
<div class={`logos-container ${viewMode}-view`}>
|
||||
{#each logos as logo}
|
||||
<div class="logo-item">
|
||||
<div
|
||||
class="logo-preview"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Preview {logo.name}"
|
||||
on:click={() => openPreview(logo)}
|
||||
on:keydown={(e) =>
|
||||
(e.key === "Enter" || e.key === " ") && openPreview(logo)}
|
||||
style="cursor:pointer;"
|
||||
>
|
||||
{#if isSvgLogo(logo)}
|
||||
<InlineSvg
|
||||
path={logo.path}
|
||||
color={logo.colors
|
||||
? logo._activeColor || getLogoThemeColor(logo)
|
||||
: undefined}
|
||||
colorConfig={logo.colors ? logo.colorConfig : undefined}
|
||||
targets={logo.targets}
|
||||
sets={logo.sets}
|
||||
colors={logo.colors}
|
||||
activeSet={logo._activeSet}
|
||||
alt={logo.name}
|
||||
/>
|
||||
{:else}
|
||||
<img src={logo.path} alt={logo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-info">
|
||||
<div class="logo-list-title-row">
|
||||
<h3>{logo.name}</h3>
|
||||
</div>
|
||||
<div class="format-row">
|
||||
<span><strong>Format:</strong> {logo.format}</span>
|
||||
</div>
|
||||
{#if logo.colors}
|
||||
<div class="color-switcher-preview align-left">
|
||||
<span
|
||||
class="color-circle color-reset"
|
||||
title="Reset to theme color"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
aria-label="Reset to theme color"
|
||||
style="background: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: none;"
|
||||
on:click|stopPropagation={() => (logo._activeColor = undefined)}
|
||||
on:keydown|stopPropagation={(e) =>
|
||||
(e.key === "Enter" || e.key === " ") &&
|
||||
(logo._activeColor = undefined)}
|
||||
>
|
||||
<svg width="100%" height="100%" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg"><path d="M400,0c220.766,0 400,179.234 400,400c0,220.766 -179.234,400 -400,400c-220.766,0 -400,-179.234 -400,-400c0,-220.766 179.234,-400 400,-400Zm-251.006,583.082l434.088,-434.088c-51.359,-37.541 -114.652,-59.71 -183.082,-59.71c-171.489,0 -310.716,139.227 -310.716,310.716c0,68.43 22.169,131.723 59.71,183.082Zm502.495,-365.501l-433.908,433.908c51.241,37.248 114.283,59.227 182.419,59.227c171.489,-0 310.716,-139.227 310.716,-310.716c-0,-68.136 -21.979,-131.178 -59.227,-182.419Z" fill="#33363f"/></svg>
|
||||
</span>
|
||||
{#if logo.sets}
|
||||
{#each Object.entries(logo.sets) as [setName, setConfig], i}
|
||||
<span
|
||||
class="color-circle set-circle"
|
||||
title={`Color Set ${i + 1}: ${setName}`}
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() => {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}}
|
||||
on:keydown|stopPropagation={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
logo._activeColor = Object.values(logo.colors)[i % Object.keys(logo.colors).length];
|
||||
logo._activeSet = setName;
|
||||
}
|
||||
}}
|
||||
style="padding: 0; overflow: hidden;"
|
||||
>
|
||||
{@html generateColorSetCircle(logo.colors, setConfig)}
|
||||
</span>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each Object.entries(logo.colors) as [colorName, colorValue]}
|
||||
<span
|
||||
class="color-circle"
|
||||
title={colorName.replace('_', ' ')}
|
||||
style={`background:${colorValue}`}
|
||||
tabindex="0"
|
||||
role="button"
|
||||
on:click|stopPropagation={() =>
|
||||
(logo._activeColor = colorValue)}
|
||||
on:keydown|stopPropagation={(e) =>
|
||||
(e.key === "Enter" || e.key === " ") &&
|
||||
(logo._activeColor = colorValue)}
|
||||
></span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="logo-actions">
|
||||
<button
|
||||
class="brand-filter-btn common-btn"
|
||||
title="Filter by brand"
|
||||
on:click={() => {
|
||||
console.log("List: Filtering by brand:", logo.brand);
|
||||
setSearchQuery(logo.brand);
|
||||
// Update URL with search param
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set('search', logo.brand);
|
||||
const newUrl = window.location.pathname + (params.toString() ? '?' + params.toString() : '');
|
||||
history.replaceState(null, '', newUrl);
|
||||
}}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
|
||||
<path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M20 4H4v2l6 6v8.5l4-2.5v-6l6-6V4z"/>
|
||||
</svg>
|
||||
{#if allLogos && allLogos.filter(l => l.brand === logo.brand).length > 1}
|
||||
<span class="brand-count-index">{allLogos.filter(l => l.brand === logo.brand).length}</span>
|
||||
{/if}
|
||||
</button>
|
||||
<Actions {logo} {onCopy} {onDownload} />
|
||||
</div>
|
||||
</div>
|
||||
{#if viewMode === "grid"}
|
||||
<CardSquare
|
||||
{logo}
|
||||
{theme}
|
||||
{onCopy}
|
||||
{onDownload}
|
||||
{setSearchQuery}
|
||||
{allLogos}
|
||||
{setTheme}
|
||||
/>
|
||||
{:else}
|
||||
<CardList
|
||||
{logo}
|
||||
{theme}
|
||||
{onCopy}
|
||||
{onDownload}
|
||||
{setSearchQuery}
|
||||
{allLogos}
|
||||
{setTheme}
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
<p class="no-results">No logos found matching your search criteria.</p>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
:global(.logo-item) {
|
||||
background: var(--color-card);
|
||||
color: var(--color-text);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
display: grid;
|
||||
grid-template-columns: 80px 2fr 3fr 150px;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
transition:
|
||||
background 0.2s,
|
||||
color 0.2s;
|
||||
}
|
||||
.logo-preview {
|
||||
height: 100px;
|
||||
width: 80px;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
.logos-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.logo-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
.grid-view {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.list-view {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.no-results {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
color: #666;
|
||||
}
|
||||
.color-switcher-preview.align-left {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.brand-filter-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
padding: 0.2em;
|
||||
border-radius: 4px;
|
||||
transition:
|
||||
background 0.2s,
|
||||
color 0.2s;
|
||||
z-index: 2;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
.brand-filter-btn:hover {
|
||||
background: var(--color-accent-light, #e0f0ff);
|
||||
color: #fff;
|
||||
}
|
||||
.brand-filter-btn.common-btn {
|
||||
background: var(--secondary-color);
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.4em 0.8em 0.4em 0.3em;
|
||||
border-radius: 6px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1em;
|
||||
transition: background 0.2s, color 0.2s;
|
||||
margin-left: 0.5em;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.04);
|
||||
position: relative;
|
||||
}
|
||||
.brand-filter-btn.common-btn:hover {
|
||||
background: var(--color-accent-dark, #3576c7);
|
||||
color: #fff;
|
||||
}
|
||||
.brand-count-index {
|
||||
position: absolute;
|
||||
font-size: 0.85em;
|
||||
bottom: 0.1em;
|
||||
right: 0.3em;
|
||||
}
|
||||
.logo-list-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.set-circle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
grid-column: 1 / -1; /* For grid view */
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
export let show = false;
|
||||
export let logo = null;
|
||||
export let theme;
|
||||
export let setTheme = () => {}; // Function to update theme
|
||||
export const openLogoByAnchor = () => {};
|
||||
export let onDownload = (path, name) => {
|
||||
const a = document.createElement("a");
|
||||
|
||||
116
src/components/RouteHeader.svelte
Normal file
116
src/components/RouteHeader.svelte
Normal file
@@ -0,0 +1,116 @@
|
||||
<script>
|
||||
export let searchQuery = "";
|
||||
export let setSearchQuery = () => {};
|
||||
export const viewMode = "grid";
|
||||
// eslint-disable-next-line
|
||||
export let theme = "system";
|
||||
export let setTheme = () => {};
|
||||
|
||||
function onInput(event) {
|
||||
searchQuery = event.target.value;
|
||||
setSearchQuery(searchQuery);
|
||||
// Update URL with search param
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (searchQuery) {
|
||||
params.set("search", searchQuery);
|
||||
} else {
|
||||
params.delete("search");
|
||||
}
|
||||
const newUrl =
|
||||
window.location.pathname +
|
||||
(params.toString() ? "?" + params.toString() : "");
|
||||
history.replaceState(null, "", newUrl);
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="main-header">
|
||||
<div class="header-row">
|
||||
<div class="header-title">
|
||||
<h1>Logo Gallery</h1>
|
||||
</div>
|
||||
|
||||
<div class="theme-switcher">
|
||||
<div class="theme-switch-group">
|
||||
<button
|
||||
on:click={() => setTheme("system")}
|
||||
class:active={theme === "system"}
|
||||
aria-label="System theme"
|
||||
>
|
||||
System
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setTheme("light")}
|
||||
class:active={theme === "light"}
|
||||
aria-label="Light mode"
|
||||
>
|
||||
Light
|
||||
</button>
|
||||
<button
|
||||
on:click={() => setTheme("dark")}
|
||||
class:active={theme === "dark"}
|
||||
aria-label="Dark mode"
|
||||
>
|
||||
Dark
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-row">
|
||||
<div class="search-bar">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search logos..."
|
||||
bind:value={searchQuery}
|
||||
on:input={onInput}
|
||||
aria-label="Search logos"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.main-header {
|
||||
padding: 1rem;
|
||||
background: var(--color-card);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.header-title h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.search-bar input {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 4px;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.theme-switch-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 0.5rem 1rem;
|
||||
background: var(--color-bg);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.active {
|
||||
background: var(--color-accent);
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user