Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"@gsap/react": "^2.1.2",
"@tailwindcss/vite": "^4.1.18",
"clsx": "^2.1.1",
"dayjs": "^1.11.19",
"gsap": "^3.14.2",
"immer": "^11.1.4",
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gsap from 'gsap';
import { Draggable } from 'gsap/Draggable';

import { Navbar, Welcome, Dock } from '#components';
import { Terminal, Safari, Resume } from '#windows';
import { Terminal, Safari, Resume, Finder } from '#windows';

gsap.registerPlugin(Draggable);

Expand All @@ -16,6 +16,7 @@ const App = () => {
<Terminal />
<Safari />
<Resume />
<Finder />
</main>
);
};
Expand Down
19 changes: 6 additions & 13 deletions src/store/location.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';
import { locations } from '#constants';

// Extract the type of a single location (e.g., the 'work' or 'trash' object)
type Location = (typeof locations)[keyof typeof locations];
import { FinderItem } from '#types'; // Use your new alias/path

interface LocationState {
activeLocation: Location; // Strictly typed to your constants
setActiveLocation: (location: Location | null) => void;
activeLocation: FinderItem;
setActiveLocation: (location: FinderItem | null) => void;
resetActiveLocation: () => void;
}

const DEFAULT_LOCATION = locations.work;
const DEFAULT_LOCATION = locations.work as FinderItem;

// Global state management for file explorer/projects
const useLocationStore = create<LocationState>()(
immer((set) => ({
activeLocation: DEFAULT_LOCATION,

setActiveLocation: (location = null) =>
setActiveLocation: (location) =>
set((state) => {
if (location) {
state.activeLocation = location;
}
if (location) state.activeLocation = location as FinderItem;
}),

resetActiveLocation: () =>
set((state) => {
state.activeLocation = DEFAULT_LOCATION;
Expand Down
23 changes: 23 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// TODO: move all types here
export type WindowID =
| 'finder'
| 'contact'
| 'resume'
| 'safari'
| 'photos'
| 'terminal'
| 'txtfile'
| 'imgfile';

export interface FinderItem {
id: number | string;
name: string;
icon: string;
kind: 'folder' | 'file';
type?: string;
fileType?: string;
position?: string;
imageUrl?: string;
href?: string;
children?: FinderItem[];
}
84 changes: 84 additions & 0 deletions src/windows/Finder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { WindowControls } from '#components';
import { locations } from '#constants';
import WindowWrapper from '#hoc/WindowWrapper';
import useLocationStore from '#store/location';
import useWindowStore from '#store/window';
import { clsx } from 'clsx';
import { Search } from 'lucide-react';
import { FinderItem, WindowID } from '#types';

const Finder = () => {
const { openWindow } = useWindowStore();
const { activeLocation, setActiveLocation } = useLocationStore();

const openItem = (item: FinderItem) => {
if (item.fileType === 'pdf') return openWindow('resume');
if (item.kind === 'folder') return setActiveLocation(item);
if (['fig', 'url'].includes(item.fileType ?? '') && item.href)
return window.open(item.href, '_blank');

const windowId = `${item.fileType}${item.kind}` as WindowID;
openWindow(windowId, item);
};

const renderList = (name: string, items: FinderItem[]) => (
<div>
<h3>{name}</h3>

<ul>
{items.map((item) => (
<li
key={item.id}
onClick={() => setActiveLocation(item)}
className={clsx(
item.id === activeLocation?.id ? 'active' : 'not-active',
)}
>
<img src={item.icon} className="w-4" alt={item.name} />
<p className="text-sm font-medium truncate">{item.name}</p>
</li>
))}
</ul>
</div>
);

return (
<>
<div id="window-header">
<WindowControls target="finder" />
<Search className="icon" />
</div>{' '}
<div className="bg-white flex h-full">
<div className="sidebar">
<ul>
{renderList('Favorites', Object.values(locations) as FinderItem[])}
</ul>
<ul>
{renderList(
'Work',
(locations.work.children as FinderItem[]) || [],
)}
</ul>
</div>

<ul className="content">
{(activeLocation?.children ?? []).map((item) => (
<li
key={item.id}
className={item.position}
onClick={() => openItem(item)}
>
{' '}
<img src={item.icon} alt={item.name} />
<p> {item.name} </p>
</li>
))}
</ul>
</div>
</>
);
};

const FinderWindow = WindowWrapper(Finder, 'finder');

export default FinderWindow;
3 changes: 2 additions & 1 deletion src/windows/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Terminal from '#windows/Terminal';
import Safari from '#windows/Safari';
import Resume from '#windows/Resume';
import Finder from '#windows/Finder';

export { Terminal, Safari, Resume };
export { Terminal, Safari, Resume, Finder };