Skip to content

Commit 4ba2cab

Browse files
authored
Merge pull request #98: Fix: tldr, svgicons 1mb js file, svg & png pages
Fix: tldr, svgicons 1mb js file, svg & png pages
2 parents e8ce2d2 + 34e5589 commit 4ba2cab

35 files changed

Lines changed: 233 additions & 255 deletions

.github/workflows/buid_deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ on:
88
jobs:
99
build-and-deploy:
1010
# Prod
11-
runs-on: ubuntu-latest
11+
# runs-on: ubuntu-latest
1212
# Self hosted
13-
# runs-on: self-hosted
13+
runs-on: self-hosted
1414
environment: production # This tells GitHub to use the production environment secrets
1515

1616
steps:

frontend/astro.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import react from "@astrojs/react";
33
import tailwind from "@astrojs/tailwind";
44
import compressor from "astro-compressor";
5-
import icon from "astro-icon";
65
import { defineConfig } from "astro/config";
76
import path from "path";
87

@@ -20,7 +19,6 @@ export default defineConfig({
2019
react(),
2120
tailwind(),
2221
compressor({ gzip: { level: 9 }, brotli: true }),
23-
icon()
2422
// sitemap({
2523
// filter: (page) => !page.includes('404') && !page.includes('_astro'),
2624
// changefreq: 'daily',

frontend/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@radix-ui/react-checkbox": "^1.3.3",
3232
"@radix-ui/react-dialog": "^1.1.15",
3333
"@radix-ui/react-dropdown-menu": "^2.1.16",
34+
"@radix-ui/react-icons": "^1.3.2",
3435
"@radix-ui/react-label": "^2.1.7",
3536
"@radix-ui/react-popover": "^1.1.15",
3637
"@radix-ui/react-progress": "^1.1.7",
@@ -74,8 +75,6 @@
7475
"tailwind-merge": "^3.3.1"
7576
},
7677
"devDependencies": {
77-
"@iconify-icon/react": "^3.0.3",
78-
"@iconify-json/ic": "^1.2.4",
7978
"@tailwindcss/typography": "^0.5.19",
8079
"@testing-library/jest-dom": "^6.7.0",
8180
"@testing-library/react": "^16.3.0",

frontend/src/components/buttons/CopyPngButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { toast } from '@/components/ToastProvider';
2-
import { IconSvg } from '@/components/ui/IconSvg';
2+
import { ClipboardCopyIcon } from '@radix-ui/react-icons';
33
import Konva from 'konva';
44
import React, { useCallback } from 'react';
55

@@ -198,8 +198,7 @@ const CopyPngButton: React.FC<CopyPngButtonProps> = ({
198198
onClick={copyAsPNG}
199199
className="inline-flex items-center justify-center px-4 py-3 text-sm font-medium text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-700 hover:bg-slate-200 dark:hover:bg-slate-600 rounded transition-colors"
200200
>
201-
<IconSvg
202-
iconName="baseline-content-copy"
201+
<ClipboardCopyIcon
203202
width="16"
204203
height="16"
205204
className="mr-2"

frontend/src/components/buttons/CopySvgButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { toast } from '@/components/ToastProvider';
2-
import { IconSvg } from '@/components/ui/IconSvg';
2+
import { ClipboardCopyIcon } from '@radix-ui/react-icons';
33
import React, { useCallback } from 'react';
44

55
interface CopySvgButtonProps {
@@ -54,8 +54,7 @@ const CopySvgButton: React.FC<CopySvgButtonProps> = ({ iconData }) => {
5454
onClick={copyAsSVG}
5555
className="inline-flex items-center justify-center px-4 py-3 text-sm font-medium text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-700 hover:bg-slate-200 dark:hover:bg-slate-600 rounded transition-colors"
5656
>
57-
<IconSvg
58-
iconName="baseline-content-copy"
57+
<ClipboardCopyIcon
5958
width="16"
6059
height="16"
6160
className="mr-2"

frontend/src/components/buttons/DownloadSvgButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { DownloadIcon } from '@radix-ui/react-icons';
12
import React, { useCallback } from 'react';
2-
import { IconSvg } from '@/components/ui/IconSvg';
33

44
interface DownloadSvgButtonProps {
55
iconData: {
@@ -45,8 +45,7 @@ const DownloadSvgButton: React.FC<DownloadSvgButtonProps> = ({ iconData }) => {
4545
onClick={downloadAsSVG}
4646
className="inline-flex items-center justify-center px-4 py-3 text-sm font-medium text-black bg-yellow-300 hover:bg-yellow-400 rounded transition-colors"
4747
>
48-
<IconSvg
49-
iconName="outline-file-download"
48+
<DownloadIcon
5049
width="16"
5150
height="16"
5251
className="mr-2"

frontend/src/components/search/SearchBar.astro

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { Icon } from 'astro-icon/components';
2+
import { MagnifyingGlassIcon, Cross2Icon } from '@radix-ui/react-icons';
33
---
44

55
<div id="searchbar-container" class="relative md:flex-1 md:max-w-sm md:mx-4">
@@ -9,9 +9,9 @@ import { Icon } from 'astro-icon/components';
99
class="md:hidden p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
1010
aria-label="Open search"
1111
>
12-
<Icon
13-
name="ic:baseline-search"
14-
class="w-6 h-6 text-gray-700 dark:text-gray-300"
12+
<MagnifyingGlassIcon
13+
client:load
14+
className="w-6 h-6 text-gray-700 dark:text-gray-300"
1515
/>
1616
</button>
1717

@@ -25,9 +25,9 @@ import { Icon } from 'astro-icon/components';
2525
class="p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex-shrink-0"
2626
aria-label="Close search"
2727
>
28-
<Icon
29-
name="ic:baseline-close"
30-
class="w-6 h-6 text-gray-700 dark:text-gray-300"
28+
<Cross2Icon
29+
client:load
30+
className="w-6 h-6 text-gray-700 dark:text-gray-300"
3131
/>
3232
</button>
3333
<input

frontend/src/components/search/SearchPage.tsx

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { IconSvg } from '@/components/ui/IconSvg';
2-
import { Icon } from '@iconify-icon/react';
1+
import { Cross2Icon, FileIcon, FileTextIcon, GearIcon, ImageIcon, ModulzLogoIcon, RocketIcon } from '@radix-ui/react-icons';
32
import React, { useCallback, useEffect, useState } from 'react';
43

54
// Types
@@ -534,17 +533,45 @@ const SearchPage: React.FC = () => {
534533
return null;
535534
}
536535

536+
const getCategoryIcon = (key: string) => {
537+
switch (key) {
538+
case 'tools':
539+
return <GearIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
540+
case 'tldr':
541+
return <FileIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
542+
case 'cheatsheets':
543+
return <FileTextIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
544+
case 'png_icons':
545+
case 'svg_icons':
546+
return <ImageIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
547+
case 'emoji':
548+
return <RocketIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
549+
case 'mcp':
550+
return <ModulzLogoIcon className="hidden md:block w-4 h-4 mr-1 flex-shrink-0" />;
551+
default:
552+
return null;
553+
}
554+
};
555+
537556
const categories = [
538-
{ key: 'all', icon: null, label: 'All' },
539-
{ key: 'tools', icon: 'ph:wrench', label: 'Tools' },
540-
{ key: 'tldr', icon: 'ic:baseline-menu-book', label: 'TLDR' },
541-
{ key: 'cheatsheets', icon: 'pepicons-pencil:file', label: 'Cheatsheets' },
542-
{ key: 'png_icons', icon: 'ph:file-png', label: 'PNG Icons' },
543-
{ key: 'svg_icons', icon: 'ph:file-svg', label: 'SVG Icons' },
544-
{ key: 'emoji', icon: 'ic:outline-emoji-emotions', label: 'Emojis' },
545-
{ key: 'mcp', icon: 'ic:outline-settings-suggest', label: 'MCP' },
557+
{ key: 'all', label: 'All' },
558+
{ key: 'tools', label: 'Tools' },
559+
{ key: 'tldr', label: 'TLDR' },
560+
{ key: 'cheatsheets', label: 'Cheatsheets' },
561+
{ key: 'png_icons', label: 'PNG Icons' },
562+
{ key: 'svg_icons', label: 'SVG Icons' },
563+
{ key: 'emoji', label: 'Emojis' },
564+
{ key: 'mcp', label: 'MCP' },
546565
];
547566

567+
const formatCount = (count: number | undefined): string => {
568+
if (count === undefined) return '';
569+
if (count > 999) {
570+
return `${Math.floor(count / 1000)}k+`;
571+
}
572+
return count.toString();
573+
};
574+
548575
const getAllCount = () => {
549576
if (Object.keys(availableCategories).length === 0) return undefined;
550577
return Object.values(availableCategories).reduce(
@@ -579,7 +606,7 @@ const SearchPage: React.FC = () => {
579606
Esc
580607
</kbd>
581608
<span className="text-sm">Clear results</span>
582-
<IconSvg iconName="round-close" className="h-4 w-4" />
609+
<Cross2Icon className="h-4 w-4" />
583610
</button>
584611
</div>
585612

@@ -588,16 +615,15 @@ const SearchPage: React.FC = () => {
588615
<button
589616
onClick={() => handleCategoryClick('all')}
590617
onContextMenu={(e) => handleCategoryRightClick(e, 'all')}
591-
className={`text-xs lg:text-sm w-full flex items-center justify-center gap-1 px-2 h-9 rounded-md whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${
592-
activeCategory === 'all'
593-
? 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-blue-500/50'
594-
: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground'
595-
}`}
618+
className={`text-xs lg:text-sm w-full flex items-center justify-center gap-1 px-2 h-9 rounded-md whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${activeCategory === 'all'
619+
? 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-blue-500/50'
620+
: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground'
621+
}`}
596622
>
597623
All{' '}
598624
{activeCategory === 'all' &&
599625
Object.keys(availableCategories).length > 0 &&
600-
`(${getAllCount()})`}
626+
`(${formatCount(getAllCount())})`}
601627
</button>
602628

603629
{categories
@@ -612,30 +638,23 @@ const SearchPage: React.FC = () => {
612638
? availableCategories[category.key]
613639
: undefined);
614640

615-
if (!category.icon) return null;
616641

617642
const buttonContent = (
618643
<>
619-
<Icon
620-
icon={category.icon}
621-
width="18"
622-
height="16"
623-
className="lg:w-4 lg:h-4 flex-shrink-0"
624-
/>
644+
{getCategoryIcon(category.key)}
625645
<span className="truncate">{category.label}</span>
626646
{count !== undefined && (
627647
<span className="flex-shrink-0 ml-0.5">
628-
({count.toLocaleString()})
648+
({formatCount(count)})
629649
</span>
630650
)}
631651
</>
632652
);
633653

634-
const buttonClassName = `text-xs lg:text-sm w-full flex items-center gap-1 px-2 h-9 rounded-md whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${
635-
isActive || selectedCategories.includes(category.key)
636-
? 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-blue-500/50'
637-
: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground hover:shadow-md hover:shadow-gray-500/30 dark:hover:bg-slate-900 dark:hover:shadow-slate-900/50'
638-
}`;
654+
const buttonClassName = `text-xs lg:text-sm w-full flex items-center gap-1 px-2 h-9 rounded-md whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${isActive || selectedCategories.includes(category.key)
655+
? 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-md shadow-blue-500/50'
656+
: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground hover:shadow-md hover:shadow-gray-500/30 dark:hover:bg-slate-900 dark:hover:shadow-slate-900/50'
657+
}`;
639658

640659
if (isActive || selectedCategories.includes(category.key)) {
641660
return (
@@ -754,4 +773,4 @@ const SearchPage: React.FC = () => {
754773
);
755774
};
756775

757-
export default SearchPage;
776+
export default SearchPage;

frontend/src/components/ui/IconSvg.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)