Skip to content

Commit a55b52c

Browse files
authored
refactor: abstracted components and assets to @common-config (#50)
- Components and some images are now organized in the `@common-config` package - Styles are distributed effectively within their respective package Issue https://linear.app/defi-wonderland/issue/CHA-339/monorepo-refactor-for-common-components-abstraction <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit * **New Features** * Introduced reusable visual components (CategoryCards, HeroSection, HandbookSection, IlustrationsContainer) with customizable props for enhanced homepage layouts. * Added new export paths for components and types in the shared configuration package. * **Enhancements** * Updated homepage layouts to use shared, typed components and explicit configuration for categories, hero sections, and partner handbooks. * Improved theming and dynamic styling for category cards and backgrounds. * Added a styled "Disclaimer" button to the template site's navbar with responsive behavior. * Added a modal dialog in the template site triggered by the "Disclaimer" button. * Added a responsive background overlay with masked ellipse SVG to Wonderland site’s local styles. * Updated CSS to remove redundant background overlays and adjust asset URL paths for consistency. * **Bug Fixes** * Corrected asset paths for icons and logos to ensure proper display across themes and dropdowns. * Updated handbook dropdown URLs to real domains. * **Chores** * Added React 19 and type definitions to dependencies for improved compatibility and type safety. * Improved TypeScript configuration for better type support and debugging. * Removed redundant or now-shared local components in favor of shared package usage. * Added TypeScript module declarations for CSS and Docusaurus Link components. * Cleaned up modal-related code by removing it from the Wonderland site’s Root component. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 9f34aa5 commit a55b52c

50 files changed

Lines changed: 1392 additions & 397 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/common-config/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
],
1111
"exports": {
1212
"./styles/global.css": "./static/common/styles/global.css",
13+
"./components": "./src/components/index.ts",
1314
"./preset": "./dist/preset/index.js",
1415
"./preset/commonDocusaurusConfig": {
1516
"types": "./preset/commonDocusaurusConfig.ts",
@@ -24,11 +25,15 @@
2425
"@docusaurus/types": "3.7.0",
2526
"prism-react-renderer": "2.3.0",
2627
"remark-math": "6.0.0",
27-
"rehype-katex": "7.0.1"
28+
"rehype-katex": "7.0.1",
29+
"react": "19.0.0",
30+
"react-dom": "19.0.0"
2831
},
2932
"devDependencies": {
3033
"fs-extra": "11.2.0",
3134
"@types/fs-extra": "11.0.4",
35+
"@types/react": "19.0.0",
36+
"@types/react-dom": "19.0.0",
3237
"typescript": "5.6.2"
3338
}
3439
}

