Skip to content

Commit fbbec76

Browse files
committed
some updates
1 parent 093bf50 commit fbbec76

File tree

9 files changed

+228
-86
lines changed

9 files changed

+228
-86
lines changed

bun.lockb

1.12 KB
Binary file not shown.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@
1212
"deploy": "gh-pages -d out"
1313
},
1414
"dependencies": {
15-
"@radix-ui/react-collapsible": "^1.1.3",
15+
"@radix-ui/react-collapsible": "^1.1.11",
1616
"@radix-ui/react-icons": "^1.3.2",
17-
"@radix-ui/react-navigation-menu": "^1.2.5",
18-
"@radix-ui/react-scroll-area": "^1.2.3",
19-
"@radix-ui/react-slot": "^1.1.2",
20-
"caniuse-lite": "^1.0.30001707",
17+
"@radix-ui/react-navigation-menu": "^1.2.13",
18+
"@radix-ui/react-scroll-area": "^1.2.9",
19+
"@radix-ui/react-slot": "^1.2.3",
20+
"caniuse-lite": "^1.0.30001727",
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",
23-
"glob": "^11.0.1",
23+
"glob": "^11.0.3",
2424
"lodash": "^4.17.21",
2525
"lucide-react": "^0.456.0",
26-
"next": "^15.2.3",
26+
"next": "^15.4.4",
2727
"next-themes": "^0.4.6",
28-
"prettier": "^3.5.3",
28+
"prettier": "^3.6.2",
2929
"react": "18.3.1",
3030
"react-dom": "18.3.1",
3131
"rehype-sanitize": "^6.0.0",
3232
"rehype-stringify": "^10.0.1",
3333
"remark": "^15.0.1",
3434
"remark-html": "^16.0.1",
3535
"remark-parse": "^11.0.0",
36-
"remark-rehype": "^11.1.1",
37-
"semver": "^7.7.1",
36+
"remark-rehype": "^11.1.2",
37+
"semver": "^7.7.2",
3838
"unified": "^11.0.5",
3939
"wasm": "^1.0.0",
4040
"wasm-pack": "^0.13.1"
4141
},
4242
"devDependencies": {
43-
"@types/lodash": "^4.17.16",
43+
"@types/lodash": "^4.17.20",
4444
"@types/node": "22.9.0",
4545
"@types/react": "18.3.12",
4646
"@types/react-dom": "18.3.1",
4747
"autoprefixer": "10.4.20",
48-
"bun-types": "^1.2.5",
48+
"bun-types": "^1.2.19",
4949
"eslint": "9.14.0",
5050
"eslint-config-next": "15.0.3",
5151
"gh-pages": "^6.3.0",

src/components/applications/finder.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11

2+
import React from 'react'
3+
4+
export type MenuItem = {
5+
label: string
6+
dropdown: React.ReactNode
7+
}
8+
9+
export const menuItems: MenuItem[] = [
10+
{
11+
label: 'Finder',
12+
dropdown: <div>Finder Menu</div>
13+
},
14+
{
15+
label: 'File',
16+
dropdown: <div>File Menu</div>
17+
},
18+
{
19+
label: 'Edit',
20+
dropdown: <div>Edit Menu</div>
21+
},
22+
{
23+
label: 'View',
24+
dropdown: <div>View Menu</div>
25+
}
26+
]
227

328
interface FinderProps {
429
path?: string;
530
}
631

732
const Finder = ({ path = '/home/soohoon' }: FinderProps) => {
8-
933
return (
1034
<div>
1135
<h1>Finder</h1>

src/components/applications/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client"
22

3-
import type { Application, DesktopIcon } from '@/providers/desktop'
3+
import type { DesktopIcon } from '@/providers/desktop'
4+
import type { Application } from '@/providers/os'
45

56

67
export const icons: DesktopIcon[] = [
@@ -33,18 +34,17 @@ export const icons: DesktopIcon[] = [
3334
},
3435
]
3536

36-
// Export applications configuration
3737
export const applications: Application[] = [
3838
{
3939
name: 'Finder',
40-
command: 'finder',
40+
command: 'finder'
4141
},
4242
{
4343
name: 'Terminal',
44-
command: 'terminal',
44+
command: 'terminal'
4545
},
4646
{
4747
name: 'Teach Text',
48-
command: 'teach-text',
48+
command: 'teach-text'
4949
},
5050
]

src/components/applications/teach-text.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
import React from 'react'
12
import { fs } from '@/data/fs'
23

4+
export type MenuItem = {
5+
label: string
6+
dropdown: React.ReactNode
7+
}
8+
9+
export const menuItems: MenuItem[] = [
10+
{
11+
label: 'File',
12+
dropdown: <div>File Menu</div>
13+
},
14+
{
15+
label: 'Edit',
16+
dropdown: <div>Edit Menu</div>
17+
},
18+
{
19+
label: 'Format',
20+
dropdown: <div>Format Menu</div>
21+
}
22+
]
23+
324
interface TeachTextProps {
425
path?: string;
526
}

src/components/applications/terminal.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
import React from 'react';
44
import { useOs } from '@/providers/os';
55

6+
export type MenuItem = {
7+
label: string
8+
dropdown: React.ReactNode
9+
}
10+
11+
export const menuItems: MenuItem[] = [
12+
{
13+
label: 'Terminal',
14+
dropdown: <div>Terminal Menu</div>
15+
},
16+
{
17+
label: 'Shell',
18+
dropdown: <div>Shell Menu</div>
19+
},
20+
{
21+
label: 'Edit',
22+
dropdown: <div>Edit Menu</div>
23+
}
24+
]
25+
626
// Add missing utility functions and state
727
const history = {
828
messages: [] as { role: 'user' | 'assistant'; content: string }[],

src/components/desktop/menu-bar.tsx

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
"use client"
22

3+
import { useOs } from "@/providers/os"
4+
import { useDesktop } from "@/providers/desktop"
35
import { useState, useEffect } from "react"
6+
import type { MenuItem } from "@/components/applications/finder"
7+
8+
async function getMenuItemsForCommand(command: string): Promise<MenuItem[]> {
9+
try {
10+
const menuModule = await import(`@/components/applications/${command}`)
11+
return menuModule.menuItems
12+
} catch (error) {
13+
console.warn(`No menu items found for command: ${command}`)
14+
return []
15+
}
16+
}
417

518
export const MenuBar = () => {
619
const [currentTime, setCurrentTime] = useState(new Date())
20+
const [menuItems, setMenuItems] = useState<MenuItem[]>([])
21+
const { selectedProcessId } = useDesktop()
22+
const { pcb } = useOs()
723

824
useEffect(() => {
9-
const timer = setInterval(() => {
10-
setCurrentTime(new Date())
11-
}, 5000)
12-
25+
const timer = setInterval(() => setCurrentTime(new Date()), 5000)
1326
return () => clearInterval(timer)
1427
}, [])
1528

29+
useEffect(() => {
30+
const selectedProcess = pcb.get(selectedProcessId)
31+
if (!selectedProcess) {
32+
setMenuItems([])
33+
return
34+
}
35+
36+
const loadMenuItems = async () => {
37+
const items = await getMenuItemsForCommand(selectedProcess.command)
38+
setMenuItems(items)
39+
}
40+
41+
loadMenuItems()
42+
}, [selectedProcessId, pcb])
43+
1644
const formattedTime = currentTime.toLocaleTimeString([], {
1745
hour: "2-digit",
1846
minute: "2-digit",
@@ -27,10 +55,9 @@ export const MenuBar = () => {
2755
<div className="flex items-center">
2856
<span className="pl-4 pr-2 font-bold text-center text-xl">λ</span>
2957
</div>
30-
<span>File</span>
31-
<span>Edit</span>
32-
<span>View</span>
33-
<span>Special</span>
58+
{menuItems.map((item) => (
59+
<span key={item.label}>{item.label}</span>
60+
))}
3461
</div>
3562
<div className="ml-auto flex items-center space-x-2">
3663
<span>{formattedTime}</span>

0 commit comments

Comments
 (0)