v0.2/code-improvements #63

Merged
lamacchinadesiderante merged 3 commits from v0.2/code-improvements into develop 2024-05-11 12:20:56 +00:00
8 changed files with 96 additions and 41 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "proxyraye-next", "name": "proxyraye-next",
"version": "0.1.0", "version": "0.2.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "proxyraye-next", "name": "proxyraye-next",
"version": "0.1.0", "version": "0.2.0",
"dependencies": { "dependencies": {
"@picocss/pico": "^2.0.6", "@picocss/pico": "^2.0.6",
"@reduxjs/toolkit": "^2.2.3", "@reduxjs/toolkit": "^2.2.3",

View File

@ -1,8 +1,11 @@
'use client'
import "@/styles/globals.scss" import "@/styles/globals.scss"
import ReduxProvider from "@/store/redux-provider"; import type { Metadata } from 'next'
export const metadata: Metadata = {
title: 'ProxyRaye',
description: 'Watch porn videos without tracking or annoying ads!',
}
export default function RootLayout({ export default function RootLayout({
children, children,
@ -14,9 +17,7 @@ export default function RootLayout({
return ( return (
<> <>
<ReduxProvider> {children}
{children}
</ReduxProvider>
</> </>
); );
} }

View File

@ -0,0 +1,38 @@
'use client'
import React from 'react';
import Head from 'next/head';
import { AppProgressBar as ProgressBar } from 'next-nprogress-bar';
import { useAppSelector } from '@/store/store';
import { LAYOUT_COLORS_PINK, LAYOUT_COLORS_YELLOW } from '@/constants/colors';
import { Themes } from '@/meta/settings';
const Content: React.FC<React.PropsWithChildren> = (props) => {
const { children } = props;
const theme = useAppSelector((state) => state.settings.theme);
return (
<html data-theme={theme} /*lang={locale}*/>
<Head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<body>
<main className="container">{children}</main>
<ProgressBar
height="4px"
color={theme == Themes.dark ? LAYOUT_COLORS_YELLOW : LAYOUT_COLORS_PINK}
options={{ showSpinner: false }}
shallowRouting
/>
</body>
</html>
);
};
export default Content;

View File

@ -2,17 +2,17 @@
import React from 'react'; import React from 'react';
import { SiGitea } from "react-icons/si"; import { SiCodeberg } from "react-icons/si";
import Icon from '../Icon'; import Icon from '../Icon';
import { REPO_GITEA_URL } from '@/constants/repo'; import { REPO_CODEBERG_URL } from '@/constants/repo';
const Menu: React.FC = () => { const Menu: React.FC = () => {
return ( return (
<Icon handleClick={() => {window.location.href = REPO_GITEA_URL;}}> <Icon handleClick={() => {window.location.href = REPO_CODEBERG_URL;}}>
{<SiGitea size={24} />} {<SiCodeberg size={24} />}
</Icon> </Icon>
); );
}; };

View File

@ -1,38 +1,18 @@
'use client'
import React from 'react'; import React from 'react';
import Head from 'next/head'; import WithRedux from '@/store/withRedux';
import Content from './Content';
import { AppProgressBar as ProgressBar } from 'next-nprogress-bar';
import { useAppSelector } from '@/store/store';
import { LAYOUT_COLORS_PINK, LAYOUT_COLORS_YELLOW } from '@/constants/colors';
import { Themes } from '@/meta/settings';
const Layout: React.FC<React.PropsWithChildren> = (props) => { const Layout: React.FC<React.PropsWithChildren> = (props) => {
const { children } = props; const { children } = props;
const theme = useAppSelector((state) => state.settings.theme);
return ( return (
<html data-theme={theme} /*lang={locale}*/> <WithRedux>
<Head> <Content>
<meta charSet="utf-8" /> {children}
<meta name="viewport" content="width=device-width, initial-scale=1" /> </Content>
<title>Proxy Raye: watch porn videos without tracking or annoying ads!</title> </WithRedux>
</Head>
<body>
<main className="container">{children}</main>
<ProgressBar
height="4px"
color={theme == Themes.dark ? LAYOUT_COLORS_YELLOW : LAYOUT_COLORS_PINK }
options={{ showSpinner: false }}
shallowRouting
/>
</body>
</html>
); );
}; };

View File

@ -1 +1,2 @@
export const REPO_GITEA_URL = 'https://git.lamacchinadesiderante.org/lamacchinadesiderante/proxyraye-nextjs' export const REPO_GITEA_URL = 'https://git.lamacchinadesiderante.org/lamacchinadesiderante/proxyraye-nextjs'
export const REPO_CODEBERG_URL = 'https://codeberg.org/lamacchinadesiderante/proxyraye'

View File

@ -4,7 +4,24 @@ import { useDispatch, TypedUseSelectorHook, useSelector } from "react-redux";
import { settingsReducer } from "@/store/settingsSlice"; import { settingsReducer } from "@/store/settingsSlice";
import { persistReducer } from "redux-persist"; import { persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";
import createWebStorage from "redux-persist/lib/storage/createWebStorage";
const createNoopStorage = () => {
return {
getItem(_key: any) {
return Promise.resolve(null);
},
setItem(_key: any, value: any) {
return Promise.resolve(value);
},
removeItem(_key: any) {
return Promise.resolve();
},
};
};
const storage = typeof window !== "undefined" ? createWebStorage("local") : createNoopStorage();
const settingsPersistConfig = { const settingsPersistConfig = {
key: "settings", key: "settings",

18
src/store/withRedux.tsx Normal file
View File

@ -0,0 +1,18 @@
'use client'
import ReduxProvider from "@/store/redux-provider";
export default function WithRedux({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<>
<ReduxProvider>
{children}
</ReduxProvider>
</>
);
}