Skip to content

Commit bc4a4ba

Browse files
committed
fix: remove emotion from nextjs
1 parent 9e1b037 commit bc4a4ba

File tree

3 files changed

+11
-70
lines changed

3 files changed

+11
-70
lines changed

packages/nextjs/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,16 @@
5050
"default": "./dist/index.js"
5151
}
5252
},
53+
"dependencies": {
54+
"@ultraviolet/themes": "workspace:*"
55+
},
5356
"peerDependencies": {
54-
"@emotion/cache": "11.14.0",
55-
"@emotion/react": "11.14.0",
56-
"@emotion/styled": "11.14.1",
5757
"@ultraviolet/ui": "workspace:*",
5858
"next": "15.x",
5959
"react": "18.x || 19.x",
6060
"react-dom": "18.x || 19.x"
6161
},
6262
"devDependencies": {
63-
"@emotion/cache": "11.14.0",
64-
"@emotion/react": "11.14.0",
65-
"@emotion/styled": "11.14.1",
6663
"@ultraviolet/ui": "workspace:*",
6764
"next": "15.5.6",
6865
"react": "19.2.0",
Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
'use client'
22

3-
import createCache from '@emotion/cache'
4-
import { CacheProvider, ThemeProvider } from '@emotion/react'
5-
import { useServerInsertedHTML } from 'next/navigation'
3+
import { ThemeProvider } from '@ultraviolet/themes'
64
import type { ComponentProps, ReactNode } from 'react'
7-
import { useState } from 'react'
85

96
type ThemeRegistryProps = {
107
children: ReactNode
@@ -15,54 +12,6 @@ type ThemeRegistryProps = {
1512
* ThemeRegistry is a component that provides a theme to its children.
1613
* This solution is provided to work with Next.js app router.
1714
*/
18-
export const ThemeRegistry = ({ children, theme }: ThemeRegistryProps) => {
19-
const [{ cache, flush }] = useState(() => {
20-
const localCache = createCache({ key: 'uv' })
21-
localCache.compat = true
22-
const prevInsert = localCache.insert
23-
let inserted: string[] = []
24-
localCache.insert = (...args) => {
25-
const serialized = args[1]
26-
if (localCache.inserted[serialized.name] === undefined) {
27-
inserted.push(serialized.name)
28-
}
29-
30-
return prevInsert(...args)
31-
}
32-
const localFlush = () => {
33-
const prevInserted = inserted
34-
inserted = []
35-
36-
return prevInserted
37-
}
38-
39-
return { cache: localCache, flush: localFlush }
40-
})
41-
42-
useServerInsertedHTML(() => {
43-
const names = flush()
44-
if (names.length === 0) {
45-
return null
46-
}
47-
let styles = ''
48-
for (const name of names) {
49-
styles += cache.inserted[name]
50-
}
51-
52-
return (
53-
<style
54-
dangerouslySetInnerHTML={{
55-
__html: styles,
56-
}}
57-
data-emotion={`${cache.key} ${names.join(' ')}`}
58-
key={cache.key}
59-
/>
60-
)
61-
})
62-
63-
return (
64-
<CacheProvider value={cache}>
65-
<ThemeProvider theme={theme}>{children}</ThemeProvider>
66-
</CacheProvider>
67-
)
68-
}
15+
export const ThemeRegistry = ({ children, theme }: ThemeRegistryProps) => (
16+
<ThemeProvider theme={theme}>{children}</ThemeProvider>
17+
)

pnpm-lock.yaml

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)