Skip to content

Commit 46ea62c

Browse files
feat: icbd page skeleton (#90)
Co-authored-by: Ludovic Mermod <ludovic.mermod@epfl.ch>
1 parent a62f6ef commit 46ea62c

16 files changed

+1428
-1464
lines changed

package-lock.json

+796-1,456
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"dependencies": {
1717
"@directus/sdk": "^18.0.0",
1818
"@svgr/webpack": "^8.1.0",
19+
"@tsparticles/engine": "^3.7.1",
20+
"@tsparticles/react": "^3.0.0",
21+
"@tsparticles/slim": "^3.7.1",
1922
"next": "^14.2.10",
2023
"react": "18.2.0",
2124
"react-dom": "18.2.0",
@@ -26,15 +29,15 @@
2629
"@commitlint/cli": "^17.4.4",
2730
"@commitlint/config-conventional": "^17.4.4",
2831
"@trivago/prettier-plugin-sort-imports": "^4.1.0",
29-
"husky": "^8.0.0",
30-
"prettier": "2.8.4",
3132
"@types/node": "20.4.5",
3233
"@types/react": "18.2.18",
3334
"@types/react-dom": "18.2.7",
3435
"autoprefixer": "10.4.14",
3536
"eslint": "8.46.0",
3637
"eslint-config-next": "13.4.12",
38+
"husky": "^8.0.0",
3739
"postcss": "8.4.31",
40+
"prettier": "2.8.4",
3841
"sass": "^1.69.5",
3942
"tailwindcss": "3.3.3",
4043
"typescript": "5.1.6"

src/components/Card.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export default function Card(
3131
case "/subsonic":
3232
className = styles.subsonic;
3333
break;
34+
case "/icbd":
35+
className = styles.icbd;
36+
break;
3437
default:
3538
className = styles.card;
3639
break;

src/components/IcbdActivityCard.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import DirectusImage from "./DirectusImage";
2+
import { getTranslation, locale } from "@/locales";
3+
import styles from "@/styles/IcbdActivityCard.module.scss";
4+
import { ICBDActivity } from "@/types/aliases";
5+
import { useRouter } from "next/router";
6+
import Markdown from "react-markdown";
7+
8+
export default function IcbdActivityCard(props: { activity: ICBDActivity }) {
9+
const router = useRouter();
10+
11+
const translation = getTranslation(props.activity, locale(router));
12+
return (
13+
<div className={styles.content}>
14+
<div className={styles.title}>
15+
<DirectusImage
16+
sizes="5rem"
17+
img={props.activity.icon}
18+
name={translation.name || ""}
19+
className={styles.picture}
20+
/>
21+
<h2>{translation.name}</h2>
22+
</div>
23+
<Markdown className={styles.description}>
24+
{translation.description}
25+
</Markdown>
26+
</div>
27+
);
28+
}

src/components/NavigationBar.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ export default function NavigationBar(props: {
177177
case "/subsonic":
178178
className = styles.subsonic;
179179
break;
180+
case "/icbd":
181+
className = styles.icbd;
182+
break;
180183
default:
181184
className = styles.navigationBar;
182185
break;

src/components/Particles.tsx

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { ISourceOptions } from "@tsparticles/engine";
2+
import Particles, { initParticlesEngine } from "@tsparticles/react";
3+
import { loadSlim } from "@tsparticles/slim";
4+
import { useEffect, useMemo, useState } from "react";
5+
6+
export default function ParticlesComponent(props: { id: string }) {
7+
const [init, setInit] = useState(false);
8+
useEffect(() => {
9+
initParticlesEngine(async (engine) => {
10+
await loadSlim(engine);
11+
}).then(() => {
12+
setInit(true);
13+
});
14+
}, []);
15+
16+
const options: ISourceOptions = useMemo(
17+
() => ({
18+
background: {
19+
color: {
20+
value: "#ffffff",
21+
},
22+
},
23+
fullScreen: {
24+
zIndex: -1,
25+
enable: true, // this is the line to change
26+
},
27+
fpsLimit: 120,
28+
interactivity: {
29+
events: {
30+
onClick: {
31+
enable: true,
32+
mode: "repulse",
33+
},
34+
onHover: {
35+
enable: true,
36+
mode: "grab",
37+
},
38+
},
39+
modes: {
40+
push: {
41+
distance: 200,
42+
duration: 15,
43+
},
44+
grab: {
45+
distance: 150,
46+
},
47+
},
48+
},
49+
particles: {
50+
color: {
51+
value: "#FE9F21",
52+
},
53+
links: {
54+
color: "#FE9F21",
55+
distance: 150,
56+
enable: true,
57+
opacity: 0.3,
58+
width: 1,
59+
},
60+
move: {
61+
direction: "none",
62+
enable: true,
63+
outModes: {
64+
default: "bounce",
65+
},
66+
random: true,
67+
speed: 3,
68+
straight: false,
69+
},
70+
number: {
71+
density: {
72+
enable: true,
73+
},
74+
value: 200,
75+
},
76+
opacity: {
77+
value: 7.0,
78+
},
79+
shape: {
80+
type: "circle",
81+
},
82+
size: {
83+
value: { min: 1, max: 4 },
84+
},
85+
},
86+
detectRetina: true,
87+
}),
88+
[]
89+
);
90+
91+
if (init) {
92+
return <Particles id={props.id} options={options} />;
93+
}
94+
95+
return <></>;
96+
}

src/directus.ts

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export function cleanTranslations<T extends { [key: string]: any }>(
157157
export function getDirectusImageUrl(
158158
image: string | components["schemas"]["Files"] | null | undefined
159159
): string | undefined {
160-
console.log(JSON.stringify(image, null, 2));
161160
return image
162161
? `${PUBLIC_DIRECTUS_URL}/assets/${
163162
typeof image === "string" ? image : image.filename_disk

0 commit comments

Comments
 (0)