Skip to content

Commit

Permalink
deps: start migrating next-ui to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Oct 24, 2024
1 parent 2410440 commit 1cd84c3
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 111 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
# TODO - switch back to 22 https://github.com/actions/setup-node/issues/1112
node-version: 20
node-version: 22
cache: "yarn"

- name: Install Dependencies
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
"@docusaurus/plugin-client-redirects": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
"@mdx-js/react": "^3.1.0",
"@nextui-org/react": "2.4.8",
"@nextui-org/react": "^2.4.8",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
"framer-motion": "^11.11.9",
"fuse.js": "^7.0.0",
"luxon": "^3.5.0",
"next-themes": "^0.3.0",
"postcss": "^8.4.47",
"prism-react-renderer": "^2.4.0",
"react": "^18.3.1",
Expand All @@ -34,6 +36,7 @@
"react-icons": "^5.3.0",
"react-markdown": "^9.0.1",
"recharts": "2.13.0",
"tailwindcss": "^3.4.14",
"yaml": "^2.6.0"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
2 changes: 1 addition & 1 deletion src/components/DownloadTable/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import { Table, Card, Text, Grid } from "@nextui-org/react";
import { Table, Card } from "@nextui-org/react";
import ReactMarkdown from "react-markdown";
import { ReleaseDownloadButton } from "../ReleaseDownloadButton";
import { GoPlus, GoDash } from "react-icons/go";
Expand Down
15 changes: 5 additions & 10 deletions src/components/GoogleAd/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState, useEffect } from "react";
import { Row, Col } from "@nextui-org/react";
import { getCookieConsentValue } from "react-cookie-consent";

