mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-25 23:24:14 +03:00
Implemented most used
This commit is contained in:
1 parent
7c4b955b56
commit
0459b2da08
12 files changed
+534
-131
No files matched your search
@@ -22,18 +22,17 @@
|
||||
|
||||
{#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 class="bookmarks-header">
|
||||
<div class="tools-grid-sub-header">
|
||||
<Icon name="bookmarks" size="sm" />
|
||||
<h2>Bookmarked Tools</h2>
|
||||
<span class="count">{$bookmarks.length}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="bookmarks-grid">
|
||||
<ToolsGrid {tools} />
|
||||
<ToolsGrid {tools} idPrefix="bookmarks" />
|
||||
</div>
|
||||
</div>
|
||||
{:else if !hideOther}
|
||||
@@ -51,44 +50,6 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<script lang="ts">
|
||||
import { frequentlyUsedTools } from '$lib/stores/toolUsage';
|
||||
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
|
||||
export let hideOther: boolean = false;
|
||||
|
||||
$: tools = $frequentlyUsedTools.map((tool, index) => ({
|
||||
href: tool.href,
|
||||
label: tool.label || 'Tool',
|
||||
description: tool.description || '',
|
||||
icon: tool.icon,
|
||||
keywords: [],
|
||||
animationDelay: index * 0.1,
|
||||
}));
|
||||
</script>
|
||||
|
||||
{#if $frequentlyUsedTools.length > 0}
|
||||
<div class="frequently-used-container" aria-live="polite">
|
||||
|
||||
<div class="frequently-used-header">
|
||||
<div class="tools-grid-sub-header">
|
||||
<Icon name="clock" size="md" />
|
||||
<h2>Most Used Tools</h2>
|
||||
<span class="count">{$frequentlyUsedTools.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="frequently-used-grid">
|
||||
<ToolsGrid {tools} idPrefix="frequent" />
|
||||
</div>
|
||||
</div>
|
||||
{:else if !hideOther}
|
||||
<div class="empty-frequently-used">
|
||||
<div class="empty-icon">
|
||||
<Icon name="clock" size="lg" />
|
||||
</div>
|
||||
<h3>No frequently used tools yet</h3>
|
||||
<p>Start using tools to see your most frequently accessed ones here</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
.frequently-used-container {
|
||||
animation: slideIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.frequently-used-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-frequently-used {
|
||||
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);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -6,6 +6,7 @@
|
||||
import { ALL_PAGES } from '$lib/constants/nav';
|
||||
import type { NavItem } from '$lib/constants/nav';
|
||||
import { bookmarks } from '$lib/stores/bookmarks';
|
||||
import { frequentlyUsedTools, toolUsage } from '$lib/stores/toolUsage';
|
||||
|
||||
let isOpen = $state(false);
|
||||
let query = $state('');
|
||||
@@ -117,6 +118,7 @@
|
||||
|
||||
onMount(() => {
|
||||
bookmarks.init();
|
||||
toolUsage.init();
|
||||
document.addEventListener('keydown', handleGlobalKeydown);
|
||||
return () => document.removeEventListener('keydown', handleGlobalKeydown);
|
||||
});
|
||||
@@ -238,6 +240,32 @@
|
||||
</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);
|
||||
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}
|
||||
</div>
|
||||
</div>
|
||||
@@ -437,80 +465,113 @@
|
||||
}
|
||||
}
|
||||
|
||||
.bookmarks-section {
|
||||
// Shared styles for quick access sections (bookmarks & frequently used)
|
||||
.bookmarks-section,
|
||||
.frequently-used-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);
|
||||
.bookmarks-header,
|
||||
.frequently-used-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,
|
||||
.frequently-used-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.bookmark-item,
|
||||
.frequently-used-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);
|
||||
transform: translateY(-1px);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.bookmarks-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--spacing-xs);
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
.bookmark-icon,
|
||||
.frequently-used-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
:global(svg) {
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.bookmark-label,
|
||||
.frequently-used-label {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
// Specific color variations
|
||||
.bookmarks-header :global(svg) {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.frequently-used-header :global(svg) {
|
||||
color: var(--color-info);
|
||||
}
|
||||
|
||||
.bookmark-item {
|
||||
&:hover,
|
||||
&:focus {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.frequently-used-item {
|
||||
&:hover,
|
||||
&:focus {
|
||||
border-color: var(--color-info);
|
||||
}
|
||||
}
|
||||
|
||||
.bookmark-icon {
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.frequently-used-icon {
|
||||
background: var(--color-info);
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
|
||||
@@ -134,6 +134,7 @@
|
||||
flex: 1;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,19 @@
|
||||
|
||||
export let tools: NavItem[] = ALL_PAGES;
|
||||
export let searchQuery: string = '';
|
||||
export let idPrefix: string = 'main-';
|
||||
|
||||
// Remove duplicates based on href, keeping the first occurrence
|
||||
$: uniqueTools = tools.filter((tool, index, array) =>
|
||||
array.findIndex(t => t.href === tool.href) === index
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if tools.length === 0 && searchQuery}
|
||||
{#if uniqueTools.length === 0 && searchQuery}
|
||||
<NoResults {searchQuery} />
|
||||
{:else}
|
||||
<section class="tools-grid">
|
||||
{#each tools as tool (tool.href)}
|
||||
{#each uniqueTools as tool (`${idPrefix}-${tool.href.replaceAll('/', '-')}`)}
|
||||
<ToolCard {tool} />
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
@@ -24,6 +24,21 @@
|
||||
|
||||
let validation: ValidationResult = $state({ valid: true });
|
||||
let focused = $state(false);
|
||||
|
||||
/**
|
||||
* Quick CIDR presets
|
||||
*/
|
||||
const cidrPresets = [
|
||||
{ cidr: 8, label: '/8 (Class A)', hosts: '16M hosts' },
|
||||
{ cidr: 16, label: '/16 (Class B)', hosts: '65K hosts' },
|
||||
{ cidr: 24, label: '/24 (Class C)', hosts: '254 hosts' },
|
||||
{ cidr: 25, label: '/25', hosts: '126 hosts' },
|
||||
{ cidr: 26, label: '/26', hosts: '62 hosts' },
|
||||
{ cidr: 27, label: '/27', hosts: '30 hosts' },
|
||||
{ cidr: 28, label: '/28', hosts: '14 hosts' },
|
||||
{ cidr: 30, label: '/30 (P2P)', hosts: '2 hosts' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Check if current value matches a preset
|
||||
*/
|
||||
@@ -45,20 +60,6 @@
|
||||
validation = validateCIDR(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick CIDR presets
|
||||
*/
|
||||
const cidrPresets = [
|
||||
{ cidr: 8, label: '/8 (Class A)', hosts: '16M hosts' },
|
||||
{ cidr: 16, label: '/16 (Class B)', hosts: '65K hosts' },
|
||||
{ cidr: 24, label: '/24 (Class C)', hosts: '254 hosts' },
|
||||
{ cidr: 25, label: '/25', hosts: '126 hosts' },
|
||||
{ cidr: 26, label: '/26', hosts: '62 hosts' },
|
||||
{ cidr: 27, label: '/27', hosts: '30 hosts' },
|
||||
{ cidr: 28, label: '/28', hosts: '14 hosts' },
|
||||
{ cidr: 30, label: '/30 (P2P)', hosts: '2 hosts' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Applies CIDR preset
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { writable, derived } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export interface ToolUsage {
|
||||
[toolHref: string]: {
|
||||
count: number;
|
||||
lastVisited: number;
|
||||
label?: string;
|
||||
icon?: string;
|
||||
description?: string;
|
||||
};
|
||||
}
|
||||
|
||||
const STORAGE_KEY = 'ip-calc-tool-usage';
|
||||
|
||||
const thresholdVisits = 4;
|
||||
const maxItems = 6;
|
||||
|
||||
function createToolUsageStore() {
|
||||
const { subscribe, set, update } = writable<ToolUsage>({});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
/**
|
||||
* Initialize the store from localStorage
|
||||
*/
|
||||
init() {
|
||||
if (!browser) return;
|
||||
|
||||
try {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored) {
|
||||
const parsed = JSON.parse(stored);
|
||||
set(parsed);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load tool usage data:', error);
|
||||
set({});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Track a tool visit
|
||||
*/
|
||||
trackVisit(href: string, label?: string, icon?: string, description?: string) {
|
||||
if (!browser) return;
|
||||
|
||||
update(usage => {
|
||||
const newUsage = { ...usage };
|
||||
|
||||
if (!newUsage[href]) {
|
||||
newUsage[href] = {
|
||||
count: 0,
|
||||
lastVisited: Date.now(),
|
||||
label,
|
||||
icon,
|
||||
description
|
||||
};
|
||||
}
|
||||
|
||||
newUsage[href].count++;
|
||||
newUsage[href].lastVisited = Date.now();
|
||||
|
||||
// Update metadata if provided
|
||||
if (label) newUsage[href].label = label;
|
||||
if (icon) newUsage[href].icon = icon;
|
||||
if (description) newUsage[href].description = description;
|
||||
|
||||
// Save to localStorage
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(newUsage));
|
||||
} catch (error) {
|
||||
console.error('Failed to save tool usage data:', error);
|
||||
}
|
||||
|
||||
return newUsage;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all usage data
|
||||
*/
|
||||
clear() {
|
||||
if (!browser) return;
|
||||
|
||||
set({});
|
||||
try {
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
} catch (error) {
|
||||
console.error('Failed to clear tool usage data:', error);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove specific tool from usage tracking
|
||||
*/
|
||||
remove(href: string) {
|
||||
if (!browser) return;
|
||||
|
||||
update(usage => {
|
||||
const newUsage = { ...usage };
|
||||
delete newUsage[href];
|
||||
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(newUsage));
|
||||
} catch (error) {
|
||||
console.error('Failed to save tool usage data:', error);
|
||||
}
|
||||
|
||||
return newUsage;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const toolUsage = createToolUsageStore();
|
||||
|
||||
/**
|
||||
* Derived store for frequently used tools
|
||||
*/
|
||||
export const frequentlyUsedTools = derived(
|
||||
toolUsage,
|
||||
($toolUsage) => {
|
||||
const sorted = Object.entries($toolUsage)
|
||||
.filter(([_, data]) => data.count >= thresholdVisits)
|
||||
.sort((a, b) => b[1].count - a[1].count)
|
||||
.slice(0, maxItems);
|
||||
|
||||
return sorted.map(([href, data]) => ({
|
||||
href,
|
||||
...data
|
||||
}));
|
||||
}
|
||||
);
|
||||
@@ -12,6 +12,8 @@
|
||||
import { getPageDetails, getPageDetailsWithIcon } from '$lib/constants/nav';
|
||||
import { generateFaviconDataUri } from '$lib/utils/favicon';
|
||||
import { site, author } from '$lib/constants/site';
|
||||
import { toolUsage } from '$lib/stores/toolUsage';
|
||||
import { ALL_PAGES } from '$lib/constants/nav';
|
||||
|
||||
import Header from '$lib/components/furniture/Header.svelte';
|
||||
import SubHeader from '$lib/components/furniture/SubHeader.svelte';
|
||||
@@ -53,6 +55,23 @@
|
||||
|
||||
onMount(() => {
|
||||
initializeTheme();
|
||||
toolUsage.init();
|
||||
});
|
||||
|
||||
// Track tool visits when page changes
|
||||
$effect(() => {
|
||||
const currentPath = $page.url.pathname;
|
||||
|
||||
// Check if current path is a tool page
|
||||
const toolPage = ALL_PAGES.find(tool => tool.href === currentPath);
|
||||
if (toolPage) {
|
||||
toolUsage.trackVisit(
|
||||
toolPage.href,
|
||||
toolPage.label,
|
||||
toolPage.icon,
|
||||
toolPage.description
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/* Reads and applies user's theme from localstorage on initial load */
|
||||
|
||||
+31
-3
@@ -5,6 +5,10 @@
|
||||
import ToolsGrid from '$lib/components/global/ToolsGrid.svelte';
|
||||
import SearchFilter from '$lib/components/furniture/SearchFilter.svelte';
|
||||
import BookmarksGrid from '$lib/components/global/BookmarksGrid.svelte';
|
||||
import FrequentlyUsedGrid from '$lib/components/global/FrequentlyUsedGrid.svelte';
|
||||
import { bookmarks } from '$lib/stores/bookmarks';
|
||||
import { frequentlyUsedTools } from '$lib/stores/toolUsage';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
|
||||
// Helper function to extract nav items from mixed structure
|
||||
function extractNavItems(items: (NavItem | NavGroup)[]): NavItem[] {
|
||||
@@ -65,8 +69,20 @@
|
||||
<!-- Bookmarks Section -->
|
||||
<BookmarksGrid hideOther={true} />
|
||||
|
||||
<!-- Frequently Used Tools Section -->
|
||||
<FrequentlyUsedGrid hideOther={true} />
|
||||
|
||||
<!-- Show "All Tools" heading if there are bookmarks or frequently used tools -->
|
||||
{#if ($bookmarks.length > 0 || $frequentlyUsedTools.length > 0)}
|
||||
<section class="tools-grid-sub-header">
|
||||
<Icon name="network-port" size="md" />
|
||||
<h2>All Tools</h2>
|
||||
<span class="count">{toolPages.length + referencePages.length}</span>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<!-- Tools Grid -->
|
||||
<ToolsGrid tools={filteredTools} {searchQuery} />
|
||||
<ToolsGrid idPrefix="tools" tools={filteredTools} {searchQuery} />
|
||||
|
||||
<!-- Reference Pages Section -->
|
||||
{#if filteredReference.length > 0}
|
||||
@@ -77,12 +93,12 @@
|
||||
Comprehensive reference materials and documentation for network professionals.
|
||||
</p>
|
||||
</div>
|
||||
<ToolsGrid tools={filteredReference} {searchQuery} />
|
||||
<ToolsGrid idPrefix="reference" tools={filteredReference} {searchQuery} />
|
||||
</section>
|
||||
{/if}
|
||||
{:else}
|
||||
<!-- Combined Search Results -->
|
||||
<ToolsGrid tools={[...filteredTools, ...filteredReference]} {searchQuery} />
|
||||
<ToolsGrid idPrefix="search" tools={[...filteredTools, ...filteredReference]} {searchQuery} />
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
@@ -116,6 +132,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
.all-tools-section {
|
||||
margin: var(--spacing-xl) 0 var(--spacing-lg);
|
||||
text-align: center;
|
||||
|
||||
h2 {
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.reference-section {
|
||||
margin-top: var(--spacing-xl);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500;600;700&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&display=swap');
|
||||
|
||||
/* Reset */
|
||||
*,
|
||||
|
||||
@@ -90,3 +90,39 @@
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.tools-grid-sub-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
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%);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@
|
||||
--spacing-2xl: 3rem;
|
||||
|
||||
/* Font */
|
||||
--font-mono: 'Noto Sans Mono', 'Roboto Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
|
||||
--font-mono: 'Roboto Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
|
||||
--font-size-2xs: 0.6rem;
|
||||
--font-size-xs: 0.75rem;
|
||||
--font-size-sm: 0.875rem;
|
||||
|
||||
Reference in new issue
Block a user