Skip to content

Commit d6c7d0f

Browse files
authoredSep 8, 2024
Misc updates (solana-foundation#30)
* Misc updates * Update comment
1 parent e7bc4f0 commit d6c7d0f

File tree

13 files changed

+414
-121
lines changed

13 files changed

+414
-121
lines changed
 

‎.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# YouTube keys for getting videos & info from channel
1+
# YouTube
22
YOUTUBE_CHANNEL_ID=
33
YOUTUBE_API_KEY=
44
# Simplecast

‎.github/workflows/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: installing_yarn
2121
run: yarn install
2222
- name: formatting
23-
run: yarn format
23+
run: yarn format:check
2424
stage:
2525
name: Test linting...
2626
needs: Format
@@ -37,4 +37,4 @@ jobs:
3737
- name: installing_yarn & lint
3838
run: |
3939
yarn install
40-
yarn run lint
40+
yarn lint

‎.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
yarn format
1+
yarn format:check
22
yarn lint

‎package.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "solana-com",
3-
"private": true,
43
"description": "The solana.com website",
54
"version": "3.0.0",
65
"author": "Solana Maintainers",
@@ -70,27 +69,21 @@
7069
"eslint-plugin-react-hooks": "^4.6.2",
7170
"husky": "^9.0.11",
7271
"next-sitemap": "^4.2.3",
73-
"next-transpile-modules": "^10.0.1",
7472
"postcss": "^8.4.38",
7573
"postcss-preset-env": "^9.5.14",
7674
"prettier": "^3.2.5",
7775
"svg-react-loader": "^0.4.6",
7876
"typescript": "^5.4.5"
7977
},
8078
"scripts": {
81-
"build": "echo 'Building solana-com...' && next build",
79+
"build": "next build",
8280
"dev": "next",
83-
"develop": "yarn dev",
8481
"start": "next start",
85-
"format": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md,scss}\"",
86-
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,scss}\"",
82+
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md,scss}\"",
83+
"format:all": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,scss}\"",
8784
"lint": "next lint",
88-
"lint:fix": "yarn lint --fix",
89-
"vdev": "vercel dev --debug",
85+
"lint:fix": "next lint --fix",
9086
"postbuild": "next-sitemap",
9187
"prepare": "husky"
92-
},
93-
"msw": {
94-
"workerDirectory": "public"
9588
}
9689
}

