Skip to content

Commit ee7d8a8

Browse files
rm:next/image comp & feat:preload-images
1 parent f162548 commit ee7d8a8

File tree

15 files changed

+551
-480
lines changed

15 files changed

+551
-480
lines changed

pnpm-lock.yaml

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

src/app/_components/this-pc.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
AccordionTrigger,
77
} from "@/components/ui/accordion";
88
import { cn } from "@/lib/utils";
9-
import Image from "next/image";
9+
// import Image from "next/image";
10+
import { ExplorerIcons } from "@/lib/images";
1011
type ThisPCItemProps = {
1112
icon: string;
1213
label?: string;
@@ -69,12 +70,12 @@ function ThisPcFolderItem(props: Omit<ThisPCItemProps, "childern">) {
6970
}
7071

7172
const FoldersItems = [
72-
{ icon: "/icons/folder-desktop.png", label: "Desktop" },
73-
// { icon: "/icons/folder-documents.png", label: "Documents" },
74-
// { icon: "/icons/folder-downloads.png", label: "Downloads" },
75-
{ icon: "/icons/folder-music.png", label: "Music" },
76-
{ icon: "/icons/folder-pictures.png", label: "Pictures" },
77-
{ icon: "/icons/folder-videos.png", label: "Videos" },
73+
{ icon: ExplorerIcons.FolderDesktop, label: "Desktop" },
74+
// { icon: ExplorerIcons.FolderDocuments, label: "Documents" },
75+
// { icon: ExplorerIcons.FolderDownloads, label: "Downloads" },
76+
{ icon: ExplorerIcons.FolderMusic, label: "Music" },
77+
{ icon: ExplorerIcons.FolderPictures, label: "Pictures" },
78+
{ icon: ExplorerIcons.FolderVideos, label: "Videos" },
7879
];
7980

8081
function ThisPC() {
@@ -103,19 +104,19 @@ function ThisPC() {
103104
fill="58.7%"
104105
space="408.1 GB free of 988 GB"
105106
label="Local Disk (C:)"
106-
icon="/icons/windows-drive.png"
107+
icon={ExplorerIcons.WindowsDrive}
107108
/>
108109
<ThisPcDriveItem
109110
fill="73.7%"
110111
space="498.8 GB free of 1895 GB"
111112
label="Local Disk (D:)"
112-
icon="/icons/drive.png"
113+
icon={ExplorerIcons.Drive}
113114
/>
114115
<ThisPcDriveItem
115116
fill="24.1%"
116117
space="2816.7 GB free of 3712 GB"
117118
label="Local Disk (E:)"
118-
icon="/icons/drive.png"
119+
icon={ExplorerIcons.Drive}
119120
/>
120121
</AccordionContent>
121122
</AccordionItem>

src/app/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { doubleClick } from "@/lib/utils";
3535
import Construction from "@/icons/construction";
3636
import FullScreenBtn from "@/components/desktop/full-screen-item";
3737
import useIsSignedIn from "@/hooks/useIsSignedIn";
38+
import { DesktopIcons } from "@/lib/images";
3839

3940
function Page() {
4041
//* need this
@@ -54,14 +55,14 @@ function Page() {
5455
}}
5556
>
5657
<ExplorerDesktopItem
57-
icon="/icons/pc.ico"
58+
icon={DesktopIcons.PC}
5859
name="This PC"
5960
explorerTab="this-pc"
6061
/>
6162
<Explorer />
6263
<CalculatorItem />
6364
<DesktopItem
64-
icon="/icons/chrome.png"
65+
icon={DesktopIcons.Chrome}
6566
name="Chrome"
6667
className="gap-2"
6768
isShortcut
@@ -81,7 +82,7 @@ function Page() {
8182
}}
8283
/>
8384
<DesktopItem
84-
icon="/icons/vscode.png"
85+
icon={DesktopIcons.Vscode}
8586
name="VS Code"
8687
isShortcut
8788
smallIcon
@@ -102,7 +103,7 @@ function Page() {
102103
win={{ child: <YouTubeEmbed />, id: "youtube" }}
103104
/> */}
104105
{/* <DesktopItem icon="/icons/game.ico" name="Game" isShortcut smallIcon className="gap-2" win={{child: <Iframe src="https://g.poppigames.com/pp/purble-place/" />, id: "friv-game"}} /> */}
105-
{/* <DesktopItem icon="/icons/vscode.png" name="Tic Tac Toe" isShortcut smallIcon className="gap-2" win={{child: <Iframe src="https://www.onlinegames.io/games/2021/unity2/tic-tac-toe/index.html" />, id: "tic-tac-toe"}} /> */}
106+
{/* <DesktopItem icon={DesktopIcons.Vscode} name="Tic Tac Toe" isShortcut smallIcon className="gap-2" win={{child: <Iframe src="https://www.onlinegames.io/games/2021/unity2/tic-tac-toe/index.html" />, id: "tic-tac-toe"}} /> */}
106107
<DesktopItem
107108
icon="/icons/motoX3.jpg"
108109
name="Moto X3M"

src/components/TaskBar/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const TaskBarButton = React.forwardRef<HTMLButtonElement, TaskBarButtonProps>(
3232
{...p}
3333
>
3434
{src && (
35-
<Image
35+
<img
3636
className={cn(
3737
"transition-transform duration-200 animate-in fade-in-0 zoom-in-0 group-active:scale-[.8]",
3838
imgClassName,

src/components/TaskBar/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SegoeIcon from "../segoe-ui-icon";
99
import { cn } from "@/lib/utils";
1010
import { Component } from "../component";
1111
import useOnlineStatus from "@/hooks/useOnline";
12+
import { DesktopIcons } from "@/lib/images";
1213

1314
function TaskBar() {
1415
return (
@@ -127,7 +128,7 @@ function StartButton() {
127128
Pinned <GroupHeaderButton label="All apps" />
128129
</div>
129130
<div className="flex flex-1 flex-wrap content-start justify-start">
130-
<PinnedItem img="/icons/folder.png" title="Name" />
131+
<PinnedItem img={DesktopIcons.Folder} title="Name" />
131132
<PinnedItem
132133
img="/icons/projects.png"
133134
title="Projects"
@@ -183,12 +184,12 @@ function StartButton() {
183184
date="Recently added"
184185
/>
185186
<RecommendItem
186-
img="/icons/folder.png"
187+
img={DesktopIcons.Folder}
187188
title="Github"
188189
date="1h ago"
189190
/>
190191
<RecommendItem
191-
img="/icons/folder.png"
192+
img={DesktopIcons.Folder}
192193
title="Github"
193194
date="2h ago"
194195
/>

src/components/desktop/desktop-item.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"use client";
22
import { clsx, cn } from "@/lib/utils";
3-
import Image from "next/image";
3+
// import Image from "next/image";
44
import React from "react";
55
import { type DraggableWindowProps } from "../drag-window";
66
import dynamic from "next/dynamic";
77
import { useWinState } from "@/hooks/useWinState";
88
import { DesktopItemContextMenuEmittor } from "@/lib/emittors";
9+
import { DesktopIcons } from "@/lib/images";
910
const DraggableWindowBase = dynamic(() =>
1011
import("../drag-window").then((all) => all.DraggableWindowBase),
1112
);
@@ -73,11 +74,11 @@ export function DesktopItemBase({
7374
smallIcon ? "size-10" : "size-11",
7475
)}
7576
>
76-
<Image src={icon} alt={name} width={45} height={45} />
77+
<img src={icon} alt={name} width={45} height={45} />
7778
{isShortcut && (
78-
<Image
79+
<img
7980
className="absolute bottom-0 left-0 size-8"
80-
src="/icons/shortcut.png"
81+
src={DesktopIcons.Shortcut}
8182
alt=""
8283
width={32}
8384
height={32}

src/components/desktop/explorer-desktop-item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { DesktopItemBase } from "./desktop-item";
33
import { explorerTabEmittor } from "@/components/desktop/explorer/emittors";
44
import type { explorerTabsType } from "@/components/desktop/explorer/explorer";
55
import { doubleClick } from "@/lib/utils";
6+
import { DesktopIcons } from "@/lib/images";
67

78
function ExplorerDesktopItem({
89
name,
910
explorerTab,
10-
icon = "/icons/folder.png",
11+
icon = DesktopIcons.Folder,
1112
}: {
1213
icon?: string;
1314
name: string;

src/components/desktop/explorer/_components/explorer-items.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @next/next/no-img-element */
22
import { Component } from "@/components/component";
3+
import { DesktopIcons } from "@/lib/images";
34
import { cn } from "@/lib/utils";
45
import React from "react";
56
type ExplorerItemProps = {
@@ -38,7 +39,7 @@ export function LargeItem({
3839
{isShortcut && (
3940
<img
4041
className="absolute bottom-1 left-2 size-8"
41-
src="/icons/shortcut.png"
42+
src={DesktopIcons.Shortcut}
4243
alt=""
4344
width={32}
4445
height={32}

src/components/desktop/explorer/explorer.tsx

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ResizablePanel,
77
ResizablePanelGroup,
88
} from "@/components/ui/resizable";
9-
import Image from "next/image";
9+
// import Image from "next/image";
1010
import Link from "next/link";
1111
import { Slot } from "@radix-ui/react-slot";
1212
import clsx from "clsx";
@@ -20,35 +20,39 @@ import { explorerTabEmittor } from "./emittors";
2020
import SegoeIcon from "@/components/segoe-ui-icon";
2121
import { ExplorerItems } from "./_components/explorer-items";
2222
import { doubleClick } from "@/lib/utils";
23+
import { DesktopIcons, ExplorerIcons, GH_PublicTree } from "@/lib/images";
24+
import { prefetchImages } from "@/lib/preload-images";
2325

24-
const skills = [
25-
// use images from GitHub repo
26-
{ icon: "js.png", label: "JavaScript" },
27-
{ icon: "mongodb.png", label: "MongoDB" },
28-
{ icon: "mui.png", label: "Material UI" },
29-
{ icon: "mysql.png", label: "MySQL" },
30-
{ icon: "next.png", label: "Next.js" },
31-
{ icon: "node.png", label: "Node.js" },
32-
{ icon: "postgresql.png", label: "PostgreSQL" },
33-
{ icon: "prisma.png", label: "Prisma" },
34-
{ icon: "react.png", label: "React" },
35-
{ icon: "reactnative.png", label: "React Native" },
36-
{ icon: "reactquery.png", label: "React Query" },
37-
{ icon: "redux.png", label: "Redux" },
38-
{ icon: "stripe.png", label: "Stripe" },
39-
{ icon: "tailwind.png", label: "Tailwind CSS" },
40-
{ icon: "tauri.png", label: "Tauri" },
41-
{ icon: "ts.png", label: "TypeScript" },
42-
{ icon: "css.png", label: "CSS" },
43-
{ icon: "docker.png", label: "Docker" },
44-
{ icon: "express.png", label: "Express" },
45-
{ icon: "figma.png", label: "Figma" },
46-
{ icon: "firebase.png", label: "Firebase" },
47-
{ icon: "framer.png", label: "Framer Motion" },
48-
{ icon: "go.png", label: "Go" },
49-
{ icon: "graphql.png", label: "GraphQL" },
50-
{ icon: "html.png", label: "HTML" },
51-
];
26+
// use images from GitHub repo
27+
const skills = (
28+
[
29+
{ icon: "/skills/js.png", label: "JavaScript" },
30+
{ icon: "/skills/mongodb.png", label: "MongoDB" },
31+
{ icon: "/skills/mui.png", label: "Material UI" },
32+
{ icon: "/skills/mysql.png", label: "MySQL" },
33+
{ icon: "/skills/next.png", label: "Next.js" },
34+
{ icon: "/skills/node.png", label: "Node.js" },
35+
{ icon: "/skills/postgresql.png", label: "PostgreSQL" },
36+
{ icon: "/skills/prisma.png", label: "Prisma" },
37+
{ icon: "/skills/react.png", label: "React" },
38+
{ icon: "/skills/reactnative.png", label: "React Native" },
39+
{ icon: "/skills/reactquery.png", label: "React Query" },
40+
{ icon: "/skills/redux.png", label: "Redux" },
41+
{ icon: "/skills/stripe.png", label: "Stripe" },
42+
{ icon: "/skills/tailwind.png", label: "Tailwind CSS" },
43+
{ icon: "/skills/tauri.png", label: "Tauri" },
44+
{ icon: "/skills/ts.png", label: "TypeScript" },
45+
{ icon: "/skills/css.png", label: "CSS" },
46+
{ icon: "/skills/docker.png", label: "Docker" },
47+
{ icon: "/skills/express.png", label: "Express" },
48+
{ icon: "/skills/figma.png", label: "Figma" },
49+
{ icon: "/skills/firebase.png", label: "Firebase" },
50+
{ icon: "/skills/framer.png", label: "Framer Motion" },
51+
{ icon: "/skills/go.png", label: "Go" },
52+
{ icon: "/skills/graphql.png", label: "GraphQL" },
53+
{ icon: "/skills/html.png", label: "HTML" },
54+
] as const
55+
).map((s) => ({ label: s.label, icon: `${GH_PublicTree}${s.icon}` }));
5256

5357
const tabs: Array<
5458
{
@@ -70,13 +74,13 @@ const tabs: Array<
7074
{
7175
title: "This PC",
7276
id: "this-pc",
73-
img: "/icons/pc.ico",
77+
img: DesktopIcons.PC,
7478
tab: ThisPC,
7579
},
7680
{
7781
title: "About Me",
7882
id: "about-me",
79-
img: "/icons/user-folder.png",
83+
img: ExplorerIcons.UserFolder,
8084
tab: AboutTab,
8185
},
8286
{
@@ -121,7 +125,7 @@ function AboutTab() {
121125
return (
122126
<>
123127
<ExplorerItems.Large
124-
icon="/icons/user-folder.png"
128+
icon={ExplorerIcons.UserFolder}
125129
label="Info"
126130
onDoubleClick={() => explorerTabEmittor.emit("about-info")}
127131
/>
@@ -141,7 +145,7 @@ function AboutTab() {
141145
onDoubleClick={() =>
142146
window.open("https://www.github.com", "_blank")
143147
}
144-
icon="/icons/github-icon.png"
148+
icon={DesktopIcons.GithubIcon}
145149
label="Github"
146150
isShortcut
147151
/>
@@ -166,12 +170,7 @@ function SkillsTab() {
166170
<ExplorerItems.Large
167171
className="gap-1"
168172
label={skill.label}
169-
icon={
170-
skill.icon.startsWith("/") ||
171-
skill.icon.startsWith("http")
172-
? skill.icon
173-
: `https://github.com/programming-with-ia/windows-11/raw/8298a01ffae8ad280ee74e18b20e841524be8845/public/skills/${skill.icon}`
174-
}
173+
icon={skill.icon}
175174
key={idx}
176175
/>
177176
))}
@@ -193,8 +192,8 @@ export function ExplorerTitleBar({ controls }: { controls: React.ReactNode }) {
193192
data-explorer-tab
194193
className="relative inline-flex min-w-60 items-center gap-2.5 bg-foreground/5 pl-2.5 text-xs"
195194
>
196-
<Image
197-
src={"/icons/explorer.png"}
195+
<img
196+
src={DesktopIcons.Explorer}
198197
className="size-4"
199198
alt=""
200199
width={16}
@@ -242,6 +241,10 @@ export function ExplorerMain() {
242241
);
243242
const CurrentTab = explorerTabMapped[CurrentTabKey ?? "about-me"];
244243

244+
useEffect(() => {
245+
prefetchImages(skills.map((skill) => skill.icon));
246+
}, []);
247+
245248
return (
246249
<>
247250
<div className="pointer-events-none flex select-none justify-between border-b border-foreground/10 px-5 py-3">
@@ -284,7 +287,7 @@ export function ExplorerMain() {
284287
(typeof item.img == "string" ? (
285288
<span>
286289
{
287-
<Image
290+
<img
288291
src={item.img}
289292
alt={item.title}
290293
width={16}

src/components/desktop/explorer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useState } from "react";
33
// import Explorer from './explorer';
44
import dynamic from "next/dynamic";
55
import { useWinState } from "@/hooks/useWinState";
6+
import { DesktopIcons } from "@/lib/images";
67
const ExplorerWindow = dynamic(() =>
78
import("./explorer").then((a) => a.ExplorerMain),
89
);
@@ -21,7 +22,7 @@ function ExplorerItem() {
2122
onDoubleClick={() => setIsWinShow(true)}
2223
smallIcon
2324
className="gap-1.5"
24-
icon="/icons/explorer.png"
25+
icon={DesktopIcons.Explorer}
2526
name="File Explorer"
2627
id="explorer-desktop-item"
2728
{...(isWinShow

src/components/desktop/full-screen-item.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22
import DesktopItem from "@/components/desktop/desktop-item";
3+
import { DesktopIcons } from "@/lib/images";
34
import { cn } from "@/lib/utils";
45
import type { CompoProps } from "@/types/types";
56
import React, { useEffect, useState } from "react";
@@ -53,8 +54,8 @@ function FullScreenBtn({
5354
key={isFullScreen ? 1 : 0}
5455
icon={
5556
isFullScreen
56-
? "/icons/exit-full-screen.png"
57-
: "/icons/full-screen.png"
57+
? DesktopIcons.ExitFullScreen
58+
: DesktopIcons.FullScreen
5859
}
5960
name={isFullScreen ? "Exit Full Screen" : "Full Screen"}
6061
isShortcut

0 commit comments

Comments
 (0)