mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-28 00:10:03 +03:00
Adds empty homepage option, and a search-based home option
This commit is contained in:
1 parent
45e6d11ac9
commit
48a36d9be1
17 files changed
+691
-226
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { ALL_PAGES, type NavItem } from '$lib/constants/nav';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { debounce } from '$lib/utils/debounce';
|
||||
|
||||
let {
|
||||
filteredTools = $bindable(),
|
||||
@@ -99,11 +100,17 @@
|
||||
return results;
|
||||
}
|
||||
|
||||
// Debounced search function (only debounce the filtering, not the input value)
|
||||
const debouncedSearch = debounce((...args: unknown[]) => {
|
||||
const query = (args[0] as string) ?? '';
|
||||
filteredTools = performSearch(query);
|
||||
}, 220);
|
||||
|
||||
// Handle search input changes
|
||||
function handleSearch(event: Event) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
searchQuery = target.value;
|
||||
filteredTools = performSearch(searchQuery);
|
||||
debouncedSearch(searchQuery);
|
||||
}
|
||||
|
||||
// Open search input
|
||||
|
||||
@@ -221,30 +221,11 @@
|
||||
>
|
||||
{lang.flag}
|
||||
{lang.name}
|
||||
{!lang.available ? ' (Soon)' : ''}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Navbar Display -->
|
||||
<div class="settings-section">
|
||||
<h3>Top Navigation</h3>
|
||||
<div class="navbar-select-wrapper">
|
||||
<select class="navbar-select" value={$currentNavbarDisplay} onchange={handleNavbarDisplayChange}>
|
||||
{#each navbarDisplayOptions as option (option.id)}
|
||||
<option value={option.id}>{option.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<div class="dropdown-icon">
|
||||
<Icon name="chevron-down" size="xs" />
|
||||
</div>
|
||||
</div>
|
||||
<small class="navbar-description">
|
||||
{navbarDisplayOptions.find((opt) => opt.id === $currentNavbarDisplay)?.description}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Homepage Layout -->
|
||||
<div class="settings-section">
|
||||
<h3>Homepage Layout</h3>
|
||||
@@ -263,6 +244,24 @@
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Navbar Display -->
|
||||
<div class="settings-section">
|
||||
<h3>Top Navigation</h3>
|
||||
<div class="navbar-select-wrapper">
|
||||
<select class="navbar-select" value={$currentNavbarDisplay} onchange={handleNavbarDisplayChange}>
|
||||
{#each navbarDisplayOptions as option (option.id)}
|
||||
<option value={option.id}>{option.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<div class="dropdown-icon">
|
||||
<Icon name="chevron-down" size="xs" />
|
||||
</div>
|
||||
</div>
|
||||
<small class="navbar-description">
|
||||
{navbarDisplayOptions.find((opt) => opt.id === $currentNavbarDisplay)?.description}
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Accessibility Options -->
|
||||
<div class="settings-section">
|
||||
<h3>Accessibility</h3>
|
||||
@@ -371,7 +370,7 @@
|
||||
|
||||
.settings-section {
|
||||
&:not(:last-child) {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
margin-bottom: var(--spacing-md);
|
||||
padding-bottom: var(--spacing-md);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
@@ -466,9 +465,9 @@
|
||||
}
|
||||
|
||||
.language-dropdown {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
|
||||
}
|
||||
|
||||
.language-option {
|
||||
@@ -573,6 +572,7 @@
|
||||
line-height: 1.3;
|
||||
margin-top: var(--spacing-xs);
|
||||
display: block;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.accessibility-options {
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
import { frequentlyUsedTools, toolUsage } from '$lib/stores/toolUsage';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
interface Props {
|
||||
embedded?: boolean; // Whether this is embedded in a page vs popup modal
|
||||
}
|
||||
|
||||
let { embedded = false }: Props = $props();
|
||||
|
||||
// Create reactive state using individual variables
|
||||
let isOpen = $state(false);
|
||||
let query = $state('');
|
||||
@@ -88,7 +94,9 @@
|
||||
const result = results[index];
|
||||
if (result) {
|
||||
goto(result.href);
|
||||
close();
|
||||
if (!embedded) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +106,15 @@
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
e.preventDefault();
|
||||
close();
|
||||
if (embedded) {
|
||||
// In embedded mode, just clear the input
|
||||
query = '';
|
||||
results = [];
|
||||
selectedIndex = 0;
|
||||
} else {
|
||||
// In modal mode, close the search
|
||||
close();
|
||||
}
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
e.preventDefault();
|
||||
@@ -130,174 +146,199 @@
|
||||
onMount(() => {
|
||||
bookmarks.init();
|
||||
toolUsage.init();
|
||||
document.addEventListener('keydown', handleGlobalKeydown);
|
||||
|
||||
// Handle browser back button on mobile
|
||||
const handlePopState = (e: PopStateEvent) => {
|
||||
if (isOpen && window.innerWidth <= 768) {
|
||||
e.preventDefault();
|
||||
close();
|
||||
}
|
||||
};
|
||||
// Only register global keyboard shortcut for modal mode
|
||||
if (!embedded) {
|
||||
document.addEventListener('keydown', handleGlobalKeydown);
|
||||
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
// Handle browser back button on mobile
|
||||
const handlePopState = (e: PopStateEvent) => {
|
||||
if (isOpen && window.innerWidth <= 768) {
|
||||
e.preventDefault();
|
||||
close();
|
||||
}
|
||||
};
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleGlobalKeydown);
|
||||
window.removeEventListener('popstate', handlePopState);
|
||||
};
|
||||
window.addEventListener('popstate', handlePopState);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleGlobalKeydown);
|
||||
window.removeEventListener('popstate', handlePopState);
|
||||
};
|
||||
} else {
|
||||
// In embedded mode, always show search and focus on mount
|
||||
isOpen = true;
|
||||
setTimeout(() => searchInput?.focus(), 100);
|
||||
}
|
||||
});
|
||||
|
||||
export { showSearch };
|
||||
</script>
|
||||
|
||||
<!-- Trigger Button -->
|
||||
<button
|
||||
class="action-button search-trigger"
|
||||
onclick={openSearch}
|
||||
aria-label="Open search"
|
||||
use:tooltip={`Search (${shortcutKey}+K)`}
|
||||
>
|
||||
<Icon name="search" size="sm" />
|
||||
</button>
|
||||
|
||||
<!-- Search Modal -->
|
||||
{#if isOpen}
|
||||
<div
|
||||
class="search-overlay"
|
||||
onclick={close}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') close();
|
||||
}}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
aria-label="Close search"
|
||||
<!-- Trigger Button (only in modal mode) -->
|
||||
{#if !embedded}
|
||||
<button
|
||||
class="action-button search-trigger"
|
||||
onclick={openSearch}
|
||||
aria-label="Open search"
|
||||
use:tooltip={`Search (${shortcutKey}+K)`}
|
||||
>
|
||||
<div
|
||||
class="search-modal"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') close();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div class="search-header">
|
||||
<Icon name="search" size="sm" />
|
||||
<input
|
||||
bind:this={searchInput}
|
||||
bind:value={query}
|
||||
onkeydown={handleKeydown}
|
||||
placeholder="Search tools and pages..."
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<button class="close-btn" onclick={close} aria-label="Close search">
|
||||
<Icon name="x" size="sm" />
|
||||
</button>
|
||||
</div>
|
||||
<Icon name="search" size="sm" />
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if query.trim() && results.length > 0}
|
||||
<div class="search-results">
|
||||
{#each results as result, index (result.href)}
|
||||
<!-- Search Content Snippet -->
|
||||
{#snippet searchContent()}
|
||||
<div class="search-header">
|
||||
<Icon name="search" size="sm" />
|
||||
<input
|
||||
bind:this={searchInput}
|
||||
bind:value={query}
|
||||
onkeydown={handleKeydown}
|
||||
placeholder="Search tools and pages..."
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
{#if !embedded}
|
||||
<button class="close-btn" onclick={close} aria-label="Close search">
|
||||
<Icon name="x" size="sm" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if query.trim() && results.length > 0}
|
||||
<div class="search-results">
|
||||
{#each results as result, index (result.href)}
|
||||
<button
|
||||
class="result-item"
|
||||
class:selected={index === selectedIndex}
|
||||
onclick={() => selectResult(index)}
|
||||
onmouseenter={() => (selectedIndex = index)}
|
||||
>
|
||||
<div class="result-content">
|
||||
<div class="result-title">
|
||||
<Icon name={result.icon || 'search'} size="xs" />
|
||||
{result.label}
|
||||
</div>
|
||||
{#if result.description}
|
||||
<div class="result-description">{result.description}</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="result-meta">
|
||||
{#if index === selectedIndex}
|
||||
<Icon name="link" size="xs" />
|
||||
{/if}
|
||||
<span class="result-path">{result.href}</span>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if query.trim()}
|
||||
<div class="no-results">
|
||||
<Icon name="search" size="md" />
|
||||
<span>No results found for "{query}"</span>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="search-help">
|
||||
<div class="help-item">
|
||||
<Icon name="search" size="xs" />
|
||||
<span>Search for tools, calculators, and diagnostics</span>
|
||||
</div>
|
||||
<div class="help-item">
|
||||
<Icon name="navigation" size="xs" />
|
||||
<span>Use ↑↓ to navigate, Enter to select</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $bookmarks.length > 0}
|
||||
<div class="bookmarks-section">
|
||||
<div class="bookmarks-header">
|
||||
<Icon name="bookmarks" size="xs" />
|
||||
<span>Bookmarked Tools</span>
|
||||
</div>
|
||||
<div class="bookmarks-list">
|
||||
{#each $bookmarks.slice(0, 6) as bookmark, _index (bookmark.href)}
|
||||
<button
|
||||
class="result-item"
|
||||
class:selected={index === selectedIndex}
|
||||
onclick={() => selectResult(index)}
|
||||
onmouseenter={() => (selectedIndex = index)}
|
||||
class="bookmark-item"
|
||||
onclick={() => {
|
||||
goto(bookmark.href);
|
||||
if (!embedded) close();
|
||||
}}
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="result-content">
|
||||
<div class="result-title">
|
||||
<Icon name={result.icon || 'search'} size="xs" />
|
||||
{result.label}
|
||||
</div>
|
||||
{#if result.description}
|
||||
<div class="result-description">{result.description}</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="result-meta">
|
||||
{#if index === selectedIndex}
|
||||
<Icon name="link" size="xs" />
|
||||
{/if}
|
||||
<span class="result-path">{result.href}</span>
|
||||
<div class="bookmark-icon">
|
||||
<Icon name={bookmark.icon} size="xs" />
|
||||
</div>
|
||||
<span class="bookmark-label">{bookmark.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{:else if query.trim()}
|
||||
<div class="no-results">
|
||||
<Icon name="search" size="md" />
|
||||
<span>No results found for "{query}"</span>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="search-help">
|
||||
<div class="help-item">
|
||||
<Icon name="search" size="xs" />
|
||||
<span>Search for tools, calculators, and diagnostics</span>
|
||||
</div>
|
||||
<div class="help-item">
|
||||
<Icon name="navigation" size="xs" />
|
||||
<span>Use ↑↓ to navigate, Enter to select</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $bookmarks.length > 0}
|
||||
<div class="bookmarks-section">
|
||||
<div class="bookmarks-header">
|
||||
<Icon name="bookmarks" size="xs" />
|
||||
<span>Bookmarked Tools</span>
|
||||
</div>
|
||||
<div class="bookmarks-list">
|
||||
{#each $bookmarks.slice(0, 6) as bookmark, _index (bookmark.href)}
|
||||
<button
|
||||
class="bookmark-item"
|
||||
onclick={() => {
|
||||
goto(bookmark.href);
|
||||
close();
|
||||
}}
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="bookmark-icon">
|
||||
<Icon name={bookmark.icon} size="xs" />
|
||||
</div>
|
||||
<span class="bookmark-label">{bookmark.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if $frequentlyUsedTools.length > 0}
|
||||
<div class="frequently-used-section">
|
||||
<div class="frequently-used-header">
|
||||
<Icon name="clock" size="xs" />
|
||||
<span>Most Used Tools</span>
|
||||
</div>
|
||||
<div class="frequently-used-list">
|
||||
{#each $frequentlyUsedTools.slice(0, 12) as tool, _index (tool.href)}
|
||||
<button
|
||||
class="frequently-used-item"
|
||||
onclick={() => {
|
||||
goto(tool.href);
|
||||
if (!embedded) close();
|
||||
}}
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="frequently-used-icon">
|
||||
<Icon name={tool.icon || ''} size="xs" />
|
||||
</div>
|
||||
<span class="frequently-used-label">{tool.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#if $frequentlyUsedTools.length > 0}
|
||||
<div class="frequently-used-section">
|
||||
<div class="frequently-used-header">
|
||||
<Icon name="clock" size="xs" />
|
||||
<span>Most Used Tools</span>
|
||||
</div>
|
||||
<div class="frequently-used-list">
|
||||
{#each $frequentlyUsedTools.slice(0, 12) as tool, _index (tool.href)}
|
||||
<button
|
||||
class="frequently-used-item"
|
||||
onclick={() => {
|
||||
goto(tool.href);
|
||||
close();
|
||||
}}
|
||||
tabindex="0"
|
||||
>
|
||||
<div class="frequently-used-icon">
|
||||
<Icon name={tool.icon || ''} size="xs" />
|
||||
</div>
|
||||
<span class="frequently-used-label">{tool.label}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
<!-- Search Modal/Embedded -->
|
||||
{#if isOpen}
|
||||
{#if embedded}
|
||||
<!-- Embedded mode: no overlay, direct content -->
|
||||
<div class="search-embedded" role="search">
|
||||
{@render searchContent()}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- Modal mode: with overlay -->
|
||||
<div
|
||||
class="search-overlay"
|
||||
onclick={close}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') close();
|
||||
}}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
aria-label="Close search"
|
||||
>
|
||||
<div
|
||||
class="search-modal"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') close();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
tabindex="-1"
|
||||
>
|
||||
{@render searchContent()}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
@@ -429,6 +470,7 @@
|
||||
&:hover,
|
||||
&.selected {
|
||||
background: var(--surface-hover);
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
@@ -655,4 +697,27 @@
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Embedded mode styles
|
||||
.search-embedded {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-md);
|
||||
overflow: hidden;
|
||||
animation: fadeIn var(--transition-normal);
|
||||
|
||||
.search-header {
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.search-help,
|
||||
.bookmarks-section,
|
||||
.frequently-used-section {
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -463,7 +463,7 @@
|
||||
|
||||
h3 {
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
line-height: 1.2;
|
||||
text-overflow: ellipsis;
|
||||
@@ -480,6 +480,7 @@
|
||||
height: 1.75rem;
|
||||
transition: all 0.25s;
|
||||
filter: saturate(0.9);
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
|
||||
@@ -35,5 +35,8 @@
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min-col-width, 280px)), 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-xl);
|
||||
&.compact {
|
||||
gap: calc(var(--spacing-md) - 0.25rem);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/constants/site';
|
||||
import { TOP_NAV, SUB_NAV, type NavItem, type NavGroup } from '$lib/constants/nav';
|
||||
import { TOP_NAV, SUB_NAV, type NavItem } from '$lib/constants/nav';
|
||||
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
|
||||
import SearchFilter from '$lib/components/furniture/SearchFilter.svelte';
|
||||
import { bookmarks } from '$lib/stores/bookmarks';
|
||||
import { frequentlyUsedTools, recentlyUsedTools } from '$lib/stores/toolUsage';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { extractNavItems } from '$lib/utils/nav';
|
||||
|
||||
interface Props {
|
||||
toolPages: NavItem[];
|
||||
@@ -14,19 +15,6 @@
|
||||
|
||||
let { toolPages, referencePages }: Props = $props();
|
||||
|
||||
// Helper to extract nav items from mixed structure
|
||||
function extractNavItems(items: (NavItem | NavGroup)[]): NavItem[] {
|
||||
const navItems: NavItem[] = [];
|
||||
for (const item of items) {
|
||||
if ('href' in item) {
|
||||
navItems.push(item);
|
||||
} else if ('title' in item && 'items' in item) {
|
||||
navItems.push(...item.items);
|
||||
}
|
||||
}
|
||||
return navItems;
|
||||
}
|
||||
|
||||
// Category configuration - easily extensible for future customization
|
||||
interface CategorySection {
|
||||
id: string;
|
||||
@@ -107,10 +95,13 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Minimal Hero -->
|
||||
<!-- Hero -->
|
||||
<section class="hero-categories">
|
||||
<h1>{site.title}</h1>
|
||||
<p class="hero-text">{site.heroDescription}</p>
|
||||
<div class="hero-bg"></div>
|
||||
<div class="hero-content">
|
||||
<h1>{site.title}</h1>
|
||||
<p class="hero-text">{site.heroDescription}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Search Filter -->
|
||||
@@ -202,15 +193,39 @@
|
||||
|
||||
<style lang="scss">
|
||||
.hero-categories {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding: var(--spacing-lg) 0 var(--spacing-md);
|
||||
padding: var(--spacing-2xl) var(--spacing-md) var(--spacing-xl);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
overflow: hidden;
|
||||
border-radius: var(--radius-lg);
|
||||
|
||||
.hero-bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(
|
||||
ellipse at center,
|
||||
color-mix(in srgb, var(--color-primary), transparent 94%),
|
||||
transparent 60%
|
||||
);
|
||||
animation:
|
||||
bgFadeIn 1s ease-out,
|
||||
bgPulse 8s ease-in-out 1s infinite;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.hero-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
animation: heroFadeIn 0.8s ease-out;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: var(--font-size-3xl);
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin: 0 0 var(--spacing-sm);
|
||||
line-height: 1.2;
|
||||
animation: heroFadeIn 0.8s ease-out 0.1s both;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: var(--font-size-2xl);
|
||||
@@ -222,6 +237,7 @@
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
animation: heroFadeIn 0.8s ease-out 0.2s both;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: var(--font-size-md);
|
||||
@@ -229,6 +245,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bgFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bgPulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes heroFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.categories-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -240,7 +286,10 @@
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
background: radial-gradient(var(--bg-tertiary), color-mix(in srgb, var(--bg-tertiary), var(--bg-primary) 25%));
|
||||
background: radial-gradient(
|
||||
color-mix(in srgb, var(--bg-tertiary), transparent 30%),
|
||||
color-mix(in srgb, var(--bg-tertiary), var(--bg-primary) 60%)
|
||||
);
|
||||
padding: var(--spacing-md);
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--border-primary);
|
||||
@@ -248,6 +297,7 @@
|
||||
break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
max-height: 36rem;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
animation: slideInFade 0.3s ease-out;
|
||||
|
||||
@@ -284,8 +334,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
padding-bottom: var(--spacing-sm);
|
||||
border-bottom: 1px solid var(--border-secondary);
|
||||
// padding-bottom: var(--spacing-sm);
|
||||
// border-bottom: 1px solid var(--border-secondary);
|
||||
|
||||
h2 {
|
||||
font-size: var(--font-size-lg);
|
||||
@@ -311,11 +361,17 @@
|
||||
}
|
||||
|
||||
// Full width sections
|
||||
.bookmarks-section,
|
||||
.full-width {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.bookmarks-section {
|
||||
background: none;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
// Usage row: 2/3 and 1/3 split
|
||||
.usage-row {
|
||||
display: grid;
|
||||
@@ -326,8 +382,8 @@
|
||||
grid-template-columns: 2fr 1fr;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
let filteredReference: NavItem[] = $state(referencePages);
|
||||
let searchQuery: string = $state('');
|
||||
|
||||
// Combined filtered list
|
||||
let allFiltered = $derived([...filteredTools, ...filteredReference]);
|
||||
|
||||
// Update filtered items when search changes
|
||||
$effect(() => {
|
||||
if (searchQuery.trim() === '') {
|
||||
@@ -53,7 +56,7 @@
|
||||
</section>
|
||||
|
||||
<!-- Search Filter -->
|
||||
<SearchFilter bind:filteredTools bind:searchQuery />
|
||||
<SearchFilter bind:filteredTools={allFiltered} bind:searchQuery />
|
||||
|
||||
{#if searchQuery.trim() === ''}
|
||||
<!-- Bookmarks Section -->
|
||||
@@ -88,7 +91,7 @@
|
||||
{/if}
|
||||
{:else}
|
||||
<!-- Combined Search Results -->
|
||||
<ToolsGrid idPrefix="search" tools={[...filteredTools, ...filteredReference]} {searchQuery} />
|
||||
<ToolsGrid idPrefix="search" tools={allFiltered} {searchQuery} />
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/constants/site';
|
||||
</script>
|
||||
|
||||
<div class="empty-layout">
|
||||
<h1>{site.title}</h1>
|
||||
<div class="search-hint">
|
||||
<kbd>⌘</kbd>
|
||||
<kbd>K</kbd>
|
||||
<span>to search</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.empty-layout {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 48vh;
|
||||
animation: slideDown 0.6s ease-out;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
h1 {
|
||||
opacity: 0.2;
|
||||
font-size: clamp(2rem, 5vw, 3rem);
|
||||
}
|
||||
|
||||
.search-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--spacing-sm);
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--text-secondary);
|
||||
opacity: 0;
|
||||
animation: fadeIn 0.8s ease-out 0.2s forwards;
|
||||
|
||||
kbd {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0 var(--spacing-sm);
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: inherit;
|
||||
font-size: var(--font-size-md);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
box-shadow: 0 2px 0 0 var(--border-secondary);
|
||||
}
|
||||
|
||||
span {
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
transform: translateY(-20px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -3,6 +3,7 @@
|
||||
import type { NavItem } from '$lib/constants/nav';
|
||||
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
|
||||
import SearchFilter from '$lib/components/furniture/SearchFilter.svelte';
|
||||
import { useToolSearch } from '$lib/composables/useToolSearch.svelte';
|
||||
|
||||
interface Props {
|
||||
toolPages: NavItem[];
|
||||
@@ -11,24 +12,8 @@
|
||||
|
||||
let { toolPages, referencePages }: Props = $props();
|
||||
|
||||
let filteredTools: NavItem[] = $state([...toolPages, ...referencePages]);
|
||||
let searchQuery: string = $state('');
|
||||
|
||||
// Update filtered items when search changes
|
||||
$effect(() => {
|
||||
const allPages = [...toolPages, ...referencePages];
|
||||
if (searchQuery.trim() === '') {
|
||||
filteredTools = allPages;
|
||||
} else {
|
||||
const query = searchQuery.toLowerCase().trim();
|
||||
filteredTools = allPages.filter(
|
||||
(tool) =>
|
||||
tool.label.toLowerCase().includes(query) ||
|
||||
tool.description?.toLowerCase().includes(query) ||
|
||||
tool.keywords?.some((keyword) => keyword.toLowerCase().includes(query)),
|
||||
);
|
||||
}
|
||||
});
|
||||
const allPages = $derived([...toolPages, ...referencePages]);
|
||||
const search = useToolSearch(allPages);
|
||||
</script>
|
||||
|
||||
<!-- Minimal Hero Section -->
|
||||
@@ -37,10 +22,10 @@
|
||||
</section>
|
||||
|
||||
<!-- Search Filter -->
|
||||
<SearchFilter bind:filteredTools bind:searchQuery />
|
||||
<SearchFilter bind:filteredTools={search.filtered} bind:searchQuery={search.query} />
|
||||
|
||||
<!-- Compact Tools Grid -->
|
||||
<ToolsGrid idPrefix="minimal" tools={filteredTools} {searchQuery} />
|
||||
<ToolsGrid idPrefix="minimal" tools={search.filtered} searchQuery={search.query} />
|
||||
|
||||
<style lang="scss">
|
||||
.hero-minimal {
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<script lang="ts">
|
||||
import GlobalSearch from '$lib/components/global/GlobalSearch.svelte';
|
||||
import { site } from '$lib/constants/site';
|
||||
</script>
|
||||
|
||||
<div class="homepage-search">
|
||||
<section class="hero-search">
|
||||
<div class="hero-bg"></div>
|
||||
<div class="hero-content">
|
||||
<h1>{site.title}</h1>
|
||||
<p class="hero-text">{site.heroDescription}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="search-container">
|
||||
<GlobalSearch embedded={true} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.homepage-search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.hero-search {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
|
||||
overflow: hidden;
|
||||
border-radius: var(--radius-lg);
|
||||
|
||||
.hero-bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(
|
||||
ellipse at center,
|
||||
color-mix(in srgb, var(--color-primary), transparent 94%),
|
||||
transparent 60%
|
||||
);
|
||||
animation:
|
||||
bgFadeIn 1s ease-out,
|
||||
bgPulse 8s ease-in-out 1s infinite;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.hero-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
animation: heroFadeIn 0.8s ease-out;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: var(--font-size-3xl);
|
||||
font-weight: 700;
|
||||
margin: 0 0 var(--spacing-sm);
|
||||
line-height: 1.2;
|
||||
animation: heroFadeIn 0.8s ease-out 0.1s both;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: var(--font-size-2xl);
|
||||
}
|
||||
}
|
||||
|
||||
.hero-text {
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
animation: heroFadeIn 0.8s ease-out 0.2s both;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
font-size: var(--font-size-md);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bgFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bgPulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes heroFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.search-container {
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
padding: 0 var(--spacing-md);
|
||||
}
|
||||
</style>
|
||||
@@ -19,12 +19,19 @@
|
||||
|
||||
let gridElement: HTMLDivElement;
|
||||
let iconHues: number[] = $state([]);
|
||||
let gridCols: number = $state(1);
|
||||
|
||||
// Memoized function to get grid column count
|
||||
function updateGridCols() {
|
||||
if (!gridElement) return;
|
||||
const gridStyle = window.getComputedStyle(gridElement);
|
||||
gridCols = gridStyle.gridTemplateColumns.split(' ').length;
|
||||
}
|
||||
|
||||
function updateIconColors() {
|
||||
if (!gridElement) return;
|
||||
|
||||
const gridStyle = window.getComputedStyle(gridElement);
|
||||
const gridCols = gridStyle.gridTemplateColumns.split(' ').length;
|
||||
updateGridCols();
|
||||
|
||||
iconHues = toolPages.map((_, index) => {
|
||||
const row = Math.floor(index / gridCols);
|
||||
@@ -34,6 +41,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
function getAnimDelay(index: number): number {
|
||||
if (!gridElement || gridCols === 0) return 0;
|
||||
const row = Math.floor(index / gridCols);
|
||||
const col = index % gridCols;
|
||||
return (row + col) * 0.03; // 30ms per diagonal step
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
bookmarks.init();
|
||||
updateIconColors();
|
||||
@@ -64,10 +78,11 @@
|
||||
recentTools: $recentlyUsedTools,
|
||||
})}
|
||||
{@const hue = iconHues[index] ?? 0}
|
||||
{@const animDelay = getAnimDelay(index)}
|
||||
<a
|
||||
href={tool.href}
|
||||
class="icon-link"
|
||||
style="--icon-hue: {hue}; --icon-color: hsl({hue}, {SATURATION}%, {LIGHTNESS}%);"
|
||||
style="--icon-hue: {hue}; --icon-color: hsl({hue}, {SATURATION}%, {LIGHTNESS}%); --anim-delay: {animDelay}s;"
|
||||
use:tooltip={tool.label}
|
||||
oncontextmenu={(e) => handleToolContextMenu(e, tool)}
|
||||
>
|
||||
@@ -153,6 +168,8 @@
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
animation: iconFadeIn 0.5s ease-out var(--anim-delay, 0s) forwards;
|
||||
transition:
|
||||
transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
|
||||
box-shadow 0.3s ease,
|
||||
@@ -207,4 +224,15 @@
|
||||
transform: scale(1.08) translateY(-1px) rotate(1deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes iconFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { NavItem } from '$lib/constants/nav';
|
||||
|
||||
/**
|
||||
* Composable for searching and filtering tools
|
||||
* @param tools Array of tools to search through
|
||||
* @returns Object with query and filtered state that can be bound
|
||||
*/
|
||||
export function useToolSearch(tools: NavItem[]) {
|
||||
const state = $state({
|
||||
query: '',
|
||||
filtered: tools,
|
||||
});
|
||||
|
||||
// Update filtered whenever query or tools change
|
||||
$effect(() => {
|
||||
if (!state.query.trim()) {
|
||||
state.filtered = tools;
|
||||
} else {
|
||||
const normalizedQuery = state.query.toLowerCase().trim();
|
||||
state.filtered = tools.filter(
|
||||
(tool) =>
|
||||
tool.label.toLowerCase().includes(normalizedQuery) ||
|
||||
tool.description?.toLowerCase().includes(normalizedQuery) ||
|
||||
tool.keywords?.some((keyword) => keyword.toLowerCase().includes(normalizedQuery)),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -1,7 +1,16 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export type HomepageLayoutMode = 'default' | 'minimal' | 'carousel' | 'categories' | 'bookmarks' | 'small-icons' | 'list';
|
||||
export type HomepageLayoutMode =
|
||||
| 'default'
|
||||
| 'minimal'
|
||||
| 'carousel'
|
||||
| 'categories'
|
||||
| 'bookmarks'
|
||||
| 'small-icons'
|
||||
| 'list'
|
||||
| 'search'
|
||||
| 'empty';
|
||||
|
||||
export interface HomepageLayoutOption {
|
||||
id: HomepageLayoutMode;
|
||||
@@ -28,11 +37,21 @@ export const homepageLayoutOptions: HomepageLayoutOption[] = [
|
||||
name: 'List',
|
||||
description: 'Hierarchical tree view of all tools and pages',
|
||||
},
|
||||
{
|
||||
id: 'empty',
|
||||
name: 'Noting',
|
||||
description: 'Show nothing',
|
||||
},
|
||||
{
|
||||
id: 'bookmarks',
|
||||
name: 'Bookmarks',
|
||||
description: 'Show only your bookmarked tools',
|
||||
},
|
||||
{
|
||||
id: 'search',
|
||||
name: 'Search',
|
||||
description: 'Search-focused layout with instant tool discovery',
|
||||
},
|
||||
// {
|
||||
// id: 'minimal',
|
||||
// name: 'Tiles',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Debounce a function call
|
||||
* @param fn Function to debounce
|
||||
* @param delay Delay in milliseconds
|
||||
* @returns Debounced function
|
||||
*/
|
||||
export function debounce<T extends (...args: unknown[]) => unknown>(
|
||||
fn: T,
|
||||
delay: number,
|
||||
): (...args: Parameters<T>) => void {
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
return (...args: Parameters<T>) => {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
fn(...args);
|
||||
timeoutId = null;
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { NavItem, NavGroup } from '$lib/constants/nav';
|
||||
|
||||
/**
|
||||
* Extract NavItems from a mixed array of NavItems and NavGroups
|
||||
* @param items Array of NavItems and/or NavGroups
|
||||
* @returns Flattened array of NavItems
|
||||
*/
|
||||
export function extractNavItems(items: (NavItem | NavGroup)[]): NavItem[] {
|
||||
const navItems: NavItem[] = [];
|
||||
for (const item of items) {
|
||||
if ('href' in item) {
|
||||
navItems.push(item);
|
||||
} else if ('title' in item && 'items' in item) {
|
||||
navItems.push(...item.items);
|
||||
}
|
||||
}
|
||||
return navItems;
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
import HomepageBookmarks from '$lib/components/home/HomepageBookmarks.svelte';
|
||||
import HomepageSmallIcons from '$lib/components/home/HomepageSmallIcons.svelte';
|
||||
import SiteMapList from '$lib/components/home/SiteMapList.svelte';
|
||||
import HomepageSearch from '$lib/components/home/HomepageSearch.svelte';
|
||||
import HomepageEmpty from '$lib/components/home/HomepageEmpty.svelte';
|
||||
|
||||
// Helper function to extract nav items from mixed structure
|
||||
function extractNavItems(items: (NavItem | NavGroup)[]): NavItem[] {
|
||||
@@ -50,6 +52,10 @@
|
||||
<HomepageSmallIcons />
|
||||
{:else if $currentLayout === 'list'}
|
||||
<SiteMapList homeMode={true} />
|
||||
{:else if $currentLayout === 'search'}
|
||||
<HomepageSearch />
|
||||
{:else if $currentLayout === 'empty'}
|
||||
<HomepageEmpty />
|
||||
{:else}
|
||||
<HomepageDefault {toolPages} {referencePages} />
|
||||
{/if}
|
||||
@@ -71,6 +71,31 @@
|
||||
--transition-fast: 0.15s ease;
|
||||
--transition-normal: 0.2s ease;
|
||||
--transition-slow: 0.3s ease;
|
||||
|
||||
/* Animation durations */
|
||||
--anim-duration-fast: 0.3s;
|
||||
--anim-duration-normal: 0.5s;
|
||||
--anim-duration-slow: 0.8s;
|
||||
}
|
||||
|
||||
/* Respect user's motion preferences */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
:root {
|
||||
--transition-fast: 0.01s ease;
|
||||
--transition-normal: 0.01s ease;
|
||||
--transition-slow: 0.01s ease;
|
||||
--anim-duration-fast: 0.01s;
|
||||
--anim-duration-normal: 0.01s;
|
||||
--anim-duration-slow: 0.01s;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01s !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01s !important;
|
||||
}
|
||||
}
|
||||
|
||||
.theme-ocean,
|
||||
|
||||
Reference in new issue
Block a user