Skip to content

Commit 9df4bf4

Browse files
Apply UI/UX review suggestions
1 parent 3d9eeda commit 9df4bf4

File tree

1 file changed

+60
-43
lines changed

1 file changed

+60
-43
lines changed

plugin/home/src/App.tsx

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
import { FiSearch, FiGlobe, FiUpload, FiHash, FiInfo } from "react-icons/fi";
1+
import { FiSearch, FiInfo } from "react-icons/fi";
22
import { useEffect, useState } from "react";
33
import { GenerateTheme } from "deweb-pages/src/hooks/GenerateTheme";
44

5+
type QuickAccessItemProps = {
6+
path: string;
7+
title: string;
8+
description: string;
9+
href: string;
10+
};
11+
12+
const QuickAccessItem = ({ path, title, description, href }: QuickAccessItemProps) => (
13+
<a
14+
href={href}
15+
target="_blank"
16+
rel="noopener noreferrer"
17+
className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all no-underline block"
18+
>
19+
<div className="flex items-center justify-center mb-4">
20+
<span className="paragraph-lg text-4xl">{path}</span>
21+
</div>
22+
<h3 className="paragraph-lg text-xl font-bold mb-2">{title}</h3>
23+
<p className="paragraph-lg text-sm">{description}</p>
24+
</a>
25+
);
26+
527
export default function App() {
628
const [searchQuery, setSearchQuery] = useState("");
729
const [port, setPort] = useState("");
@@ -35,21 +57,42 @@ export default function App() {
3557
});
3658
}, []);
3759

38-
const redirectTo = (service: string) => {
60+
const generateUrl = (service: string, path: string = '') => {
3961
const { host } = new URL(window.location.href);
40-
const url = host === "station.massa" && port
41-
? `http://${service}.localhost:${port}`
42-
: `//${service}.${host}`;
43-
window.open(url, '_blank');
62+
return host === "station.massa" && port
63+
? `http://${service}.localhost:${port}${path}`
64+
: `//${service}.${host}${path}`;
4465
};
4566

4667
const handleSearch = (e: React.FormEvent) => {
4768
e.preventDefault();
4869
if (searchQuery.trim()) {
49-
redirectTo(searchQuery);
70+
window.open(generateUrl(searchQuery), '_blank');
5071
}
5172
};
5273

74+
const quickAccessItems = [
75+
{
76+
path: "/explore",
77+
title: "Explore DeWeb",
78+
description: "Browse the list of all websites available in the decentralized web ecosystem",
79+
service: "deweb",
80+
pathUrl: "/explore"
81+
},
82+
{
83+
path: "/mns",
84+
title: "Massa Name System",
85+
description: "Decentralized naming service for users and smart contracts on the Massa blockchain",
86+
service: "mns"
87+
},
88+
{
89+
path: "/upload",
90+
title: "DeWeb Uploader",
91+
description: "Upload and manage your websites on DeWeb",
92+
service: "dws"
93+
}
94+
];
95+
5396
const theme = GenerateTheme();
5497

5598
return (
@@ -83,44 +126,18 @@ export default function App() {
83126
<span className="mr-3 text-primary">.massa</span>
84127
</form>
85128

86-
<h2 className="text-2xl font-bold mb-4">Quick Access</h2>
129+
<h2 className="paragraph-lg text-2xl font-bold mb-4 text-secondary">Quick Access</h2>
87130

88131
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 w-full md:w-4/5 lg:w-3/4 xl:w-2/3 mb-8">
89-
{/* DeWeb Homepage Card */}
90-
<div
91-
onClick={() => redirectTo('deweb')}
92-
className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all"
93-
>
94-
<div className="flex items-center justify-center mb-4">
95-
<FiGlobe className="text-4xl" />
96-
</div>
97-
<h3 className="text-xl font-bold mb-2">DeWeb</h3>
98-
<p className="text-sm">Search for websites and browse the list of websites uploaded on DeWeb</p>
99-
</div>
100-
101-
{/* MNS Card */}
102-
<div
103-
onClick={() => redirectTo('mns')}
104-
className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all"
105-
>
106-
<div className="flex items-center justify-center mb-4">
107-
<FiHash className="text-4xl" />
108-
</div>
109-
<h3 className="text-xl font-bold mb-2">Massa Name System</h3>
110-
<p className="text-sm">Decentralized naming service for users and smart contracts on the Massa blockchain</p>
111-
</div>
112-
113-
{/* DeWeb Uploader Card */}
114-
<div
115-
onClick={() => redirectTo('dws')}
116-
className="bg-secondary text-primary p-6 rounded-lg shadow-lg cursor-pointer hover:bg-opacity-90 transition-all"
117-
>
118-
<div className="flex items-center justify-center mb-4">
119-
<FiUpload className="text-4xl" />
120-
</div>
121-
<h3 className="text-xl font-bold mb-2">DeWeb Uploader</h3>
122-
<p className="text-sm">Upload and manage your websites on DeWeb</p>
123-
</div>
132+
{quickAccessItems.map((item) => (
133+
<QuickAccessItem
134+
key={item.path}
135+
path={item.path}
136+
title={item.title}
137+
description={item.description}
138+
href={generateUrl(item.service, item.pathUrl || '')}
139+
/>
140+
))}
124141
</div>
125142
</div>
126143
);

0 commit comments

Comments
 (0)