Skip to content

Commit

Permalink
fix(uiux): 🐛 fix UI theme switching
Browse files Browse the repository at this point in the history
  • Loading branch information
vanntile committed Oct 13, 2021
1 parent 44f45f3 commit 37fec49
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"next": "^11.1.0",
"next-mdx-remote": "^3.0.4",
"next-secure-headers": "^2.2.0",
"next-themes": "^0.0.14",
"next-themes": "^0.0.15",
"nprogress": "^0.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Router.events.on('routeChangeComplete', () => done())
Router.events.on('routeChangeError', () => done())

const App: NextPage<Props> = ({ Component, pageProps }) => (
<ThemeProvider attribute="class" defaultTheme="dark">
<ThemeProvider attribute="class" forcedTheme={(Component as unknown as { theme: string }).theme || undefined}>
<MDXProvider components={MDXComponents}>
<Component {...pageProps} />
</MDXProvider>
Expand Down
3 changes: 2 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const externals: ExternalSVG[] = [
},
]

const IndexPage: NextPage<Props> = ({ blogPosts }) => {
const IndexPage: NextPage<Props> & { theme: string } = ({ blogPosts }) => {
const techSectionRef = useRef(null)
const ExperienceTabsRef = useRef(null)
const logomarkInt = useIntersection(techSectionRef, { root: null, rootMargin: '0px', threshold: 0.4 })
Expand Down Expand Up @@ -246,4 +246,5 @@ export const getStaticProps: GetStaticProps<Props> = async () => ({
props: { blogPosts: await getSortedPostsData('posts') },
})

IndexPage.theme = 'dark'
export default IndexPage

0 comments on commit 37fec49

Please sign in to comment.