Skip to content

Commit 8c08bca

Browse files
committed
Merge pull request #14 from IgorD-lab/feat/img-viewer
implemented image file (window) viewer
2 parents 49c6e9d + 352d6bf commit 8c08bca

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import gsap from 'gsap';
22
import { Draggable } from 'gsap/Draggable';
33

44
import { Navbar, Welcome, Dock } from '#components';
5-
import { Terminal, Safari, Resume, Finder, Text } from '#windows';
5+
import { Terminal, Safari, Resume, Finder, Text, Image } from '#windows';
66

77
gsap.registerPlugin(Draggable);
88

@@ -18,6 +18,7 @@ const App = () => {
1818
<Resume />
1919
<Finder />
2020
<Text />
21+
<Image />
2122
</main>
2223
);
2324
};

src/windows/Image.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { WindowControls } from '#components';
2+
import WindowWrapper from '#hoc/WindowWrapper';
3+
import useWindowStore from '#store/window';
4+
5+
const ImageWindowContent = () => {
6+
const { windows } = useWindowStore();
7+
8+
const data = windows.imgfile?.data;
9+
10+
if (!data) return null;
11+
12+
const { name, imageUrl } = data;
13+
14+
return (
15+
<>
16+
<div id="window-header">
17+
<WindowControls target="imgfile" />
18+
<h2>{name}</h2>
19+
</div>
20+
21+
<div className="p-5 bg-white">
22+
{imageUrl ? (
23+
<div className="w-full">
24+
<img
25+
src={imageUrl}
26+
alt={name}
27+
className="w-full h-auto max-h-[70vh] object-contain rounded"
28+
/>
29+
</div>
30+
) : null}
31+
</div>
32+
</>
33+
);
34+
};
35+
36+
const ImageWindow = WindowWrapper(ImageWindowContent, 'imgfile');
37+
export default ImageWindow;

src/windows/Text.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import WindowWrapper from '#hoc/WindowWrapper';
33
import useWindowStore from '#store/window';
44
import { FinderItem } from '#types';
55

6-
const Text = () => {
6+
const TextWindowContent = () => {
77
const { windows } = useWindowStore();
88

99
// Directly access the data stored for this window
@@ -43,5 +43,5 @@ const Text = () => {
4343
);
4444
};
4545

46-
const TextWindow = WindowWrapper(Text, 'txtfile');
46+
const TextWindow = WindowWrapper(TextWindowContent, 'txtfile');
4747
export default TextWindow;

src/windows/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import Safari from '#windows/Safari';
33
import Resume from '#windows/Resume';
44
import Finder from '#windows/Finder';
55
import Text from '#windows/Text';
6+
import Image from './Image';
67

7-
export { Terminal, Safari, Resume, Finder, Text };
8+
export { Terminal, Safari, Resume, Finder, Text, Image };

0 commit comments

Comments
 (0)