@ultraviolet/nextjs 3.0.0-beta.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Ultraviolet JS is a utility package to make Ultraviolet UI work with NextJS. Thi
7
7
  ### Get Started
8
8
 
9
9
  ```sh
10
- pnpm add @ultraviolet/nextjs @ultraviolet/ui @ultraviolet/themes @emotion/react @emotion/styled @emotion/cache
10
+ pnpm add @ultraviolet/nextjs
11
11
  ```
12
12
 
13
13
  In you NextJS project you can implement the following:
@@ -18,6 +18,8 @@ import { consoleLightTheme } from '@ultraviolet/themes'
18
18
  import { ThemeRegistry } from '@ultraviolet/nextjs'
19
19
  import { Button } from '@ultraviolet/ui'
20
20
  import { ReactNode } from 'react'
21
+ import '@ultraviolet/ui/styles'
22
+ import '@ultraviolet/themes/global' // For normalisation, not necessary
21
23
 
22
24
  export default function RootLayout({
23
25
  children,
@@ -52,23 +54,6 @@ pnpm add @ultraviolet/fonts
52
54
  import '@ultraviolet/fonts/fonts.css'
53
55
  ```
54
56
 
55
- - **Styled Components**: in order to customize an emotion component, you need to import the `styled` function from `@emotion/styled` and use it to create your styled components. Emotion is not yet compatible with server components, so you need to use the `styled` function in a client component. Example:
56
-
57
- ```tsx
58
- "use client"
59
-
60
- import { styled } from '@emotion/styled'
61
-
62
- const Button = styled.button`
63
- background-color: #0070f3;
64
- color: white;
65
- padding: 10px 20px;
66
- border: none;
67
- border-radius: 4px;
68
- cursor: pointer;
69
- `
70
- ```
71
-
72
57
  ## Documentation
73
58
 
74
59
  Checkout our [documentation website](https://storybook.ultraviolet.scaleway.com/).
@@ -1,4 +1,4 @@
1
- import { ThemeProvider } from '@emotion/react';
1
+ import { ThemeProvider } from '@ultraviolet/themes';
2
2
  import type { ComponentProps, ReactNode } from 'react';
3
3
  type ThemeRegistryProps = {
4
4
  children: ReactNode;
@@ -8,5 +8,5 @@ type ThemeRegistryProps = {
8
8
  * ThemeRegistry is a component that provides a theme to its children.
9
9
  * This solution is provided to work with Next.js app router.
10
10
  */
11
- export declare const ThemeRegistry: ({ children, theme }: ThemeRegistryProps) => import("@emotion/react/jsx-runtime").JSX.Element;
11
+ export declare const ThemeRegistry: ({ children, theme }: ThemeRegistryProps) => import("react/jsx-runtime").JSX.Element;
12
12
  export {};
@@ -1,55 +1,7 @@
1
1
  "use client";
2
- import { jsx } from "@emotion/react/jsx-runtime";
3
- import createCache from "@emotion/cache";
4
- import { CacheProvider, ThemeProvider } from "@emotion/react";
5
- import { useServerInsertedHTML } from "next/navigation";
6
- import { useState } from "react";
7
- const ThemeRegistry = ({
8
- children,
9
- theme
10
- }) => {
11
- const [{
12
- cache,
13
- flush
14
- }] = useState(() => {
15
- const localCache = createCache({
16
- key: "uv"
17
- });
18
- localCache.compat = true;
19
- const prevInsert = localCache.insert;
20
- let inserted = [];
21
- localCache.insert = (...args) => {
22
- const serialized = args[1];
23
- if (localCache.inserted[serialized.name] === void 0) {
24
- inserted.push(serialized.name);
25
- }
26
- return prevInsert(...args);
27
- };
28
- const localFlush = () => {
29
- const prevInserted = inserted;
30
- inserted = [];
31
- return prevInserted;
32
- };
33
- return {
34
- cache: localCache,
35
- flush: localFlush
36
- };
37
- });
38
- useServerInsertedHTML(() => {
39
- const names = flush();
40
- if (names.length === 0) {
41
- return null;
42
- }
43
- let styles = "";
44
- for (const name of names) {
45
- styles += cache.inserted[name];
46
- }
47
- return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: {
48
- __html: styles
49
- }, "data-emotion": `${cache.key} ${names.join(" ")}` }, cache.key);
50
- });
51
- return /* @__PURE__ */ jsx(CacheProvider, { value: cache, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children }) });
52
- };
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { ThemeProvider } from "@ultraviolet/themes";
4
+ const ThemeRegistry = ({ children, theme }) => /* @__PURE__ */ jsx(ThemeProvider, { theme, children });
53
5
  export {
54
6
  ThemeRegistry
55
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/nextjs",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.1",
4
4
  "description": "Ultraviolet NextJS utility package",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -42,22 +42,18 @@
42
42
  }
43
43
  },
44
44
  "peerDependencies": {
45
- "@emotion/cache": "11.14.0",
46
- "@emotion/react": "11.14.0",
47
- "@emotion/styled": "11.14.1",
48
- "next": "15.x",
45
+ "next": "15.x || 16.x",
49
46
  "react": "18.x || 19.x",
50
- "react-dom": "18.x || 19.x",
51
- "@ultraviolet/ui": "3.0.0-beta.20"
47
+ "react-dom": "18.x || 19.x"
52
48
  },
53
49
  "devDependencies": {
54
- "@emotion/cache": "11.14.0",
55
- "@emotion/react": "11.14.0",
56
- "@emotion/styled": "11.14.1",
57
- "next": "15.5.3",
58
- "react": "19.1.1",
59
- "react-dom": "19.1.1",
60
- "@ultraviolet/ui": "3.0.0-beta.20"
50
+ "next": "16.0.7",
51
+ "react": "19.2.0",
52
+ "react-dom": "19.2.0"
53
+ },
54
+ "dependencies": {
55
+ "@ultraviolet/themes": "3.0.0",
56
+ "@ultraviolet/ui": "3.1.0"
61
57
  },
62
58
  "scripts": {
63
59
  "type:generate": "tsc --declaration -p tsconfig.build.json",
@@ -1,57 +0,0 @@
1
- "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("@emotion/react/jsx-runtime");
5
- const createCache = require("@emotion/cache");
6
- const react$1 = require("@emotion/react");
7
- const navigation = require("next/navigation");
8
- const react = require("react");
9
- const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
10
- const createCache__default = /* @__PURE__ */ _interopDefaultCompat(createCache);
11
- const ThemeRegistry = ({
12
- children,
13
- theme
14
- }) => {
15
- const [{
16
- cache,
17
- flush
18
- }] = react.useState(() => {
19
- const localCache = createCache__default.default({
20
- key: "uv"
21
- });
22
- localCache.compat = true;
23
- const prevInsert = localCache.insert;
24
- let inserted = [];
25
- localCache.insert = (...args) => {
26
- const serialized = args[1];
27
- if (localCache.inserted[serialized.name] === void 0) {
28
- inserted.push(serialized.name);
29
- }
30
- return prevInsert(...args);
31
- };
32
- const localFlush = () => {
33
- const prevInserted = inserted;
34
- inserted = [];
35
- return prevInserted;
36
- };
37
- return {
38
- cache: localCache,
39
- flush: localFlush
40
- };
41
- });
42
- navigation.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
- return /* @__PURE__ */ jsxRuntime.jsx("style", { dangerouslySetInnerHTML: {
52
- __html: styles
53
- }, "data-emotion": `${cache.key} ${names.join(" ")}` }, cache.key);
54
- });
55
- return /* @__PURE__ */ jsxRuntime.jsx(react$1.CacheProvider, { value: cache, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ThemeProvider, { theme, children }) });
56
- };
57
- exports.ThemeRegistry = ThemeRegistry;
package/dist/index.cjs DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const ThemeRegistry = require("./ThemeRegistry.cjs");
4
- exports.ThemeRegistry = ThemeRegistry.ThemeRegistry;