Skip to content

Commit 4917656

Browse files
committed
Update Settings.tsx UI
1 parent 5744735 commit 4917656

File tree

5 files changed

+114
-12
lines changed

5 files changed

+114
-12
lines changed
+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
1+
// STORES
2+
import { useFileName } from "@/stores"
23

34
export default function Title() {
5+
6+
// Get the file name from the store
7+
const { currentFileName } = useFileName()
8+
49
return (
5-
<div className="font-semibold">Untitled Presentation</div>
6-
)
10+
<div className="font-semibold">{currentFileName}</div>
11+
)
712
}

src/components/common/right-section/Settings.tsx

+79-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// UI
32
import { Button } from "@/components/ui/button"
43
import {
@@ -9,27 +8,99 @@ import {
98
DialogTitle,
109
DialogTrigger,
1110
} from "@/components/ui/dialog"
11+
import { Input } from "@/components/ui/input"
12+
import { Label } from "@/components/ui/label"
13+
import { Separator } from "@/components/ui/separator"
1214

1315
// ICONS
1416
import { FcSettings } from "react-icons/fc"
17+
import { FiCopy } from "react-icons/fi"
18+
19+
// STORES
20+
import { useFileName } from "@/stores"
21+
22+
23+
24+
1525

1626
export default function Settings() {
27+
28+
// Get the file name from the store
29+
const { currentFileName, newFileName, setNewFileName, setCurrentFileName } = useFileName();
30+
31+
// Temp fileID
32+
const fileId = "FILE_12345"
33+
34+
const handleCopyFileId = async () => {
35+
await navigator.clipboard.writeText(fileId)
36+
}
37+
38+
const handleUpdateFileName = () => {
39+
setCurrentFileName(newFileName)
40+
}
41+
42+
1743
return (
1844
<Dialog>
19-
<DialogTrigger>
20-
<Button variant="outline" className="flex justify-center items-center capitalize">
21-
<FcSettings className="!size-5" />
45+
<DialogTrigger asChild>
46+
<Button variant="outline" className="flex items-center">
47+
<FcSettings className="h-5 w-5" />
2248
<span>Settings</span>
2349
</Button>
2450
</DialogTrigger>
25-
<DialogContent>
51+
<DialogContent className="sm:max-w-[425px]">
2652
<DialogHeader>
27-
<DialogTitle>Are you absolutely sure?</DialogTitle>
53+
<DialogTitle>File Settings</DialogTitle>
2854
<DialogDescription>
29-
This action cannot be undone. This will permanently delete your account
30-
and remove your data from our servers.
55+
Manage your file settings and properties.
3156
</DialogDescription>
3257
</DialogHeader>
58+
<div className="grid gap-4 mt-2">
59+
60+
<div className="grid gap-3 mb-2">
61+
<Label htmlFor="fileId">File ID</Label>
62+
<div className="flex items-center gap-2">
63+
<Input
64+
id="fileId"
65+
value={fileId}
66+
readOnly
67+
className="bg-gray-100 flex-grow"
68+
/>
69+
<Button
70+
variant="outline"
71+
size="icon"
72+
onClick={handleCopyFileId}
73+
aria-label="Copy file ID"
74+
>
75+
<FiCopy className="h-4 w-4" />
76+
</Button>
77+
</div>
78+
</div>
79+
80+
<div className="grid gap-3 mb-2">
81+
<div className="flex items-center justify-between">
82+
<Label htmlFor="fileName">File name</Label>
83+
<span className="text-sm font-medium text-gray-500">Current: {currentFileName}</span>
84+
</div>
85+
<Input
86+
id="fileName"
87+
maxLength={25}
88+
onChange={(e) => setNewFileName(e.target.value)}
89+
placeholder="Enter new file name"
90+
/>
91+
</div>
92+
93+
<Separator />
94+
95+
<div className="flex justify-between items-center">
96+
<Button variant="destructive">
97+
Delete file
98+
</Button>
99+
<Button disabled={newFileName.length <= 0} onClick={handleUpdateFileName}>
100+
Update file name
101+
</Button>
102+
</div>
103+
</div>
33104
</DialogContent>
34105
</Dialog>
35106
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
interface useFileName_interface {
2+
currentFileName: string,
3+
setCurrentFileName: (state: string) => void,
4+
5+
newFileName: string,
6+
setNewFileName: (state: string) => void,
7+
8+
}
9+
10+
export default useFileName_interface

src/stores/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export { default as useTools } from './tools/useTools'
1+
export { default as useTools } from './tools/useTools'
2+
export { default as useFileName } from './settings/useFileName'

src/stores/settings/useFileName.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { create } from 'zustand';
2+
import useFileName_interface from '@/interfaces/settings/useFileName_interface';
3+
4+
const useFileName = create<useFileName_interface>((set) => ({
5+
6+
// Current file name
7+
currentFileName: 'Untitled file',
8+
setCurrentFileName: (state) => set({ currentFileName: state }),
9+
10+
// New file name
11+
newFileName: '',
12+
setNewFileName: (state) => set({ newFileName: state }),
13+
}))
14+
15+
export default useFileName;

0 commit comments

Comments
 (0)