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

Disable dark mode #635

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
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
24 changes: 0 additions & 24 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -11,25 +11,15 @@ import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp'
import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline'

import * as config from '@/lib/config'
import { useDarkMode } from '@/lib/use-dark-mode'

import styles from './styles.module.css'

// TODO: merge the data and icons from PageSocial with the social links in Footer

export const FooterImpl: React.FC = () => {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()
const currentYear = new Date().getFullYear()

const onToggleDarkMode = React.useCallback(
(e) => {
e.preventDefault()
toggleDarkMode()
},
[toggleDarkMode]
)

React.useEffect(() => {
setHasMounted(true)
}, [])
@@ -38,20 +28,6 @@ export const FooterImpl: React.FC = () => {
<footer className={styles.footer}>
<div className={styles.copyright}>Copyright {currentYear} {config.author}</div>

<div className={styles.settings}>
{hasMounted && (
<a
className={styles.toggleDarkMode}
href='#'
role='button'
onClick={onToggleDarkMode}
title='Toggle dark mode'
>
{isDarkMode ? <IoMoonSharp /> : <IoSunnyOutline />}
</a>
)}
</div>

<div className={styles.social}>
{config.twitter && (
<a
8 changes: 0 additions & 8 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
@@ -17,10 +17,8 @@ import * as types from '@/lib/types'
import { mapImageUrl } from '@/lib/map-image-url'
import { getCanonicalPageUrl, mapPageUrl } from '@/lib/map-page-url'
import { searchNotion } from '@/lib/search-notion'
import { useDarkMode } from '@/lib/use-dark-mode'

import { Footer } from './Footer'
import { GitHubShareButton } from './GitHubShareButton'
import { Loading } from './Loading'
import { NotionPageHeader } from './NotionPageHeader'
import { Page404 } from './Page404'
@@ -172,8 +170,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
// lite mode is for oembed
const isLiteMode = lite === 'true'

const { isDarkMode } = useDarkMode()

const siteMapPageUrl = React.useMemo(() => {
const params: any = {}
if (lite) params.lite = lite
@@ -254,14 +250,12 @@ export const NotionPage: React.FC<types.PageProps> = ({
/>

{isLiteMode && <BodyClassName className='notion-lite' />}
{isDarkMode && <BodyClassName className='dark-mode' />}

<NotionRenderer
bodyClassName={cs(
styles.notion,
pageId === site.rootNotionPageId && 'index-page'
)}
darkMode={isDarkMode}
components={components}
recordMap={recordMap}
rootPageId={site.rootNotionPageId}
@@ -280,8 +274,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
pageAside={pageAside}
footer={footer}
/>

<GitHubShareButton />
</>
)
}
8 changes: 0 additions & 8 deletions components/NotionPageHeader.tsx
Original file line number Diff line number Diff line change
@@ -7,28 +7,20 @@ import cs from 'classnames'
import { Breadcrumbs, Header, Search, useNotionContext } from 'react-notion-x'

import { isSearchEnabled, navigationLinks, navigationStyle } from '@/lib/config'
import { useDarkMode } from '@/lib/use-dark-mode'

import styles from './styles.module.css'

const ToggleThemeButton = () => {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()

React.useEffect(() => {
setHasMounted(true)
}, [])

const onToggleTheme = React.useCallback(() => {
toggleDarkMode()
}, [toggleDarkMode])

return (
<div
className={cs('breadcrumb', 'button', !hasMounted && styles.hidden)}
onClick={onToggleTheme}
>
{hasMounted && isDarkMode ? <IoMoonSharp /> : <IoSunnyOutline />}
</div>
)
}
34 changes: 1 addition & 33 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -25,39 +25,7 @@ export default class MyDocument extends Document {
dangerouslySetInnerHTML={{
__html: `
/** Inlined version of noflash.js from use-dark-mode */
;(function () {
var storageKey = 'darkMode'
var classNameDark = 'dark-mode'
var classNameLight = 'light-mode'
function setClassOnDocumentBody(darkMode) {
document.body.classList.add(darkMode ? classNameDark : classNameLight)
document.body.classList.remove(darkMode ? classNameLight : classNameDark)
}
var preferDarkQuery = '(prefers-color-scheme: dark)'
var mql = window.matchMedia(preferDarkQuery)
var supportsColorSchemeQuery = mql.media === preferDarkQuery
var localStorageTheme = null
try {
localStorageTheme = localStorage.getItem(storageKey)
} catch (err) {}
var localStorageExists = localStorageTheme !== null
if (localStorageExists) {
localStorageTheme = JSON.parse(localStorageTheme)
}
// Determine the source of truth
if (localStorageExists) {
// source of truth from localStorage
setClassOnDocumentBody(localStorageTheme)
} else if (supportsColorSchemeQuery) {
// source of truth from system
setClassOnDocumentBody(mql.matches)
localStorage.setItem(storageKey, mql.matches)
} else {
// source of truth from document.body
var isDarkMode = document.body.classList.contains(classNameDark)
localStorage.setItem(storageKey, JSON.stringify(isDarkMode))
}
})();
;(function () {})();
`
}}
/>
43 changes: 26 additions & 17 deletions site.config.ts
Original file line number Diff line number Diff line change
@@ -2,19 +2,19 @@ import { siteConfig } from './lib/site-config'

export default siteConfig({
// the site's root Notion page (required)
rootNotionPageId: '7875426197cf461698809def95960ebf',
rootNotionPageId: '21154a51f1de4dfda9511bab441ece3f',

// if you want to restrict pages to a single notion workspace (optional)
// (this should be a Notion ID; see the docs for how to extract this)
rootNotionSpaceId: null,

// basic site info (required)
name: 'Next.js Notion Starter Kit',
domain: 'nextjs-notion-starter-kit.transitivebullsh.it',
author: 'Travis Fischer',
name: 'Sam Lee Portfolio',
domain: 'https://18smlee.github.io/samlee-portfolio/',
author: 'Samantha Lee',

// open graph metadata (optional)
description: 'Example Next.js Notion Starter Kit Site',
description: 'Sam Lee Portfolio',

// social usernames (optional)
twitter: 'transitive_bs',
@@ -37,6 +37,7 @@ export default siteConfig({
// NOTE: if you enable redis, you need to set the `REDIS_HOST` and `REDIS_PASSWORD`
// environment variables. see the readme for more info
isRedisEnabled: false,
isSearchEnabled: false,

// map of notion page IDs to URL paths (optional)
// any pages defined here will override their default URL paths
@@ -50,16 +51,24 @@ export default siteConfig({

// whether to use the default notion navigation style or a custom one with links to
// important pages. To use `navigationLinks`, set `navigationStyle` to `custom`.
navigationStyle: 'default'
// navigationStyle: 'custom',
// navigationLinks: [
// {
// title: 'About',
// pageId: 'f1199d37579b41cbabfc0b5174f4256a'
// },
// {
// title: 'Contact',
// pageId: '6a29ebcb935a4f0689fe661ab5f3b8d1'
// }
// ]
// navigationStyle: 'default'
navigationStyle: 'custom',
navigationLinks: [
{
title: '3D Modeling',
pageId: '7c7dfdbdfcb74fc29cc551b5258cd82a'
},
{
title: 'Sketchbook',
pageId: 'c0d168169aff4a72be5aaf417e0ccbf0'
},
{
title: 'Code',
pageId: '1b75c913a6c14c45a806df7439e28853'
},
{
title: 'About Me',
pageId: '4d1b0f1f2c55474fa15da73b167d11d1'
},
]
})
15 changes: 13 additions & 2 deletions styles/notion.css
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
*/

.notion {
--notion-max-width: 720px;
--notion-max-width: 1020px;
--notion-header-height: 54px;
}

@@ -41,6 +41,7 @@
.notion-asset-wrapper-video > div,
.notion-asset-wrapper-video video {
width: 100% !important;
height: 500px !important;
}

.notion-header .notion-nav-header {
@@ -54,7 +55,7 @@
}

.notion-gallery-grid {
grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
grid-gap: 6vmin;
gap: 6vmin;
}
@@ -348,9 +349,15 @@
}

/* if you don't want rounded page icon images, remove this */
.notion-page-has-cover .notion-page-icon-hero.notion-page-icon-image {
top: -90px;
}
.notion-page-icon-hero.notion-page-icon-image {
border-radius: 50%;
box-shadow: 0 8px 40px 0 rgb(0 0 0 / 21%);
width: 170px;
height: 170px;
margin-left: -80px;
}
.notion-page-icon-hero.notion-page-icon-image span,
.notion-page-icon-hero.notion-page-icon-image img {
@@ -403,3 +410,7 @@
.notion-equation.notion-equation-block{
align-items: center;
}

.notion-h2 {
text-align: center;
}