packages/common-config/preset/commonDocusaurusConfig.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ const commonDocusaurusConfig: Partial<Config> = {
3636
},
3737
style: "dark",
3838
items: [
39-
// {
40-
// type: "html",
41-
// position: "right",
42-
// value:
43-
// '<style>#disclaimer-btn::before { content: ""; width: 16px; height: 16px; background-image: url("/img/icons/information-circle.svg"); background-size: contain; background-repeat: no-repeat; margin-right: 8px; } #disclaimer-btn:hover { color: #d1d5db; } @media (max-width: 996px) { #disclaimer-btn { display: none !important; } }</style><button id="disclaimer-btn" style="background: none; border: none; color: #5D6B98; cursor: pointer; margin-left: 8px; display: flex; align-items: center; font-size: 14px; font-family: inherit; transition: color 0.2s ease;">Disclaimer</button>',
44-
// },
4539
{
4640
type: "dropdown",
4741
label: "Handbooks",
@@ -53,13 +47,15 @@ const commonDocusaurusConfig: Partial<Config> = {
5347
},
5448
{
5549
label: "Optimism",
56-
to: "https://optimism-handbook.example.com",
50+
to: "https://handbook.wonderland.xyz/optimism",
5751
target: "_blank",
5852
rel: "noopener noreferrer",
5953
},
54+
// // TODO: Enable when Aztec handbook is ready
55+
// // TODO: Remember to add the rewrite in vercel.json!
6056
// {
6157
// label: "Aztec",
62-
// to: "https://aztec-handbook.example.com",
58+
// to: "https://handbook.wonderland.xyz/aztec",
6359
// target: "_blank",
6460
// rel: "noopener noreferrer",
6561
// },

sites/wonderland/src/components/Backgrounds/FooterBackground/index.tsx renamed to packages/common-config/src/components/Backgrounds/FooterBackground/index.tsx

File renamed without changes.

sites/wonderland/src/components/Backgrounds/FooterBackground/styles.module.css renamed to packages/common-config/src/components/Backgrounds/FooterBackground/styles.module.css

File renamed without changes.

sites/wonderland/src/components/Backgrounds/NoiseBackground/index.tsx renamed to packages/common-config/src/components/Backgrounds/NoiseBackground/index.tsx

File renamed without changes.

sites/wonderland/src/components/Backgrounds/NoiseBackground/styles.module.css renamed to packages/common-config/src/components/Backgrounds/NoiseBackground/styles.module.css

File renamed without changes.

sites/wonderland/src/components/Backgrounds/TriangleBackground/index.tsx renamed to packages/common-config/src/components/Backgrounds/TriangleBackground/index.tsx

File renamed without changes.

sites/wonderland/src/components/Backgrounds/TriangleBackground/styles.module.css renamed to packages/common-config/src/components/Backgrounds/TriangleBackground/styles.module.css

File renamed without changes.

sites/wonderland/src/components/Backgrounds/index.ts renamed to packages/common-config/src/components/Backgrounds/index.ts

File renamed without changes.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import Link from "@docusaurus/Link";
2+
import styles from "./styles.module.css";
3+
import { ReactNode } from "react";
4+
5+
export interface Category {
6+
title: string;
7+
icon: string;
8+
href: string;
9+
}
10+
11+
export interface CategoryCardsTheme {
12+
gradientStart: string;
13+
gradientEnd: string;
14+
iconHoverColorEffect?: "white" | "none";
15+
}
16+
17+
interface CategoryCardsProps {
18+
categories: Category[];
19+
theme?: CategoryCardsTheme;
20+
}
21+
22+
export default function CategoryCards({
23+
categories,
24+
theme,
25+
}: CategoryCardsProps): ReactNode {
26+
const handleCardClick = (
27+
e: React.MouseEvent<HTMLAnchorElement>,
28+
href: string
29+
) => {
30+
e.preventDefault();
31+
32+
// Scroll to top
33+
window.scrollTo({ top: 0 });
34+
35+
// Navigate after scroll
36+
setTimeout(() => {
37+
window.location.href = href;
38+
}, 10);
39+
};
40+
41+
// Default theme (Wonderland)
42+
const defaultTheme: CategoryCardsTheme = {
43+
gradientStart: "var(--wonderland-pink)",
44+
gradientEnd: "var(--wonderland-yellow)",
45+
iconHoverColorEffect: "white",
46+
};
47+
48+
const currentTheme = theme || defaultTheme;
49+
50+
return (
51+
<div className={styles.categoryCards}>
52+
{categories.map((category) => (
53+
<Link
54+
key={category.title}
55+
to={category.href}
56+
className={`${styles.categoryCard} ${currentTheme.iconHoverColorEffect === "none" ? styles.noIconHoverEffect : ""}`}
57+
onClick={(e: React.MouseEvent<HTMLAnchorElement>) =>
58+
handleCardClick(e, category.href)
59+
}
60+
style={
61+
{
62+
"--gradient-start": currentTheme.gradientStart,
63+
"--gradient-end": currentTheme.gradientEnd,
64+
} as React.CSSProperties
65+
}
66+
>
67+
<img
68+
src={category.icon}
69+
alt={category.title}
70+
className={styles.categoryIcon}
71+
/>
72+
<span className={styles.categoryTitle}>{category.title}</span>
73+
</Link>
74+
))}
75+
</div>
76+
);
77+
}

0 commit comments

Comments
 (0)