Bookmarking functionality and UI

This commit is contained in:
Alicia Sykes committed 2025-09-15 16:44:44 +01:00
1 parent 531815f226
commit 461cd3b5e7
7 files changed
+640 -20

No files matched your search

@@ -0,0 +1,205 @@
<script lang="ts">
import { onMount } from 'svelte';
import { bookmarks } from '$lib/stores/bookmarks';
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
import Icon from '$lib/components/global/Icon.svelte';
export let hideOther: boolean = false;
onMount(() => {
bookmarks.init();
});
$: tools = $bookmarks.map((bookmark, index) => ({
href: bookmark.href,
label: bookmark.label,
description: bookmark.description,
icon: bookmark.icon,
keywords: [],
animationDelay: index * 0.1
}));
</script>
{#if $bookmarks.length > 0}
<div class="bookmarks-container" aria-live="polite">
{#if !hideOther}
<div class="bookmarks-header">
<div class="header-content">
<Icon name="bookmarks" size="sm" />
<h2>Bookmarked Tools</h2>
<span class="count">{$bookmarks.length}</span>
</div>
</div>
{/if}
<div class="bookmarks-grid">
<ToolsGrid {tools} />
</div>
</div>
{:else if !hideOther}
<div class="empty-bookmarks">
<div class="empty-icon">
<Icon name="bookmarks" size="lg" />
</div>
<h3>No bookmarks yet</h3>
<p>Hover over any tool card and click the bookmark icon to save your favorites</p>
</div>
{/if}
<style lang="scss">
.bookmarks-container {
animation: slideIn 0.3s ease-out;
}
.bookmarks-header {
margin-bottom: var(--spacing-lg);
width: fit-content;
.header-content {
display: flex;
align-items: center;
gap: var(--spacing-sm);
:global(svg) {
color: var(--color-primary);
}
h2 {
font-size: var(--font-size-xl);
font-weight: 600;
color: var(--text-primary);
margin: 0;
}
.count {
background: var(--text-secondary);
opacity: 0.8;
color: var(--bg-primary);
padding: var(--spacing-2xs) var(--spacing-xs);
border-radius: var(--radius-sm);
font-size: var(--font-size-sm);
font-weight: 600;
min-width: 1.25rem;
text-align: center;
animation: pulse 0.5s ease;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
cursor: default;
&:hover {
transform: scale(1.1);
box-shadow: 0 4px 8px color-mix(in srgb, var(--color-warning), transparent 70%);
}
}
}
}
.bookmarks-grid {
animation: subtleFadeIn 0.2s ease-out;
:global(.tool-card) {
animation: subtleSlideIn 0.3s ease-out forwards;
opacity: 0;
}
:global(.tool-card:nth-child(1)) { animation-delay: 0.05s; }
:global(.tool-card:nth-child(2)) { animation-delay: 0.1s; }
:global(.tool-card:nth-child(3)) { animation-delay: 0.15s; }
:global(.tool-card:nth-child(4)) { animation-delay: 0.2s; }
:global(.tool-card:nth-child(5)) { animation-delay: 0.25s; }
:global(.tool-card:nth-child(6)) { animation-delay: 0.3s; }
:global(.tool-card:nth-child(n+7)) { animation-delay: 0.35s; }
}
.empty-bookmarks {
background: var(--bg-secondary);
margin: var(--spacing-xl) auto;
padding: var(--spacing-xl) var(--spacing-lg);
border-radius: var(--radius-lg);
text-align: center;
opacity: 0.85;
animation: fadeIn 0.2s ease;
.empty-icon {
:global(svg) {
color: var(--text-secondary);
opacity: 0.5;
}
}
h3 {
font-size: var(--font-size-lg);
color: var(--text-primary);
margin: 0 0 var(--spacing-sm) 0;
}
p {
color: var(--text-secondary);
max-width: 24rem;
margin: 0 auto;
line-height: 1.5;
}
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes subtleFadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes subtleSlideIn {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(0.3);
}
50% {
opacity: 1;
transform: scale(1.05);
}
70% {
transform: scale(0.9);
}
100% {
opacity: 1;
transform: scale(1);
}
}
</style>
+122 -7
View File
@@ -5,6 +5,7 @@
import Icon from './Icon.svelte';
import { ALL_PAGES } from '$lib/constants/nav';
import type { NavItem } from '$lib/constants/nav';
import { bookmarks } from '$lib/stores/bookmarks';
let isOpen = $state(false);
let query = $state('');
@@ -116,6 +117,7 @@
});
onMount(() => {
bookmarks.init();
document.addEventListener('keydown', handleGlobalKeydown);
return () => document.removeEventListener('keydown', handleGlobalKeydown);
});
@@ -159,16 +161,19 @@
onmouseenter={() => selectedIndex = index}
>
<div class="result-content">
<div class="result-title">{result.label}</div>
<div class="result-title">
<Icon name={result.icon} size="xs" />
{result.label}
</div>
{#if result.description}
<div class="result-description">{result.description}</div>
{/if}
</div>
<div class="result-meta">
<span class="result-path">{result.href}</span>
{#if index === selectedIndex}
<Icon name="corner-down-left" size="xs" />
<Icon name="link" size="xs" />
{/if}
<span class="result-path">{result.href}</span>
</div>
</button>
{/each}
@@ -189,12 +194,40 @@
<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}
<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}
</div>
</div>
{/if}
<style lang="scss">
button:hover:not(:disabled) {
border-color: var(--border-primary);
}
.search-trigger {
display: flex;
align-items: center;
@@ -295,7 +328,7 @@
.result-item {
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-between;
width: 100%;
padding: var(--spacing-md) var(--spacing-lg);
@@ -323,6 +356,12 @@
color: var(--text-primary);
font-weight: 500;
margin-bottom: var(--spacing-xs);
display: flex;
align-items: center;
gap: var(--spacing-xs);
:global(svg) {
color: var(--text-tertiary);
}
}
.result-description {
@@ -341,13 +380,15 @@
display: flex;
align-items: center;
gap: var(--spacing-sm);
margin-left: var(--spacing-md);
justify-content: end;
.result-path {
color: var(--text-tertiary);
font-size: var(--font-size-xs);
font-family: var(--font-mono);
}
:global(svg) {
color: var(--text-tertiary);
}
}
}
@@ -364,7 +405,7 @@
.search-help {
padding: var(--spacing-lg);
border-top: 1px solid var(--border-secondary);
.help-item {
display: flex;
align-items: center;
@@ -375,6 +416,80 @@
}
}
.bookmarks-section {
padding: var(--spacing-md) var(--spacing-lg);
border-top: 1px solid var(--border-secondary);
.bookmarks-header {
display: flex;
align-items: center;
gap: var(--spacing-sm);
color: var(--text-secondary);
font-size: var(--font-size-xs);
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: var(--spacing-sm);
:global(svg) {
color: var(--color-primary);
}
}
.bookmarks-list {
display: flex;
flex-wrap: wrap;
gap: var(--spacing-xs);
}
.bookmark-item {
display: flex;
align-items: center;
gap: var(--spacing-xs);
padding: var(--spacing-xs) var(--spacing-sm);
background: var(--bg-tertiary);
border: 1px solid var(--border-secondary);
border-radius: var(--radius-md);
color: var(--text-primary);
font-size: var(--font-size-xs);
cursor: pointer;
transition: all var(--transition-fast);
max-width: 140px;
&:hover,
&:focus {
background: var(--surface-hover);
border-color: var(--color-primary);
transform: translateY(-1px);
outline: none;
}
&:active {
transform: translateY(0);
}
.bookmark-icon {
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
background: var(--color-primary);
border-radius: var(--radius-sm);
flex-shrink: 0;
:global(svg) {
color: var(--bg-primary);
}
}
.bookmark-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.2;
}
}
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
+5
View File
@@ -173,6 +173,11 @@
'plus': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path opacity=".4" d=""/><path d="M344 88C344 74.7 333.3 64 320 64C306.7 64 296 74.7 296 88L296 296L88 296C74.7 296 64 306.7 64 320C64 333.3 74.7 344 88 344L296 344L296 552C296 565.3 306.7 576 320 576C333.3 576 344 565.3 344 552L344 344L552 344C565.3 344 576 333.3 576 320C576 306.7 565.3 296 552 296L344 296L344 88z"/></svg>`,
'plus-circle': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path opacity=".4" d="M112 320C112 434.9 205.1 528 320 528C434.9 528 528 434.9 528 320C528 205.1 434.9 112 320 112C205.1 112 112 205.1 112 320zM208 320C208 306.7 218.7 296 232 296L296 296L296 232C296 218.7 306.7 208 320 208C333.3 208 344 218.7 344 232L344 296L408 296C421.3 296 432 306.7 432 320C432 333.3 421.3 344 408 344L344 344L344 408C344 421.3 333.3 432 320 432C306.7 432 296 421.3 296 408L296 344L232 344C218.7 344 208 333.3 208 320z"/><path d="M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM296 408C296 421.3 306.7 432 320 432C333.3 432 344 421.3 344 408L344 344L408 344C421.3 344 432 333.3 432 320C432 306.7 421.3 296 408 296L344 296L344 232C344 218.7 333.3 208 320 208C306.7 208 296 218.7 296 232L296 296L232 296C218.7 296 208 306.7 208 320C208 333.3 218.7 344 232 344L296 344L296 408z"/></svg>`,
'previous': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path opacity=".4" d="M141.3 320L173.3 352L544 352C561.7 352 576 337.7 576 320C576 302.3 561.7 288 544 288L173.3 288L141.3 320z"/><path d="M73.4 342.6C60.9 330.1 60.9 309.8 73.4 297.3L233.4 137.3C245.9 124.8 266.2 124.8 278.7 137.3C291.2 149.8 291.2 170.1 278.7 182.6L141.3 320L278.6 457.4C291.1 469.9 291.1 490.2 278.6 502.7C266.1 515.2 245.8 515.2 233.3 502.7L73.3 342.7z"/></svg>`,
'bookmarks': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M176 128L176 515.2L293.4 437C309.5 426.3 330.5 426.3 346.6 437L464 515.2L464 128C464 119.2 456.8 112 448 112L192 112C183.2 112 176 119.2 176 128z"/><path d="M128 128C128 92.7 156.7 64 192 64L448 64C483.3 64 512 92.7 512 128L512 545.1C512 570.7 483.5 585.9 462.2 571.7L320 476.8L177.8 571.7C156.5 585.9 128 570.6 128 545.1L128 128zM192 112C183.2 112 176 119.2 176 128L176 515.2L293.4 437C309.5 426.3 330.5 426.3 346.6 437L464 515.2L464 128C464 119.2 456.8 112 448 112L192 112z"/></svg>`,
'bookmark-add': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M128 128L128 544C128 555.5 134.2 566.2 144.2 571.8C154.2 577.4 166.5 577.3 176.4 571.4L320 485.3L463.5 571.4C473.4 577.3 485.7 577.5 495.7 571.8C505.7 566.1 512 555.5 512 544L512 128C512 92.7 483.3 64 448 64L192 64C156.7 64 128 92.7 128 128zM224 288C224 274.7 234.7 264 248 264L296 264L296 216C296 202.7 306.7 192 320 192C333.3 192 344 202.7 344 216L344 264L392 264C405.3 264 416 274.7 416 288C416 301.3 405.3 312 392 312L344 312L344 360C344 373.3 333.3 384 320 384C306.7 384 296 373.3 296 360L296 312L248 312C234.7 312 224 301.3 224 288z"/><path d="M344 216C344 202.7 333.3 192 320 192C306.7 192 296 202.7 296 216L296 264L248 264C234.7 264 224 274.7 224 288C224 301.3 234.7 312 248 312L296 312L296 360C296 373.3 306.7 384 320 384C333.3 384 344 373.3 344 360L344 312L392 312C405.3 312 416 301.3 416 288C416 274.7 405.3 264 392 264L344 264L344 216z"/></svg>`,
'bookmark-remove': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M128 229.8L128 544C128 555.5 134.2 566.2 144.2 571.8C154.2 577.4 166.5 577.3 176.4 571.4L319.9 485.3L321.2 486.1L358.2 460.2L127.8 229.8z"/><path d="M39 39.1C48.4 29.7 63.6 29.7 72.9 39.1L134.2 100.4C144.5 78.9 166.5 64 192 64L448 64C483.3 64 512 92.7 512 128L512 478.2L601 567.2C610.4 576.6 610.4 591.8 601 601.1C591.6 610.4 576.4 610.5 567.1 601.1L39 73.1C29.7 63.7 29.7 48.5 39 39.1z"/></svg>`,
'link': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M224 323.5C224 367.4 242.1 407.1 271.2 435.5C286.9 450.8 305.7 462.8 326.7 470.5C343.5 476.6 361.6 480 380.4 480C421.9 480 461.7 463.5 491 434.2L562.1 363.1C591.5 333.7 608 293.9 608 252.5C608 166 538 96 451.5 96C410.1 96 370.3 112.5 340.9 141.8L313.2 169.5C334.1 177.2 353 189.3 368.6 204.6L386.1 187.1C403.4 169.8 427 160 451.5 160C502.6 160 544 201.4 544 252.5C544 277 534.3 300.5 516.9 317.9L445.8 389C428.5 406.3 404.9 416.1 380.3 416.1C355.5 416.1 333 406.3 316.4 390.4C298.9 373.6 287.9 349.9 287.9 323.7C287.9 299.2 297.6 275.7 315 258.3L323.3 250C306.7 234.1 284.3 224.2 259.4 224.2C236.6 252.1 223.9 287.3 223.9 323.7z"/><path d="M194.2 251.1C211.5 233.8 235.1 224 259.6 224C310.5 224 352.1 265.7 352.1 316.9C352.1 341.1 342.5 364.4 325.5 381.4L316.6 390.3C333.2 406.2 355.7 416 380.4 416C403.4 388.3 416.1 353.1 416.1 316.9C416.1 230.6 346.2 160 259.6 160C218.1 160 178.3 176.5 149 205.8L77.8 276.9C48.5 306.3 32 346.1 32 387.5C32 474 102 544 188.5 544C229.9 544 269.7 527.5 299.1 498.2L326.7 470.6C305.7 462.9 286.9 450.9 271.2 435.6L253.8 453C236.5 470.3 212.9 480.1 188.4 480.1C137.3 480.1 95.9 438.7 95.9 387.6C95.9 363.1 105.6 339.6 123 322.2L194.1 251.1z"/></svg>`,
'ptr-generator': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M208 136L208 416L284.8 313.6C289.3 307.6 296.4 304 304 304L432 304L208 136z"/><path d="M198.4 68.8C191.1 63.3 181.4 62.5 173.3 66.5C165.2 70.5 160 78.9 160 88L160 488C160 498.3 166.6 507.5 176.4 510.8C186.2 514.1 197 510.7 203.2 502.4L299.9 373.4L394.5 562.7C400.4 574.6 414.8 579.4 426.7 573.4C438.6 567.4 443.4 553.1 437.4 541.2L342.7 351.9L503.9 351.9C514.2 351.9 523.4 345.3 526.7 335.5C530 325.7 526.6 314.9 518.3 308.7L198.4 68.8zM208 416L208 136L432 304L304 304C296.4 304 289.3 307.6 284.8 313.6L208 416z"/></svg>`,
'random-ip': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path opacity=".4" d="M66.5 306.7C56.2 345.1 79 384.6 117.4 394.9L306.9 445.7C345.3 456 384.8 433.2 395.1 394.8L445.9 205.3C455.5 169.3 436.1 132.4 402 119.4L395 117.1L205.5 66.3L198.3 64.8C164.6 59.3 131.6 78.4 119.5 110.2L117.2 117.2L66.4 306.7zM186.9 296C193 305.9 193.2 318.4 187.5 328.5C181.8 338.6 171 344.8 159.3 344.7C147.7 344.6 137.1 338.2 131.5 328C125.4 318.1 125.2 305.6 130.9 295.5C136.6 285.4 147.4 279.2 159.1 279.3C170.7 279.4 181.3 285.8 186.9 296zM227.9 143C234 152.9 234.2 165.4 228.5 175.5C222.8 185.6 212 191.8 200.3 191.7C188.7 191.6 178.1 185.2 172.5 175C166.4 165.1 166.2 152.6 171.9 142.5C177.6 132.4 188.4 126.2 200.1 126.3C211.7 126.4 222.3 132.8 227.9 143zM283.9 240C290 249.9 290.2 262.4 284.5 272.5C278.8 282.6 268 288.8 256.3 288.7C244.7 288.6 234.1 282.2 228.5 272C222.4 262.1 222.2 249.6 227.9 239.5C233.6 229.4 244.4 223.2 256.1 223.3C267.7 223.4 278.3 229.8 283.9 240zM339.9 337C346 346.9 346.2 359.4 340.5 369.5C334.8 379.6 324 385.8 312.3 385.7C300.7 385.6 290.1 379.2 284.5 369C278.4 359.1 278.2 346.6 283.9 336.5C289.6 326.4 300.4 320.2 312.1 320.3C323.7 320.4 334.3 326.8 339.9 337zM380.9 184C387 193.9 387.2 206.4 381.5 216.5C375.8 226.6 365 232.8 353.3 232.7C341.7 232.6 331.1 226.2 325.5 216C319.4 206.1 319.2 193.6 324.9 183.5C330.6 173.4 341.4 167.2 353.1 167.3C364.7 167.4 375.3 173.8 380.9 184z"/><path d="M184.2 131.3C174 136.9 167.6 147.5 167.5 159.1C167.4 170.8 173.6 181.6 183.7 187.3C193.8 193 206.3 192.8 216.2 186.7C226.4 181.1 232.8 170.5 232.9 158.9C233 147.2 226.8 136.4 216.7 130.7C206.6 125 194.1 125.2 184.2 131.3zM369.2 227.7C379.4 222.1 385.8 211.5 385.9 199.9C386 188.2 379.8 177.4 369.7 171.7C359.6 166 347.1 166.2 337.2 172.3C327 177.9 320.6 188.5 320.5 200.1C320.4 211.8 326.6 222.6 336.7 228.3C346.8 234 359.3 233.8 369.2 227.7zM272.2 283.7C282.4 278.1 288.8 267.5 288.9 255.9C289 244.2 282.8 233.4 272.7 227.7C262.6 222 250.1 222.2 240.2 228.3C230 233.9 223.6 244.5 223.5 256.1C223.4 267.8 229.6 278.6 239.7 284.3C249.8 290 262.3 289.8 272.2 283.7zM175.2 339.7C185.4 334.1 191.8 323.5 191.9 311.9C192 300.2 185.8 289.4 175.7 283.7C165.6 278 153.1 278.2 143.2 284.3C133 289.9 126.6 300.5 126.5 312.1C126.4 323.8 132.6 334.6 142.7 340.3C152.8 346 165.3 345.8 175.2 339.7zM296.2 325.3C286 330.9 279.6 341.5 279.5 353.1C279.4 364.8 285.6 375.6 295.7 381.3C305.8 387 318.3 386.8 328.2 380.7C338.4 375.1 344.8 364.5 344.9 352.9C345 341.2 338.8 330.4 328.7 324.7C318.6 319 306.1 319.2 296.2 325.3zM256.2 481.8L256.2 512C256.2 547.3 284.9 576 320.2 576L512.2 576C547.5 576 576.2 547.3 576.2 512L576.2 320C576.2 284.7 547.5 256 512.2 256L482 256L441.5 407.2C424.9 469.2 362.6 506.8 300.5 493.5L294.5 492.1L256.2 481.8z"/></svg>`,
'redirect-trace': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 320C112 322.6 113 325.2 114.9 327L313 525.1C314.9 527 317.4 528 320 528C322.6 528 325.2 527 327 525.1L525.1 327C527 325.1 528 322.6 528 320C528 317.4 527 314.8 525.1 313L327 114.9C325.1 113 322.6 112 320 112C317.4 112 314.8 113 313 114.9L114.9 313C113 314.9 112 317.4 112 320zM224 352C224 312.2 256.2 280 296 280L350.1 280L327.1 257C317.7 247.6 317.7 232.4 327.1 223.1C336.5 213.8 351.7 213.7 361 223.1L425 287.1C434.4 296.5 434.4 311.7 425 321L361 385C351.6 394.4 336.4 394.4 327.1 385C317.8 375.6 317.7 360.4 327.1 351.1L350.1 328.1L296 328.1C282.7 328.1 272 338.8 272 352.1L272 376.1C272 389.4 261.3 400.1 248 400.1C234.7 400.1 224 389.4 224 376.1L224 352.1z"/><path d="M114.9 313L313 114.9C314.9 113 317.4 112 320 112C322.6 112 325.2 113 327 114.9L525.1 313C527 314.9 528 317.4 528 320C528 322.6 527 325.2 525.1 327L327 525.1C325.1 527 322.6 528 320 528C317.4 528 314.8 527 313 525.1L114.9 327C113 325.1 112 322.6 112 320C112 317.4 113 314.8 114.9 313zM279 81L81 279C70.1 289.9 64 304.6 64 320C64 335.4 70.1 350.1 81 361L279 559C289.9 569.9 304.6 576 320 576C335.4 576 350.1 569.9 361 559L559 361C569.9 350.1 576 335.4 576 320C576 304.6 569.9 289.9 559 279L361 81C350.1 70.1 335.4 64 320 64C304.6 64 289.9 70.1 279 81zM425 321C434.4 311.6 434.4 296.4 425 287.1L361 223.1C351.6 213.7 336.4 213.7 327.1 223.1C317.8 232.5 317.7 247.7 327.1 257L350.1 280L296 280C256.2 280 224 312.2 224 352L224 376C224 389.3 234.7 400 248 400C261.3 400 272 389.3 272 376L272 352C272 338.7 282.7 328 296 328L350.1 328L327.1 351C317.7 360.4 317.7 375.6 327.1 384.9C336.5 394.2 351.7 394.3 361 384.9L425 320.9z"/></svg>`,
+167 -13
View File
@@ -1,10 +1,35 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
import { tooltip } from '$lib/actions/tooltip';
import { onMount } from 'svelte';
import Icon from '$lib/components/global/Icon.svelte';
import type { NavItem } from '$lib/constants/nav';
import { bookmarks, type BookmarkedTool } from '$lib/stores/bookmarks';
export let tool: NavItem;
export let small: boolean = false;
let isHovered = false;
let isBookmarked = false;
onMount(() => {
bookmarks.init();
});
$: isBookmarked = bookmarks.isBookmarked(tool.href, $bookmarks);
function toggleBookmark(e: Event) {
e.preventDefault();
e.stopPropagation();
const bookmarkedTool: BookmarkedTool = {
href: tool.href,
label: tool.label,
description: tool.description || '',
icon: tool.icon || 'default'
};
bookmarks.toggle(bookmarkedTool);
}
</script>
{#if small}
<a href={tool.href} class="tool-card small" aria-label={tool.label} use:tooltip={{ text: tool.description || '' }}>
@@ -21,8 +46,35 @@
</div>
</a>
{:else}
<a href={tool.href} class="tool-card" aria-label={tool.label}>
<h3>{tool.label}</h3>
<a
href={tool.href}
class="tool-card"
aria-label={tool.label}
on:mouseenter={() => isHovered = true}
on:mouseleave={() => isHovered = false}
>
<div class="card-header">
<h3>{tool.label}</h3>
{#if isHovered || isBookmarked}
<button
class="bookmark-btn"
class:bookmarked={isBookmarked}
on:click={toggleBookmark}
aria-label={isBookmarked ? 'Remove bookmark' : 'Add bookmark'}
>
{#if isBookmarked}
{#if isHovered}
<Icon name="bookmark-remove" size="sm" />
{:else}
<Icon name="bookmarks" size="sm" />
{/if}
{:else}
<Icon name="bookmark-add" size="md" />
{/if}
<!-- <Icon name={isBookmarked ? 'bookmark-remove' : 'bookmark-add'} size="sm" /> -->
</button>
{/if}
</div>
<div class="right">
<div class="tool-icon">
<Icon name={tool.icon || 'default'} />
@@ -56,17 +108,84 @@
height: 100%;
min-width: 0;
> h3 {
font-size: var(--font-size-lg);
font-weight: 600;
color: var(--text-primary);
margin: 0;
line-height: 1.3;
text-overflow: ellipsis;
display: block;
max-width: 100%;
white-space: nowrap;
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: var(--spacing-sm);
h3 {
font-size: var(--font-size-lg);
font-weight: 600;
color: var(--text-primary);
margin: 0;
line-height: 1.3;
text-overflow: ellipsis;
display: block;
flex: 1;
white-space: nowrap;
overflow: hidden;
}
}
.bookmark-btn {
background: none;
border: none;
cursor: pointer;
padding: var(--spacing-xs);
border-radius: var(--radius-sm);
color: var(--text-secondary);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
opacity: 0;
animation: slideInFromTop 0.3s ease forwards;
overflow: hidden;
position: absolute;
right: var(--spacing-sm);
top: var(--spacing-sm);
&::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
background: color-mix(in srgb, var(--color-primary), transparent 90%);
border-radius: 50%;
transition: all 0.3s ease;
transform: translate(-50%, -50%);
z-index: -1;
}
&:hover {
background: var(--surface-hover);
color: var(--color-success);
transform: scale(1.15);
&::before {
width: 100%;
height: 100%;
}
}
&:active {
transform: scale(0.95);
}
&.bookmarked {
color: var(--text-secondary);
opacity: 1;
animation: bookmarkPulse 0.6s ease;
&:hover {
color: var(--color-error);
transform: scale(1.1) rotate(-5deg);
}
}
:global(svg) {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
}
.right {
@@ -193,4 +312,39 @@
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
@keyframes slideInFromTop {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes bookmarkPulse {
0% {
transform: scale(1);
}
25% {
transform: scale(1.2);
}
50% {
transform: scale(1.1);
}
75% {
transform: scale(1.15);
}
100% {
transform: scale(1);
}
}
</style>
+69
View File
@@ -0,0 +1,69 @@
import { writable } from 'svelte/store';
import { browser } from '$app/environment';
export interface BookmarkedTool {
href: string;
label: string;
description: string;
icon: string;
}
const STORAGE_KEY = 'bookmarked-tools';
function createBookmarksStore() {
const { subscribe, set, update } = writable<BookmarkedTool[]>([]);
return {
subscribe,
init: () => {
if (browser) {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored) {
try {
set(JSON.parse(stored));
} catch {
set([]);
}
}
}
},
add: (tool: BookmarkedTool) => {
update(bookmarks => {
if (!bookmarks.find(b => b.href === tool.href)) {
const newBookmarks = [...bookmarks, tool];
if (browser) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(newBookmarks));
}
return newBookmarks;
}
return bookmarks;
});
},
remove: (href: string) => {
update(bookmarks => {
const newBookmarks = bookmarks.filter(b => b.href !== href);
if (browser) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(newBookmarks));
}
return newBookmarks;
});
},
toggle: (tool: BookmarkedTool) => {
update(bookmarks => {
const existing = bookmarks.find(b => b.href === tool.href);
const newBookmarks = existing
? bookmarks.filter(b => b.href !== tool.href)
: [...bookmarks, tool];
if (browser) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(newBookmarks));
}
return newBookmarks;
});
},
isBookmarked: (href: string, bookmarks: BookmarkedTool[]) => {
return bookmarks.some(b => b.href === href);
}
};
}
export const bookmarks = createBookmarksStore();
+5
View File
@@ -4,6 +4,7 @@
import { ALL_PAGES, SUB_NAV, type NavItem, type NavGroup } from '$lib/constants/nav';
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
import SearchFilter from '$lib/components/furniture/SearchFilter.svelte';
import BookmarksGrid from '$lib/components/global/BookmarksGrid.svelte';
// Helper function to extract nav items from mixed structure
function extractNavItems(items: (NavItem | NavGroup)[]): NavItem[] {
@@ -70,6 +71,10 @@
<SearchFilter bind:filteredTools bind:searchQuery />
{#if searchQuery.trim() === ''}
<!-- Bookmarks Section -->
<BookmarksGrid hideOther={true} />
<!-- Tools Grid -->
<ToolsGrid tools={filteredTools} {searchQuery} />
+67
View File
@@ -0,0 +1,67 @@
<script lang="ts">
import { onMount } from 'svelte';
import { site, pages } from '$lib/constants/site';
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
import BookmarksGrid from '$lib/components/global/BookmarksGrid.svelte';
import { bookmarks } from '$lib/stores/bookmarks';
onMount(() => {
bookmarks.init();
});
$: bookmarkCount = $bookmarks.length;
$: showAll = false;
</script>
<svelte:head>
<title>{pages.home.title}</title>
<meta name="description" content="{pages.home.description}" />
<meta name="keywords" content="{site.keywords}" />
<meta property="og:title" content="{pages.home.title}" />
<meta property="og:description" content="{pages.home.ogDescription}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{site.url}" />
</svelte:head>
<BookmarksGrid />
<!-- Button for showing all tools, so user can find some to bookmark -->
{#if bookmarkCount > 0}
<div class="toggle-container">
<button on:click={() => showAll = !showAll} class="toggle-button">
{showAll ? 'Hide All' : 'Show All'}
</button>
</div>
{/if}
<!-- Show all tools -->
{#if bookmarkCount === 0 || showAll}
<ToolsGrid />
{/if}
<style lang="scss">
.toggle-container {
display: flex;
justify-content: center;
margin: var(--spacing-lg) 0;
.toggle-button {
padding: var(--spacing-sm) var(--spacing-md);
background: var(--color-primary);
color: var(--bg-primary);
font-size: var(--font-size-md);
border-radius: var(--radius-sm);
cursor: pointer;
border: none;
transition: background 0.3s ease;
&:hover {
background: var(--color-primary-hover);
}
}
}
</style>