create-murasaki 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -95,3 +95,30 @@ code {
|
|
|
95
95
|
|
|
96
96
|
.counter button:hover { background: rgba(168, 85, 247, 0.15); }
|
|
97
97
|
.counter button:active { transform: scale(0.94); }
|
|
98
|
+
|
|
99
|
+
.actions {
|
|
100
|
+
margin-top: 24px;
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: 12px;
|
|
103
|
+
flex-wrap: wrap;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.actions button {
|
|
108
|
+
padding: 10px 18px;
|
|
109
|
+
border-radius: 10px;
|
|
110
|
+
border: 1px solid rgba(168, 85, 247, 0.25);
|
|
111
|
+
background: rgba(168, 85, 247, 0.05);
|
|
112
|
+
color: #5B21B6;
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
font-weight: 600;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
transition: background 0.12s, transform 0.06s;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@media (prefers-color-scheme: dark) {
|
|
120
|
+
.actions button { color: #d8b4fe; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.actions button:hover { background: rgba(168, 85, 247, 0.15); }
|
|
124
|
+
.actions button:active { transform: scale(0.97); }
|
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
// src/app/page.tsx — the "/" route.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Demonstrates hooks from murasaki/jsx/dom:
|
|
4
|
+
// useState — re-render on state change
|
|
5
|
+
// useNotification — OS notification banner
|
|
6
|
+
// useClipboard — read/write system clipboard
|
|
7
|
+
// useShell — open URL in default browser
|
|
8
|
+
// useDialog + useFs — file picker + read
|
|
5
9
|
|
|
6
10
|
import { Link } from 'murasaki'
|
|
7
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useClipboard,
|
|
13
|
+
useDialog,
|
|
14
|
+
useFs,
|
|
15
|
+
useNotification,
|
|
16
|
+
useShell,
|
|
17
|
+
useState,
|
|
18
|
+
} from 'murasaki/jsx/dom'
|
|
8
19
|
|
|
9
20
|
export default function HomePage() {
|
|
10
21
|
const [count, setCount] = useState(0)
|
|
22
|
+
const [filePath, setFilePath] = useState('')
|
|
23
|
+
|
|
24
|
+
const notify = useNotification()
|
|
25
|
+
const clipboard = useClipboard()
|
|
26
|
+
const shell = useShell()
|
|
27
|
+
const dialog = useDialog()
|
|
28
|
+
const fs = useFs()
|
|
29
|
+
|
|
30
|
+
async function pickFile() {
|
|
31
|
+
const paths = await dialog.openFile({ title: 'Pick a file' })
|
|
32
|
+
if (paths.length === 0) return
|
|
33
|
+
setFilePath(paths[0])
|
|
34
|
+
const text = await fs.readFile(paths[0])
|
|
35
|
+
notify({ title: 'File loaded', body: `${text.length} chars from ${paths[0]}` })
|
|
36
|
+
}
|
|
37
|
+
|
|
11
38
|
return (
|
|
12
39
|
<main>
|
|
13
40
|
<h1>Hello, Murasaki 🦋</h1>
|
|
@@ -25,9 +52,22 @@ export default function HomePage() {
|
|
|
25
52
|
</button>
|
|
26
53
|
</div>
|
|
27
54
|
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
<div className="actions">
|
|
56
|
+
<button onClick={() => notify({ title: 'Hello', body: `Count: ${count}` })}>
|
|
57
|
+
🔔 Notify
|
|
58
|
+
</button>
|
|
59
|
+
<button onClick={() => clipboard.write(`Count: ${count}`)}>📋 Copy</button>
|
|
60
|
+
<button onClick={pickFile}>📂 Pick file</button>
|
|
61
|
+
<button onClick={() => shell.openExternal('https://github.com/murasakijs/murasaki')}>
|
|
62
|
+
🔗 Repo
|
|
63
|
+
</button>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{filePath && (
|
|
67
|
+
<p className="hint">
|
|
68
|
+
Last picked: <code>{filePath}</code>
|
|
69
|
+
</p>
|
|
70
|
+
)}
|
|
31
71
|
|
|
32
72
|
<nav className="links">
|
|
33
73
|
<Link href="/about">About →</Link>
|