Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next-themes #1004

Merged
merged 47 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e94978d
next-themes wip
sspenst Sep 28, 2023
8270e75
signup toast and game.tsx change
k2xl Sep 28, 2023
c6bb1ae
nuke newrelic frontend because possible memory issue on windows
k2xl Sep 28, 2023
3f5de11
update git ignore, add public/sounds/music
k2xl Sep 29, 2023
b4d7366
/campaign perf. From ~1.1s load to about 200ms
k2xl Sep 29, 2023
4632436
fix test
k2xl Sep 29, 2023
1601236
cleanup
sspenst Sep 29, 2023
ce7dab2
reset leastMoves on unpublish
sspenst Sep 29, 2023
6b33ac9
post level modal and tooltips (#1000)
k2xl Sep 29, 2023
3ddfa10
ch4 preview (#1006)
sspenst Sep 30, 2023
5019497
collection-by-id aggregate (#1003)
sspenst Sep 30, 2023
eb583d5
postgamemodal improvements
sspenst Sep 30, 2023
bfd02e0
more intuitive campaign button
sspenst Sep 30, 2023
4f8b73e
login link for some tips
sspenst Sep 30, 2023
c044c5a
[Snyk] Upgrade pureimage from 0.3.17 to 0.4.7 (#977)
k2xl Sep 30, 2023
9af24cb
add reviews and 'dont show this popup for 24h' checkbox
k2xl Sep 30, 2023
bb853fa
getRecommendedLevel dont show a level they have played recently
k2xl Sep 30, 2023
a81c56c
get rid of datetime filter
k2xl Oct 1, 2023
3521b12
Tweak. Remove unnecessary colon
k2xl Oct 1, 2023
cb4ee6f
complete/incomplete filter button for chapters
k2xl Oct 1, 2023
8af95e8
indicators for marking ready
k2xl Oct 1, 2023
dab78b8
tooltip for checkpoint
k2xl Oct 1, 2023
53d1d4e
cleanup
sspenst Oct 1, 2023
ff37737
disable useswr unless popup is open
k2xl Oct 2, 2023
f9e01a0
share icons on post modal
k2xl Oct 2, 2023
a71bd74
sharebar
k2xl Oct 2, 2023
ba1e687
curator edit/delete reviews (#1009)
sspenst Oct 2, 2023
af8f59f
clear review rating button
sspenst Oct 2, 2023
e91677b
curator level management ux
sspenst Oct 2, 2023
120faef
delete achievements on user delete
sspenst Oct 2, 2023
4a41bb7
use level userId instead of req userId
sspenst Oct 2, 2023
a33d3d4
move add to/edit level out of header dropdown
sspenst Oct 2, 2023
49c2205
hotfix for deleted reviews on home page
sspenst Oct 2, 2023
3bed841
achievement page (#1005)
k2xl Oct 3, 2023
a126b82
update calc_records on archive
sspenst Oct 3, 2023
28ffd12
Revert "update calc_records on archive"
sspenst Oct 3, 2023
3de286c
Try to get twitter images to show
k2xl Oct 3, 2023
875bf53
change to twitter site for card...
k2xl Oct 3, 2023
f3e4330
apparently twitter now requires full url for og image
k2xl Oct 3, 2023
66739f7
also do ogurl just in case
k2xl Oct 3, 2023
7b2fefa
mobile buttons update (#1011)
k2xl Oct 4, 2023
aaa12ac
integrityCheckRecords
sspenst Oct 4, 2023
5bf2373
more accurate preventKeyDownEvent
sspenst Oct 4, 2023
eb81176
multiSelectLevel (from #1008)
sspenst Oct 4, 2023
946c3d8
Merge branch 'main' into next-themes
sspenst Oct 4, 2023
71b6482
handle app theme in theme modal
sspenst Oct 4, 2023
eca38ad
use dark class condition instead of checking theme
sspenst Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions components/homepage/homeLoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Image from 'next/image';
import Link from 'next/link';
import { useRouter } from 'next/router';
import React, { useContext, useState } from 'react';
import Theme from '../../constants/theme';
import TimeRange from '../../constants/timeRange';
import { AppContext } from '../../contexts/appContext';
import { useTour } from '../../hooks/useTour';
Expand Down Expand Up @@ -43,15 +42,11 @@ export default function HomeLoggedIn({
topLevelsThisMonth,
user,
}: HomeLoggedInProps) {
const { multiplayerSocket, theme, userConfig } = useContext(AppContext);
const { multiplayerSocket, userConfig } = useContext(AppContext);
const router = useRouter();
const [search, setSearch] = useState('');
const { connectedPlayersCount, matches, socket } = multiplayerSocket;
const buttonClassNames = classNames('py-2.5 px-3.5 inline-flex justify-center items-center gap-2 rounded-md border font-medium align-middle focus:z-10 focus:outline-none focus:ring-2 focus:ring-blue-600 transition-all text-sm whitespace-nowrap',
theme === Theme.Light ?
'bg-green-100 hover:bg-gray-50 border-gray-300 text-gray-700' :
'bg-gray-800 hover:bg-slate-600 border-gray-700 text-gray-300'
);
const buttonClassNames = 'py-2.5 px-3.5 inline-flex justify-center items-center gap-2 rounded-md border font-medium align-middle focus:z-10 focus:outline-none focus:ring-2 focus:ring-blue-600 transition-all text-sm whitespace-nowrap bg-green-100 dark:bg-gray-800 hover:bg-gray-50 hover:dark:bg-slate-600 border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300';

const tour = useTour(PagePath.HOME);

Expand Down
10 changes: 2 additions & 8 deletions components/level/reviews/commentThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Types } from 'mongoose';
import React, { useContext, useEffect, useRef, useState } from 'react';
import toast from 'react-hot-toast';
import { KeyedMutator } from 'swr';
import Theme from '../../../constants/theme';
import { AppContext } from '../../../contexts/appContext';
import { COMMENT_QUERY_LIMIT } from '../../../models/CommentEnums';
import { EnrichedComment } from '../../../models/db/comment';
Expand All @@ -29,7 +28,7 @@ export default function CommentThread({ className, comment, mutateComments, onSe
const [text, setText] = useState('');
const [totalRows, setTotalRows] = useState(comment.totalReplies || 0);
const [page, setPage] = useState(0);
const { theme, user } = useContext(AppContext);
const { user } = useContext(AppContext);

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -210,12 +209,7 @@ export default function CommentThread({ className, comment, mutateComments, onSe
:
<div className='flex flex-col gap-2'>
<textarea
className={classNames(
'block p-1 w-full rounded-lg border disabled:opacity-25',
theme === Theme.Light ?
'bg-gray-100 focus:ring-blue-500 focus:border-blue-500 border-gray-300' :
'bg-gray-700 border-gray-600 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500'
)}
className='block p-1 w-full rounded-lg border disabled:opacity-25 focus:ring-blue-500 focus:border-blue-500 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600'
disabled={isUpdating}
onChange={(e) => setText(e.currentTarget.value)}
placeholder='Reply...'
Expand Down
11 changes: 2 additions & 9 deletions components/level/reviews/commentWall.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import classNames from 'classnames';
import { Types } from 'mongoose';
import React, { useContext, useEffect, useState } from 'react';
import toast from 'react-hot-toast';
import Theme from '../../../constants/theme';
import { AppContext } from '../../../contexts/appContext';
import useComments from '../../../hooks/useComments';
import { COMMENT_QUERY_LIMIT } from '../../../models/CommentEnums';
Expand All @@ -20,8 +18,8 @@ export default function CommentWall({ userId }: CommentWallProps) {
const [isUpdating, setIsUpdating] = useState(false);
const [page, setPage] = useState(0);
const [text, setText] = useState('');
const { theme, user } = useContext(AppContext);
const [totalRows, setTotalRows] = useState(0);
const { user } = useContext(AppContext);

useEffect(() => {
if (commentQuery) {
Expand Down Expand Up @@ -101,12 +99,7 @@ export default function CommentWall({ userId }: CommentWallProps) {
{user &&
<div className='flex flex-col gap-2'>
<textarea
className={classNames(
'block p-1 w-full rounded-lg border disabled:opacity-25',
theme === Theme.Light ?
'bg-gray-100 focus:ring-blue-500 focus:border-blue-500 border-gray-300' :
'bg-gray-700 border-gray-600 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500'
)}
className='block p-1 w-full rounded-lg border disabled:opacity-25 focus:ring-blue-500 focus:border-blue-500 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600'
disabled={isUpdating}
onChange={(e) => setText(e.currentTarget.value)}
placeholder='Add a comment...'
Expand Down
9 changes: 2 additions & 7 deletions components/level/reviews/reviewForm.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import classNames from 'classnames';
import React, { useContext, useState } from 'react';
import toast from 'react-hot-toast';
import { Rating } from 'react-simple-star-rating';
import TextareaAutosize from 'react-textarea-autosize';
import Theme from '../../../constants/theme';
import { AppContext } from '../../../contexts/appContext';
import { LevelContext } from '../../../contexts/levelContext';
import { PageContext } from '../../../contexts/pageContext';
Expand All @@ -24,7 +22,7 @@ export default function ReviewForm({ inModal, review }: ReviewFormProps) {
const [rating, setRating] = useState(review?.score || 0);
const [reviewBody, setReviewBody] = useState(review?.text || '');
const { setPreventKeyDownEvent } = useContext(PageContext);
const { theme, user: reqUser } = useContext(AppContext);
const { user: reqUser } = useContext(AppContext);

function onUpdateReview() {
setIsUpdating(true);
Expand Down Expand Up @@ -118,10 +116,7 @@ export default function ReviewForm({ inModal, review }: ReviewFormProps) {
}
</div>
<TextareaAutosize
className={classNames(
'bg-inherit block py-1 -mt-2 w-full border-b border-neutral-500 disabled:text-neutral-500 transition resize-none placeholder:text-neutral-500 focus:outline-0 rounded-none',
theme === Theme.Light ? 'focus:border-black' : 'focus:border-white',
)}
className='bg-inherit block py-1 -mt-2 w-full border-b border-neutral-500 disabled:text-neutral-500 transition resize-none placeholder:text-neutral-500 focus:outline-0 rounded-none focus:border-black focus:dark:border-white'
disabled={isUpdating}
onBlur={() => {
// only prevent keydown when entering review from the sidebar
Expand Down
7 changes: 7 additions & 0 deletions components/modal/themeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import RadioButton from '@root/components/page/radioButton';
import TileType from '@root/constants/tileType';
import { useTheme } from 'next-themes';
import React, { useContext, useEffect } from 'react';
import Theme, { getIconFromTheme } from '../../constants/theme';
import { AppContext } from '../../contexts/appContext';
Expand All @@ -13,6 +14,7 @@ interface ThemeModalProps {

export default function ThemeModal({ closeModal, isOpen }: ThemeModalProps) {
const { mutateUser, setTheme, theme } = useContext(AppContext);
const { setTheme: setAppTheme } = useTheme();

useEffect(() => {
for (const className of document.body.classList.values()) {
Expand All @@ -24,6 +26,11 @@ export default function ThemeModal({ closeModal, isOpen }: ThemeModalProps) {
}
}, [isOpen, setTheme]);

// maintain accurate app theme for tailwind dark mode classes
useEffect(() => {
setAppTheme(theme === Theme.Light ? 'light' : 'dark');
}, [setAppTheme, theme]);

function onChange(e: React.ChangeEvent<HTMLInputElement>) {
const newTheme = e.currentTarget.value;

Expand Down
11 changes: 2 additions & 9 deletions components/settings/settingsPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import moment from 'moment';
import Image from 'next/image';
import Link from 'next/link';
import React, { useContext, useEffect, useState } from 'react';
import Theme from '../../constants/theme';
import { AppContext } from '../../contexts/appContext';
import useSWRHelper from '../../hooks/useSWRHelper';
import { SubscriptionData } from '../../pages/api/subscription';
Expand Down Expand Up @@ -40,7 +39,7 @@ interface SettingsProProps {
}

export default function SettingsPro({ stripeCustomerPortalLink, stripePaymentLink, stripePaymentYearlyLink }: SettingsProProps) {
const { mutateUser, theme, user, userLoading } = useContext(AppContext);
const { mutateUser, user, userLoading } = useContext(AppContext);
const [plan, setPlan] = useState('year');
const [shouldContinouslyFetch, setShouldContinouslyFetch] = useState(false);
const { data: subscriptionData } = useSWRHelper<SubscriptionData>('/api/subscription');
Expand Down Expand Up @@ -69,12 +68,6 @@ export default function SettingsPro({ stripeCustomerPortalLink, stripePaymentLin
);
}

const buttonClassNames = classNames('py-2.5 px-3.5 mt-2 inline-flex justify-center items-center gap-2 rounded-md border font-medium align-middle focus:z-10 focus:outline-none focus:ring-2 focus:ring-blue-600 transition-all text-sm whitespace-nowrap',
theme === Theme.Light ?
'bg-green-100 hover:bg-gray-50 border-gray-300 text-gray-700' :
'bg-gray-800 hover:bg-slate-600 border-gray-700 text-gray-300'
);

return (
<div className='flex flex-col justify-center items-center gap-4'>
<div className='flex gap-4'>
Expand All @@ -101,7 +94,7 @@ export default function SettingsPro({ stripeCustomerPortalLink, stripePaymentLin
</span>
:
<a
className={buttonClassNames}
className='py-2.5 px-3.5 mt-2 inline-flex justify-center items-center gap-2 rounded-md border font-medium align-middle focus:z-10 focus:outline-none focus:ring-2 focus:ring-blue-600 transition-all text-sm whitespace-nowrap bg-green-100 dark:bg-gray-800 hover:bg-gray-50 hover:dark:bg-slate-600 border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300'
href={stripeCustomerPortalLink || ''}
rel='noreferrer'
target='_blank'
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"newrelic": "^11.1.0",
"next": "^13.3.4",
"next-seo": "^6.1.0",
"next-themes": "^0.2.1",
"nextjs-google-analytics": "^2.3.3",
"nodemailer": "^6.9.5",
"nprogress": "^0.2.0",
Expand Down
7 changes: 3 additions & 4 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Rubik, Teko } from 'next/font/google';
import Head from 'next/head';
import Router, { useRouter } from 'next/router';
import { DefaultSeo } from 'next-seo';
import { ThemeProvider } from 'next-themes';
import nProgress from 'nprogress';
import React, { useEffect, useState } from 'react';
import CookieConsent from 'react-cookie-consent';
Expand Down Expand Up @@ -305,13 +306,11 @@ export default function MyApp({ Component, pageProps }: AppProps) {
const isEU = Intl.DateTimeFormat().resolvedOptions().timeZone.startsWith('Europe');

return (
<>

<ThemeProvider attribute='class'>
<Head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<meta name='apple-itunes-app' content='app-id=1668925562, app-argument=pathology.gg' />
</Head>

<DefaultSeo
defaultTitle='Pathology - Shortest Path Puzzle Game'
description='The goal of the puzzle game Pathology is simple. Get to the exit in the least number of moves.'
Expand Down Expand Up @@ -366,6 +365,6 @@ export default function MyApp({ Component, pageProps }: AppProps) {
</div>
</AppContext.Provider>
</GrowthBookProvider>
</>
</ThemeProvider>
);
}
7 changes: 4 additions & 3 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module.exports = {
'./components/**/*.{js,jsx,ts,tsx}',
'./pages/**/*.{js,jsx,ts,tsx}',
],
darkMode: 'class',
plugins: [
require('@headlessui/tailwindcss')
],
theme: {
extend: {
flexBasis: {
Expand All @@ -15,7 +19,4 @@ module.exports = {
},
},
},
plugins: [
require('@headlessui/tailwindcss')
],
};