export function GoogleAd({ margins = "5em", alignment = "center" }) {
export function GoogleAd() {
const [displayAd, setDisplayAd] = useState(false);

useEffect(() => {
Expand All @@ -16,12 +15,8 @@ export function GoogleAd({ margins = "5em", alignment = "center" }) {
}, [displayAd]);

return !displayAd ? null : (
<Row
justify={alignment}
css={{ mt: margins, mb: margins, width: "auto" }}
gap={2}
>
<Col span={12}>
<div className="flex justify-center mt-5 mb-5 gap-2">
<div className="flex-auto">
<ins
className="adsbygoogle"
style={{
Expand All @@ -34,7 +29,7 @@ export function GoogleAd({ margins = "5em", alignment = "center" }) {
data-ad-format="auto"
data-full-width-responsive="true"
></ins>
</Col>
</Row>
</div>
</div>
);
}
4 changes: 4 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

/**
* Any CSS included here will be global. The classic template
* bundles Infima by default. Infima is a CSS framework designed to
Expand Down
1 change: 0 additions & 1 deletion src/mdx/BarChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from "react";
import { Row, Col } from "@nextui-org/react";
import {
BarChart,
Bar,
Expand Down
1 change: 0 additions & 1 deletion src/mdx/Image.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { Grid } from "@nextui-org/react";

export default function Image({ children, cols, src, alt }) {
return (
Expand Down
1 change: 0 additions & 1 deletion src/mdx/ImageCompare.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { Grid } from "@nextui-org/react";

export default function ImageCompare({
children,
Expand Down
2 changes: 1 addition & 1 deletion src/mdx/PRLink/PCSX2PRLink.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { GoGitCommit, GoGitPullRequest } from "react-icons/go";
import { Avatar, Grid, Tooltip } from "@nextui-org/react";
import { Avatar, Tooltip } from "@nextui-org/react";
import { IconContext } from "react-icons";
import styles from "./PCSX2PRLink.module.css";

Expand Down
1 change: 0 additions & 1 deletion src/mdx/SliderCompare/SliderCompare.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useRef } from "react";
import { Grid } from "@nextui-org/react";
import styles from "./SliderCompare.module.css";

export default function SliderCompare({ children, cols, before, after }) {
Expand Down
5 changes: 0 additions & 5 deletions src/pages/compat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ import React, { useState, useEffect } from "react";
import Layout from "@theme/Layout";
import {
Table,
Grid,
Tooltip,
Badge,
Link,
Loading,
Input,
Container,
Row,
Col,
Button,
} from "@nextui-org/react";
import { MdLibraryBooks, MdForum } from "react-icons/md";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/downloads/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import Layout from "@theme/Layout";
import { Container, Text, Grid, Switch } from "@nextui-org/react";
import { Switch } from "@nextui-org/react";
import Admonition from "@theme/Admonition";
import { ReleaseDownloadButton } from "../../components/ReleaseDownloadButton";
import { DownloadTable } from "../../components/DownloadTable";
Expand Down
69 changes: 32 additions & 37 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,47 @@ import React, { useState, useEffect } from "react";
import Link from "@docusaurus/Link";
import Layout from "@theme/Layout";
import {
Text,
Button,
Row,
Col,
Card,
Grid,
Container,
Tooltip,
getDocumentTheme,
Tooltip
} from "@nextui-org/react";
import {useTheme} from "next-themes";
import { NumberTicker } from "../components/NumberTicker";
import { getLatestRelease } from "../components/ReleaseDownloadButton";
import { ReleaseDownloadButton } from "../components/ReleaseDownloadButton";
import { GoogleAd } from "../components/GoogleAd";
import { useMediaQuery } from "../utils/mediaQuery";
import { styled } from "@nextui-org/react";
import useBaseUrl from "@docusaurus/useBaseUrl";

const StyledTitle = styled("h1", {
display: "inline",
fontWeight: "$bold",
color: "$text",
lh: "1.2",
fs: "2.5rem",
"@sm": {
fs: "3rem",
},
"@lg": {
fs: "3.5rem",
},
});
// const StyledTitle = styled("h1", {
// display: "inline",
// fontWeight: "$bold",
// color: "$text",
// lh: "1.2",
// fs: "2.5rem",
// "@sm": {
// fs: "3rem",
// },
// "@lg": {
// fs: "3.5rem",
// },
// });

const StyledGradientTitle = styled(StyledTitle, {
textGradient: "180deg, #5099ff 25%, #465eae 100%",
"&::selection": {
WebkitTextFillColor: "$colors$text",
},
});
// const StyledGradientTitle = styled(StyledTitle, {
// textGradient: "180deg, #5099ff 25%, #465eae 100%",
// "&::selection": {
// WebkitTextFillColor: "$colors$text",
// },
// });

const StyledSubtitle = styled("p", {
pl: "$1",
fs: "$xl",
width: "100%",
display: "inline-flex",
fontWeight: "500",
color: "$accents9",
});
// const StyledSubtitle = styled("p", {
// pl: "$1",
// fs: "$xl",
// width: "100%",
// display: "inline-flex",
// fontWeight: "500",
// color: "$accents9",
// });

import CompatData from "@site/static/data/compat/data.min.json";

Expand Down Expand Up @@ -80,6 +74,7 @@ import {
const baseApiUrl = "https://api.pcsx2.net/v1";

export default function Home() {
const { theme, setTheme } = useTheme();
const [latestStableRelease, setLatestStableRelease] = useState({});
const [latestNightlyRelease, setLatestNightlyRelease] = useState({});
const [apiErrorMsg, setApiErrorMsg] = useState(undefined);
Expand Down Expand Up @@ -113,14 +108,14 @@ export default function Home() {
useEffect(() => {
fetchLatestReleases();
setHomeVideoPath(
getDocumentTheme(document?.documentElement) === "dark"
theme === "dark"
? "/videos/splash.webm"
: "/videos/splash-light.mp4",
);

const observer = new MutationObserver((mutation) => {
setHomeVideoPath(
getDocumentTheme(document?.documentElement) === "dark"
theme === "dark"
? "/videos/splash.webm"
: "/videos/splash-light.mp4",
);
Expand Down
2 changes: 1 addition & 1 deletion src/theme/BlogPostItem/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import BlogPostItemHeaderTitle from "@theme-original/BlogPostItem/Header/Title";
import BlogPostItemHeaderInfo from "@theme-original/BlogPostItem/Header/Info";
import BlogPostItemHeaderAuthors from "@theme-original/BlogPostItem/Header/Authors";
import { useBlogPost } from "@docusaurus/theme-common/internal";
import { useBlogPost } from '@docusaurus/plugin-content-blog/client';
import useBaseUrl from "@docusaurus/useBaseUrl";

export default function BlogPostItemHeader() {
Expand Down
58 changes: 22 additions & 36 deletions src/theme/Root.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import React, { useEffect, useState } from "react";
import {
createTheme,
NextUIProvider,
getDocumentTheme,
} from "@nextui-org/react";
import {ThemeProvider as NextThemesProvider} from "next-themes";
import {useTheme} from "next-themes";
import CookieConsent, { getCookieConsentValue } from "react-cookie-consent";

const lightTheme = createTheme({
type: "light",
theme: {
// colors: {...}, // optional
},
});

const darkTheme = createTheme({
type: "dark",
theme: {
// colors: {...}, // optional
},
});

function loadGoogleAds() {
if (
getCookieConsentValue("pcsx2CookieConsent") === "true" &&
Expand All @@ -37,6 +23,7 @@ function loadGoogleAds() {

// Default implementation, that you can customize
export default function Root({ children }) {
const { theme, setTheme } = useTheme();
const [isDark, setIsDark] = useState(false);

useEffect(() => {
Expand All @@ -47,7 +34,7 @@ export default function Root({ children }) {
setIsDark(theme === "dark");

const observer = new MutationObserver((mutation) => {
let newTheme = getDocumentTheme(document?.documentElement);
let newTheme = theme;
if (newTheme === "dark") {
if (!document?.documentElement.classList.contains("dark-theme")) {
document?.documentElement.classList.add("dark-theme");
Expand All @@ -74,25 +61,24 @@ export default function Root({ children }) {
}, []);

return (
<NextUIProvider
theme={isDark ? darkTheme : lightTheme}
disableBaseline={true}
>
<CookieConsent
location="bottom"
buttonText="Agree"
declineButtonText="Decline"
cookieName="pcsx2CookieConsent"
enableDeclineButton={true}
style={{ background: "#2B373B" }}
expires={150}
onAccept={() => {
loadGoogleAds();
}}
>
This website uses cookies to enhance the user experience.
</CookieConsent>
{children}
<NextUIProvider disableBaseline={true}>
<NextThemesProvider attribute="class" defaultTheme="dark">
<CookieConsent
location="bottom"
buttonText="Agree"
declineButtonText="Decline"
cookieName="pcsx2CookieConsent"
enableDeclineButton={true}
style={{ background: "#2B373B" }}
expires={150}
onAccept={() => {
loadGoogleAds();
}}
>
This website uses cookies to enhance the user experience.
</CookieConsent>
{children}
</NextThemesProvider>
</NextUIProvider>
);
}
17 changes: 17 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",

// Or if using `src` directory:
"./src/**/*.{js,ts,jsx,tsx,mdx}",
// next-ui
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}"
],
theme: {
extend: {},
},
plugins: [],
}
Loading

0 comments on commit 1cd84c3

Please sign in to comment.