Skip to content

Commit 847e007

Browse files
fix: simplify footer and particles init
1 parent ca27f64 commit 847e007

3 files changed

Lines changed: 52 additions & 277 deletions

File tree

src/components/particle.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
import * as React from "react";
2-
import Particles, { initParticlesEngine } from "@tsparticles/react";
3-
import { useEffect, useMemo, useState } from "react";
2+
import * as ParticlesReact from "@tsparticles/react";
3+
import { useCallback, useEffect, useMemo, useState } from "react";
44
import { loadSlim } from "@tsparticles/slim";
55
import BrowserOnly from "@docusaurus/BrowserOnly";
66

77
const ParticlesInner = (props) => {
88
const [init, setInit] = useState(false);
9+
const Particles = (ParticlesReact.default ??
10+
ParticlesReact.Particles) as React.ComponentType<Record<string, unknown>>;
11+
12+
const particlesInit = useCallback(async (engine) => {
13+
await loadSlim(engine);
14+
}, []);
915

1016
useEffect(() => {
11-
initParticlesEngine(async (engine) => {
12-
await loadSlim(engine);
13-
}).then(() => {
17+
const initParticlesEngine = ParticlesReact.initParticlesEngine;
18+
19+
if (typeof initParticlesEngine !== "function") {
20+
setInit(true);
21+
return;
22+
}
23+
24+
initParticlesEngine(particlesInit).then(() => {
1425
setInit(true);
1526
});
16-
}, []);
27+
}, [particlesInit]);
1728

1829
const options = useMemo(
1930
() => ({
@@ -108,7 +119,7 @@ const ParticlesInner = (props) => {
108119
pointerEvents: "none",
109120
}}
110121
>
111-
<Particles id={props.id} options={options} />
122+
<Particles id={props.id} init={particlesInit} options={options} />
112123
</div>
113124
);
114125
};

src/theme/Footer/Layout/enhanced-footer.css

Lines changed: 20 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123

124124
.footer-main {
125125
display: grid;
126-
grid-template-columns: 0.95fr 0.95fr 0.9fr 0.9fr 1.35fr;
127-
column-gap: 28px;
126+
grid-template-columns: repeat(4, minmax(0, 1fr));
127+
column-gap: 56px;
128128
row-gap: 40px;
129129
padding: 70px 56px 54px;
130130
min-height: 410px;
@@ -210,126 +210,6 @@
210210
border-color: rgba(0, 212, 164, 0.25);
211211
}
212212

213-
.newsletter-description {
214-
margin: -4px 0 18px;
215-
color: var(--footer-steel);
216-
font-size: 15px;
217-
line-height: 1.5;
218-
}
219-
220-
.newsletter-form {
221-
display: grid;
222-
grid-template-columns: minmax(0, 1fr) auto;
223-
gap: 8px;
224-
}
225-
226-
.newsletter-input {
227-
width: 100%;
228-
min-width: 0;
229-
height: 40px;
230-
padding: 0 13px;
231-
border: 1px solid var(--footer-hairline);
232-
border-radius: 8px;
233-
background: var(--footer-canvas);
234-
color: var(--footer-ink);
235-
font: inherit;
236-
font-size: 14px;
237-
outline: none;
238-
}
239-
240-
.newsletter-input:focus {
241-
border-color: var(--footer-green);
242-
box-shadow: 0 0 0 3px rgba(0, 212, 164, 0.12);
243-
}
244-
245-
.newsletter-input.input-error {
246-
border-color: var(--footer-error);
247-
}
248-
249-
.newsletter-button {
250-
height: 40px;
251-
padding: 0 16px;
252-
border: 0;
253-
border-radius: 999px;
254-
background: var(--footer-ink);
255-
color: var(--footer-canvas);
256-
font-size: 14px;
257-
font-weight: 600;
258-
cursor: pointer;
259-
white-space: nowrap;
260-
}
261-
262-
.newsletter-button:hover {
263-
background: var(--footer-steel);
264-
}
265-
266-
.newsletter-button.subscribed,
267-
.newsletter-button:disabled {
268-
background: var(--footer-green);
269-
color: #0a0a0a;
270-
cursor: default;
271-
}
272-
273-
.error-text {
274-
grid-column: 1 / -1;
275-
margin: 0;
276-
color: var(--footer-error);
277-
font-size: 13px;
278-
}
279-
280-
.newsletter-stats {
281-
margin-top: 12px;
282-
}
283-
284-
.newsletter-stat {
285-
display: inline-flex;
286-
align-items: center;
287-
gap: 7px;
288-
color: var(--footer-steel);
289-
font-size: 13px;
290-
line-height: 1.4;
291-
}
292-
293-
.quick-links-section {
294-
margin-top: 26px;
295-
}
296-
297-
.quick-links-title {
298-
display: flex;
299-
align-items: center;
300-
gap: 7px;
301-
margin: 0 0 10px;
302-
color: var(--footer-stone);
303-
font-size: 13px;
304-
font-weight: 600;
305-
letter-spacing: 0.06em;
306-
text-transform: uppercase;
307-
}
308-
309-
.quick-links-list {
310-
display: flex;
311-
flex-wrap: wrap;
312-
gap: 8px;
313-
}
314-
315-
.quick-link {
316-
display: inline-flex;
317-
align-items: center;
318-
gap: 7px;
319-
min-height: 34px;
320-
padding: 7px 11px;
321-
border: 1px solid var(--footer-hairline);
322-
border-radius: 999px;
323-
background: var(--footer-surface-soft);
324-
color: var(--footer-charcoal);
325-
font-size: 13px;
326-
font-weight: 500;
327-
}
328-
329-
.quick-link:hover {
330-
border-color: var(--footer-hairline);
331-
}
332-
333213
.footer-stats {
334214
display: grid;
335215
grid-template-columns: repeat(4, minmax(0, 1fr));
@@ -391,20 +271,12 @@
391271
}
392272

393273
.footer-bottom {
394-
min-height: 94px;
274+
min-height: 72px;
395275
display: grid;
396-
grid-template-columns: minmax(180px, 1fr) auto minmax(120px, 1fr);
397-
align-items: center;
398-
gap: 24px;
399-
padding: 18px 40px;
400-
}
401-
402-
.footer-bottom-center {
403-
display: flex;
404-
flex-direction: column;
276+
grid-template-columns: minmax(0, 1fr) auto;
405277
align-items: center;
406-
gap: 10px;
407-
min-width: 0;
278+
gap: 20px;
279+
padding: 14px 40px;
408280
}
409281

410282
.legal-link {
@@ -415,9 +287,9 @@
415287

416288
.footer-copyright {
417289
color: var(--footer-steel);
418-
font-size: 16px;
290+
font-size: 13px;
419291
line-height: 1.4;
420-
text-align: center;
292+
text-align: left;
421293
}
422294

423295
.footer-copyright a {
@@ -428,8 +300,8 @@
428300
}
429301

430302
.footer-heart-icon {
431-
width: 16px;
432-
height: 16px;
303+
width: 13px;
304+
height: 13px;
433305
display: inline-block;
434306
vertical-align: -2px;
435307
color: #e5484d;
@@ -441,31 +313,31 @@
441313
display: inline-flex;
442314
align-items: center;
443315
justify-content: center;
444-
min-height: 38px;
316+
min-height: 32px;
445317
padding: 0;
446318
border-radius: 999px;
447319
background: transparent;
448320
}
449321

450322
.footer-theme-switcher {
451-
--theme-option-width: 40px;
323+
--theme-option-width: 32px;
452324
position: relative;
453325
display: grid;
454326
grid-template-columns: repeat(3, var(--theme-option-width));
455327
align-items: center;
456-
min-height: 38px;
457-
padding: 3px;
328+
min-height: 32px;
329+
padding: 2px;
458330
border-radius: 999px;
459331
background: var(--footer-surface);
460332
}
461333

462334
.footer-theme-switcher::before {
463335
content: "";
464336
position: absolute;
465-
top: 3px;
466-
left: 3px;
337+
top: 2px;
338+
left: 2px;
467339
width: var(--theme-option-width);
468-
height: calc(100% - 6px);
340+
height: calc(100% - 4px);
469341
border-radius: 999px;
470342
background: var(--footer-canvas);
471343
border: 1px solid var(--footer-hairline);
@@ -484,7 +356,7 @@
484356
.footer-theme-option {
485357
position: relative;
486358
z-index: 1;
487-
height: 32px;
359+
height: 28px;
488360
padding: 0;
489361
display: inline-flex;
490362
align-items: center;
@@ -499,8 +371,8 @@
499371
}
500372

501373
.footer-theme-option svg {
502-
width: 15px;
503-
height: 15px;
374+
width: 13px;
375+
height: 13px;
504376
display: block;
505377
}
506378

0 commit comments

Comments
 (0)