‎src/components/ModalLauncher/ModalLauncher.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { useEffect, useState, useRef, createElement } from "react";
1+
import {
2+
useEffect,
3+
useState,
4+
useRef,
5+
createElement,
6+
useCallback,
7+
useMemo,
8+
} from "react";
29
import { useRouter } from "next/router";
310
import { Modal, CloseButton } from "react-bootstrap";
411
import ArtistsAndCreatorsNewsletter from "../newsletter/artistsAndCreators";
@@ -10,11 +17,14 @@ const ModalLauncher = () => {
1017
const [modalLaunchId, setModalLaunchId] = useState("default");
1118
const modalActionCompleted = useRef(false);
1219

13-
const modalMapping = {
14-
artistAndCreatorsNewsletter: ArtistsAndCreatorsNewsletter,
15-
};
20+
const modalMapping = useMemo(
21+
() => ({
22+
artistAndCreatorsNewsletter: ArtistsAndCreatorsNewsletter,
23+
}),
24+
[],
25+
);
1626

17-
const modalCloseHandler = () => {
27+
const modalCloseHandler = useCallback(() => {
1828
// if the modal action is not complete, track bounce
1929
if (!modalActionCompleted.current && typeof window.gtag !== "undefined") {
2030
window.gtag("event", "modal_bounce", {
@@ -37,7 +47,7 @@ const ModalLauncher = () => {
3747
undefined,
3848
{ shallow: true },
3949
);
40-
};
50+
}, [modalLaunchId, router]);
4151

4252
useEffect(() => {
4353
const { modalLaunch, modalLaunchId } = router.query;
@@ -68,7 +78,7 @@ const ModalLauncher = () => {
6878
setShowModal(false);
6979
setModalComponent(null);
7080
}
71-
}, [router.query]);
81+
}, [router.query, modalCloseHandler, modalMapping]);
7282

7383
return (
7484
<Modal

‎src/components/blog/PostCard.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ const PostCard = ({ post, index, isFirstPage, variant = "primary" }) => {
170170
height={1073}
171171
/>
172172
</Link>
173-
<h2 className="post-card-title secondary">{post?.data?.title}</h2>
173+
<h2 className="post-card-title secondary">
174+
{typeof post?.data?.title === "string"
175+
? post.data.title
176+
: post?.data?.title?.Default}
177+
</h2>
174178
</div>
175179
<Link to={url} className="post-card-button">
176180
{t("blog.read-article")}
@@ -198,7 +202,11 @@ const PostCard = ({ post, index, isFirstPage, variant = "primary" }) => {
198202
<small className="d-block post-card-date">
199203
<PublishedAt publishedDateString={publishedDate} />
200204
</small>
201-
<h2 className="post-card-title">{post?.data?.title}</h2>
205+
<h2 className="post-card-title">
206+
{typeof post?.data?.title === "string"
207+
? post.data.title
208+
: post?.data?.title?.Default}
209+
</h2>
202210
<p className="post-card-excerpt">{excerpt}</p>
203211
</div>
204212
</div>
@@ -232,7 +240,11 @@ const PostCard = ({ post, index, isFirstPage, variant = "primary" }) => {
232240
<span className="d-block post-card-date">
233241
<PublishedAt publishedDateString={publishedDate} />
234242
</span>
235-
<h2 className="post-card-title">{post?.data?.title}</h2>
243+
<h2 className="post-card-title">
244+
{typeof post?.data?.title === "string"
245+
? post.data.title
246+
: post?.data?.title?.Default}
247+
</h2>
236248
<p className="post-card-excerpt">{excerpt}</p>
237249
</div>
238250
) : (

‎src/components/news/CategorySelection.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useState, useEffect } from "react";
1+
import { useRef, useState, useEffect, useCallback } from "react";
22
import styles from "./CategorySelection.module.scss";
33
import classNames from "classnames";
44
import { SwitcherButtons } from "@solana-foundation/solana-lib";
@@ -29,7 +29,7 @@ const CategorySelection = ({
2929
return arr.length; // Return -1 if the sum never exceeds maxNumber
3030
};
3131

32-
const updateDisplayedItems = () => {
32+
const updateDisplayedItems = useCallback(() => {
3333
const containerWidth = categoryContainer.current.offsetWidth;
3434
const dropdownWidth = moreCategoriesLabel?.length * 10 + 70; // 70 = padding + ~margin
3535
maxDisplayItems.current = findExceedingIndex(
@@ -45,7 +45,7 @@ const CategorySelection = ({
4545
setDisplayCategories(categories);
4646
setMoreCategories([]);
4747
}
48-
};
48+
}, [buttonWidths, moreCategoriesLabel, categories]); // Added 'categories' to dependencies
4949

5050
// estimate the widths of the category buttons on initial render
5151
// note: can't rely on actual widths because some buttons are stored in the dropdown and are not accessible
@@ -66,7 +66,7 @@ const CategorySelection = ({
6666
return () => {
6767
window.removeEventListener("resize", updateDisplayedItems);
6868
};
69-
}, [buttonWidths]);
69+
}, [buttonWidths, updateDisplayedItems]);
7070

7171
return (
7272
<>

‎src/components/possible/PossibleAnimatedIcons.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ const PossibleAnimatedIcons = ({
2121
},
2222
);
2323

24-
if (videoRef.current) {
25-
observer.observe(videoRef.current);
24+
const currentVideoRef = videoRef.current; // Store the current ref
25+
26+
if (currentVideoRef) {
27+
observer.observe(currentVideoRef);
2628
}
2729

2830
return () => {
29-
if (videoRef.current) {
30-
observer.unobserve(videoRef.current);
31+
if (currentVideoRef) {
32+
observer.unobserve(currentVideoRef);
3133
}
3234
};
33-
}, [videoSrc]);
35+
}, []);
3436

3537
const handleVideoError = () => {
3638
setShowFallback(true);

‎src/components/shared/Divider.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import styled from "styled-components";
33
const StyledDivider = styled.div`
44
height: ${(props) => props.height || "auto"};
55
${(props) =>
6-
props.axis === "x"
6+
props.$axis === "x"
77
? "border-top"
8-
: props.axis === "y"
8+
: props.$axis === "y"
99
? "border-right"
1010
: "border"}: 1px solid
1111
rgba(
1212
${(props) =>
13-
props.theme === "light"
13+
props.$theme === "light"
1414
? "255, 255, 255"
15-
: props.theme === "dark"
15+
: props.$theme === "dark"
1616
? "0, 0, 0"
17-
: "100,100,100"},
18-
${(props) => props.alpha || 0.4}
17+
: "100, 100, 100"},
18+
${(props) => props.$alpha || 0.4}
1919
);
2020
`;
2121

@@ -32,9 +32,9 @@ const StyledDivider = styled.div`
3232
const Divider = ({ theme, alpha, axis, height, className }) => (
3333
<StyledDivider
3434
role="separator"
35-
theme={theme}
36-
alpha={alpha}
37-
axis={axis}
35+
$theme={theme}
36+
$alpha={alpha}
37+
$axis={axis}
3838
height={height}
3939
className={className}
4040
/>

‎src/components/shared/Link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const Link = ({
2525
asPath.includes(to) &&
2626
!partiallyActiveIgnore.filter((el) => asPath.startsWith(el)).length)
2727
);
28-
}, [partiallyActive, asPath, to]);
28+
}, [partiallyActive, asPath, to, partiallyActiveIgnore]); // Added partiallyActiveIgnore to dependencies
2929

3030
if (internal) {
3131
const { scroll, prefetch, ...aProps } = other;

0 commit comments

Comments
 (0)
Please sign in to comment.