Skip to content

Commit

Permalink
Merge pull request #76 from asnakep/main
Browse files Browse the repository at this point in the history
Reduced Local Fonts + Added Eslint ignore rules
  • Loading branch information
tuckpuck authored Dec 8, 2024
2 parents 435d10a + eb62682 commit 755bab3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 42 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
"extends": [
"next/core-web-vitals",
"next/typescript"
]
],
"rules": {
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-this-alias": "off",
"react-hooks/rules-of-hooks": "off"
}
}
4 changes: 1 addition & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ module.exports = withNextra({
GITHUB_ACCESS_TOKEN: process.env.GITHUB_ACCESS_TOKEN,
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
ignoreDuringBuilds: false,
},
async redirects() {
return [
Expand Down
61 changes: 23 additions & 38 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import "../css/styles.css";
import { useEffect, useState } from "react";
import { StyleProvider } from "@ant-design/cssinjs";
import { ConfigProvider, theme } from "antd";
import { useEffect, useState } from "react";
import localFont from "next/font/local";

const campton = localFont({
src: [
{ path: "../assets/fonts/0_campton_thin.otf", weight: "100" },
{ path: "../assets/fonts/1_campton_extra_light.otf", weight: "200" },
{ path: "../assets/fonts/2_campton_light.otf", weight: "300" },
{ path: "../assets/fonts/3_campton_normal.otf", weight: "400" },
{ path: "../assets/fonts/4_campton_medium.otf", weight: "500" },
{ path: "../assets/fonts/5_campton_semi_bold.otf", weight: "600" },
{ path: "../assets/fonts/6_campton_bold.otf", weight: "700" },
{ path: "../assets/fonts/7_campton_extra_bold.otf", weight: "800" },
{ path: "../assets/fonts/8_campton_black.otf", weight: "900" },
],
src: [{ path: "../assets/fonts/3_campton_normal.otf", weight: "400" }], // Loading only the regular font for optimization
variable: "--font-campton",
fallback: [
"Segoe UI",
Expand Down Expand Up @@ -45,11 +35,10 @@ const ThemeWrapper = ({ children }) => {
setMounted(true);

const handleThemeChange = () => {
const isDarkMode = document.documentElement.classList.contains("dark");
setIsDark(isDarkMode);
setIsDark(document.documentElement.classList.contains("dark"));
};

handleThemeChange();
handleThemeChange(); // Initial check

const observer = new MutationObserver(handleThemeChange);
observer.observe(document.documentElement, {
Expand All @@ -60,27 +49,27 @@ const ThemeWrapper = ({ children }) => {
return () => observer.disconnect();
}, []);

if (!mounted) return null;
if (!mounted) return null; // Prevent hydration errors

const themeConfig = {
algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
cssVar: true,
token: {
colorPrimary: "#3964f6",
colorBgContainer: isDark ? "#141414" : "#ffffff",
colorBgSpotlight: isDark ? "#141414" : "#ffffff",
colorTextLightSolid: isDark ? "#ffffff" : "#000000",
},
components: {
Table: {
colorBgContainer: isDark ? "#0e121e" : "#f7f7f7",
},
},
};

return (
<StyleProvider hashPriority="high">
<ConfigProvider
theme={{
algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
cssVar: true,
token: {
colorPrimary: "#3964f6",
colorBgContainer: isDark ? "#141414" : "#ffffff",
colorBgSpotlight: isDark ? "#141414" : "#ffffff",
colorTextLightSolid: isDark ? "#ffffff" : "#000000",
},
components: {
Table: {
colorBgContainer: isDark ? "#0e121e" : "#f7f7f7",
},
},
}}
>
<ConfigProvider theme={themeConfig}>
<div className={campton.variable}>{children}</div>
</ConfigProvider>
</StyleProvider>
Expand All @@ -94,11 +83,7 @@ const LoadingWrapper = ({ children }) => {
setIsClient(true);
}, []);

if (!isClient) {
return <div style={{ visibility: "hidden" }}>{children}</div>;
}

return children;
return isClient ? children : <div style={{ visibility: "hidden" }}>{children}</div>;
};

export default function MyApp({ Component, pageProps }) {
Expand Down

1 comment on commit 755bab3

@vercel
Copy link

@vercel vercel bot commented on 755bab3 Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.