mirror of
https://github.com/shadoll/sLogos.git
synced 2025-12-20 09:31:59 +00:00
Compare commits
1 Commits
4ee8757577
...
restore1
| Author | SHA1 | Date | |
|---|---|---|---|
| faa14bfe1b |
@@ -55,15 +55,12 @@
|
|||||||
applyTheme();
|
applyTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute all unique tags as objects with text and optional color
|
// Compute all unique tags as strings
|
||||||
$: allTags = Array.from(
|
$: allTags = Array.from(
|
||||||
new Map(
|
new Set(
|
||||||
logos.flatMap(logo => (logo.tags || []).map(tag => {
|
logos.flatMap(logo => (logo.tags || []))
|
||||||
if (typeof tag === 'string') return [tag, { text: tag }];
|
)
|
||||||
return [tag.text, tag];
|
).map(tag => typeof tag === 'object' ? tag.text : tag);
|
||||||
}))
|
|
||||||
).values()
|
|
||||||
).sort((a, b) => a.text.localeCompare(b.text));
|
|
||||||
|
|
||||||
$: filteredLogos = logos.filter(logo => {
|
$: filteredLogos = logos.filter(logo => {
|
||||||
const matchesSearch = logo.name.toLowerCase().includes(searchQuery.toLowerCase());
|
const matchesSearch = logo.name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||||
@@ -179,7 +176,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getTagObj(text) {
|
function getTagObj(text) {
|
||||||
return allTags.find(t => t.text === text);
|
return { text };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for outside click to close dropdown
|
// Listen for outside click to close dropdown
|
||||||
@@ -215,17 +212,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="tag-filter">
|
<div class="tag-filter">
|
||||||
{#each selectedTags as tagText}
|
{#each selectedTags as tagText}
|
||||||
{#if getTagObj(tagText)}
|
<button
|
||||||
<button
|
class="selected-tag"
|
||||||
class="selected-tag"
|
aria-label={`Remove tag: ${tagText}`}
|
||||||
style={getTagObj(tagText).color ? `background: ${getTagObj(tagText).color}; color: #fff;` : ''}
|
on:click={() => removeTag(tagText)}
|
||||||
aria-label={`Remove tag: ${getTagObj(tagText).text}`}
|
>
|
||||||
on:click={() => removeTag(getTagObj(tagText).text)}
|
<span>{tagText}</span>
|
||||||
>
|
<span class="close">×</span>
|
||||||
{getTagObj(tagText).text}
|
</button>
|
||||||
<span class="close">×</span>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
<div class="tag-dropdown">
|
<div class="tag-dropdown">
|
||||||
<button class="dropdown-toggle" on:click={toggleDropdown} aria-label="Add tag filter">
|
<button class="dropdown-toggle" on:click={toggleDropdown} aria-label="Add tag filter">
|
||||||
@@ -233,15 +227,15 @@
|
|||||||
</button>
|
</button>
|
||||||
{#if tagDropdownOpen}
|
{#if tagDropdownOpen}
|
||||||
<div class="dropdown-list">
|
<div class="dropdown-list">
|
||||||
{#each allTags.filter(t => !selectedTags.includes(t.text)) as tagObj}
|
{#each allTags.filter(tag => !selectedTags.includes(tag)) as tag}
|
||||||
<button
|
<button
|
||||||
class="dropdown-tag"
|
class="dropdown-tag"
|
||||||
style={tagObj.color ? `background: ${tagObj.color}; color: #fff;` : ''}
|
on:click={() => toggleTag(tag)}
|
||||||
on:click={() => addTag(tagObj.text)}
|
>
|
||||||
aria-label={`Add tag: ${tagObj.text}`}
|
{tag}
|
||||||
>{tagObj.text}</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
{#if allTags.filter(t => !selectedTags.includes(t.text)).length === 0}
|
{#if allTags.filter(tag => !selectedTags.includes(tag)).length === 0}
|
||||||
<span class="no-tags">No more tags</span>
|
<span class="no-tags">No more tags</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
|
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
|
||||||
import InlineSvg from './InlineSvg.svelte';
|
import InlineSvg from './InlineSvg.svelte';
|
||||||
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
||||||
import tagsData from '../../public/data/tags.json';
|
|
||||||
console.log('Loaded tagsData:', tagsData);
|
|
||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
export let logo = null;
|
export let logo = null;
|
||||||
@@ -24,11 +22,9 @@
|
|||||||
return logo && logo.format && logo.format.toLowerCase() === 'svg';
|
return logo && logo.format && logo.format.toLowerCase() === 'svg';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to get tag object from tags.json by text
|
// Helper to get tag object - simplified without tags.json
|
||||||
function getTagObj(text) {
|
function getTagObj(text) {
|
||||||
const tag = tagsData && typeof tagsData === 'object' && tagsData[text] ? { text, ...tagsData[text] } : { text };
|
return { text: typeof text === 'object' ? text.text : text };
|
||||||
console.log('[LogoModal] Tag lookup:', text, tag, tagsData);
|
|
||||||
return tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use $theme directly, do not cache in a function
|
// Always use $theme directly, do not cache in a function
|
||||||
@@ -45,7 +41,6 @@ $: getLogoThemeColor = logo => getDefaultLogoColor(logo.colors, theme);
|
|||||||
$: if (logo && logo.tags && logo.tags.length) {
|
$: if (logo && logo.tags && logo.tags.length) {
|
||||||
logo.tags.forEach(tag => {
|
logo.tags.forEach(tag => {
|
||||||
console.log('[LogoModal] Tag:', tag);
|
console.log('[LogoModal] Tag:', tag);
|
||||||
getTagObj(tag);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,11 +124,7 @@ $: getLogoThemeColor = logo => getDefaultLogoColor(logo.colors, theme);
|
|||||||
{#if logo.tags && logo.tags.length}
|
{#if logo.tags && logo.tags.length}
|
||||||
<div class="logo-tags">
|
<div class="logo-tags">
|
||||||
{#each logo.tags as tag}
|
{#each logo.tags as tag}
|
||||||
{#if getTagObj(tag).color}
|
<span class="logo-tag">{typeof tag === 'object' ? tag.text : tag}</span>
|
||||||
<span class="logo-tag" style={`background:${getTagObj(tag).color}`}>{getTagObj(tag).text}</span>
|
|
||||||
{:else}
|
|
||||||
<span class="logo-tag">{getTagObj(tag).text}</span>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -7,10 +7,6 @@
|
|||||||
export let onPreview = null;
|
export let onPreview = null;
|
||||||
import InlineSvg from './InlineSvg.svelte';
|
import InlineSvg from './InlineSvg.svelte';
|
||||||
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
import { getDefaultLogoColor } from '../utils/colorTheme.js';
|
||||||
import tagsData from '../../public/data/tags.json';
|
|
||||||
function getTagObj(text) {
|
|
||||||
return tagsData[text] ? { text, ...tagsData[text] } : { text };
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="logo-row {view}">
|
<div class="logo-row {view}">
|
||||||
@@ -53,11 +49,7 @@
|
|||||||
{#if logo.tags && logo.tags.length}
|
{#if logo.tags && logo.tags.length}
|
||||||
<div class="logo-tags">
|
<div class="logo-tags">
|
||||||
{#each logo.tags as tag}
|
{#each logo.tags as tag}
|
||||||
{#if getTagObj(tag).color}
|
<span class="logo-tag">{typeof tag === 'object' ? tag.text : tag}</span>
|
||||||
<span class="logo-tag" style={`background:${getTagObj(tag).color}`}>{getTagObj(tag).text}</span>
|
|
||||||
{:else}
|
|
||||||
<span class="logo-tag">{getTagObj(tag).text}</span>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user