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

Provide themes without any wrappers #2945

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions .changeset/silly-walls-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'nextra-theme-blog': patch
'nextra-theme-docs': patch
---

Provide themes without any wrappers

- It makes it easy to switch to next.js app router and utilize server components
- Wrapper would force everything to be client component.
- Has more granular configuration for theme and colorScheme
- Possibility of adding theme sets - i.e., dark and light variants of each theme.

4 changes: 2 additions & 2 deletions docs/pages/docs/docs-theme/api/use-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ context.
[Navigation](/docs/docs-theme/theme-configuration#navigation)
- `themeSwitch`: data about
[Theme Switch](/docs/docs-theme/theme-configuration#theme-switch)
- `nextThemes`: data about theme configuration (see
[pacocoursey/next-themes](https://github.com/pacocoursey/next-themes))
- `nextjs-themes`: data about theme configuration (see
[react18-tools/nextjs-themes](https://github.com/react18-tools/nextjs-themes))
- `notFound`: data to display when the page is not found
- `primaryHue`: data about
[Theme Color](/docs/docs-theme/theme-configuration#theme-color)
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/docs-theme/theme-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ Customize the theme behavior of the website.
<>
Configuration for the{' '}
<a
href="https://github.com/pacocoursey/next-themes#themeprovider"
href="https://github.com/react18-tools/nextjs-themes/blob/main/guides/getting-started.md#configuration"
target="_blank"
>
next-themes
nextjs-themes
</a>{' '}
package.
</>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@mdx-js/react": "^2.3.0",
"next-themes": "^0.2.1",
"next": "13.5.6"
},
"patchedDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
},
"dependencies": {
"next-themes": "^0.2.1"
"nextjs-themes": "^4.0.1"
},
"devDependencies": {
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-blog/src/cusdis.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from 'next-themes'
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
import { useTheme } from 'nextjs-themes'
import type { ReactElement } from 'react'
import { useEffect } from 'react'
import { useBlogContext } from './blog-context'
Expand Down
9 changes: 5 additions & 4 deletions packages/nextra-theme-blog/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeProvider } from 'next-themes'
import { ThemeSwitcher } from 'nextjs-themes'
import type { NextraThemeLayoutProps } from 'nextra'
import type { ReactElement, ReactNode } from 'react'
import { ArticleLayout } from './article-layout'
Expand Down Expand Up @@ -41,15 +41,16 @@ export default function Layout({
const extendedConfig = { ...DEFAULT_THEME, ...context.themeConfig }

return (
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<>
<ThemeSwitcher />
<BlogLayout config={extendedConfig} opts={context.pageOpts}>
{children}
</BlogLayout>
</ThemeProvider>
</>
)
}

export { useTheme } from 'next-themes'
export { useTheme } from 'nextjs-themes'
export { useBlogContext } from './blog-context'
export { getStaticTags } from './utils/get-tags'
export * from './types'
2 changes: 1 addition & 1 deletion packages/nextra-theme-blog/src/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from 'next-themes'
import { useTheme } from 'nextjs-themes'
import { useMounted } from 'nextra/hooks'
import { MoonIcon, SunIcon } from 'nextra/icons'

Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"intersection-observer": "^0.12.2",
"match-sorter": "^6.3.1",
"next-seo": "^6.0.0",
"next-themes": "^0.2.1",
"nextjs-themes": "^4.0.1",
"scroll-into-view-if-needed": "^3.1.0",
"zod": "^3.22.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/components/head.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextSeoProps } from 'next-seo'
import { NextSeo } from 'next-seo'
import { useTheme } from 'next-themes'
import NextHead from 'next/head'
import { useTheme } from 'nextjs-themes'
import { useMounted } from 'nextra/hooks'
import type { ReactElement } from 'react'
import { useConfig } from '../contexts'
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/components/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme } from 'next-themes'
import { useTheme } from 'nextjs-themes'
import { useMounted } from 'nextra/hooks'
import { MoonIcon, SunIcon } from 'nextra/icons'
import type { ReactElement } from 'react'
Expand Down
15 changes: 5 additions & 10 deletions packages/nextra-theme-docs/src/contexts/config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeProvider } from 'next-themes'
import { ThemeSwitcher } from 'nextjs-themes'
import type { FrontMatter, PageMapItem, PageOpts } from 'nextra'
import { metaSchema } from 'nextra/normalize-pages'
import type { ReactElement, ReactNode } from 'react'
Expand Down Expand Up @@ -108,19 +108,14 @@ export const ConfigProvider = ({
frontMatter: pageOpts.frontMatter
}

const { nextThemes } = extendedConfig
const { nextThemes: nextjsThemes } = extendedConfig

return (
<ThemeProvider
attribute="class"
disableTransitionOnChange
defaultTheme={nextThemes.defaultTheme}
storageKey={nextThemes.storageKey}
forcedTheme={nextThemes.forcedTheme}
>
<>
<ThemeSwitcher {...nextjsThemes} />
<ConfigContext.Provider value={extendedConfig}>
<MenuProvider value={{ menu, setMenu }}>{children}</MenuProvider>
</ConfigContext.Provider>
</ThemeProvider>
</>
)
}
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export {
Card,
FileTree
} from 'nextra/components'
export { useTheme } from 'next-themes'
export { useTheme } from 'nextjs-themes'
export { Link } from './mdx-components'
export {
Bleed,
Expand Down
Loading