@worldresources/wri-design-systems 2.204.0 → 2.204.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
@@ -85,11 +85,71 @@ Copy the `SKILL.md` file you want into the matching skills folder in your own pr
85
85
 
86
86
  With this custom theme you can change the color scheme according to your Project Theme
87
87
 
88
+ ### Add an EmotionProvider to avoid hydrate errors
89
+
90
+ ```tsx
91
+ 'use client'
92
+
93
+ import React, { useState } from 'react'
94
+ import { useServerInsertedHTML } from 'next/navigation'
95
+ import { CacheProvider } from '@emotion/react'
96
+ import createCache from '@emotion/cache'
97
+
98
+ export default function EmotionProvider({
99
+ children,
100
+ }: {
101
+ children: React.ReactNode
102
+ }) {
103
+ const [{ cache, flush }] = useState(() => {
104
+ const cache = createCache({ key: 'css-global' })
105
+ cache.compat = true
106
+ const prevInsert = cache.insert
107
+ let inserted: string[] = []
108
+ cache.insert = (...args) => {
109
+ const serialized = args[1]
110
+ if (cache.inserted[serialized.name] === undefined) {
111
+ inserted.push(serialized.name)
112
+ }
113
+ return prevInsert(...args)
114
+ }
115
+ const flush = () => {
116
+ const prevInserted = inserted
117
+ inserted = []
118
+ return prevInserted
119
+ }
120
+ return { cache, flush }
121
+ })
122
+
123
+ useServerInsertedHTML(() => {
124
+ const names = flush()
125
+ if (names.length === 0) return null
126
+ let styles = ''
127
+ for (const name of names) {
128
+ styles += cache.inserted[name]
129
+ }
130
+ return (
131
+ <style
132
+ data-emotion={`${cache.key} ${names.join(' ')}`}
133
+ dangerouslySetInnerHTML={{ __html: styles }}
134
+ />
135
+ )
136
+ })
137
+
138
+ return <CacheProvider value={cache}>{children}</CacheProvider>
139
+ }
140
+ ```
141
+
142
+ ### Chakra Provider
143
+
88
144
  ```tsx
89
- import { createSystem, defaultConfig } from '@chakra-ui/react'
145
+ import {
146
+ ChakraProvider as ChakraProviderComponent,
147
+ createSystem,
148
+ } from '@chakra-ui/react'
90
149
  import { designSystemStyles } from '@worldresources/wri-design-systems'
150
+ import EmotionProvider from './EmotionProvider'
91
151
 
92
- export const system = createSystem(designSystemStyles._config, {
152
+ const customStylesSystem = createSystem(designSystemStyles._config, {
93
153
  theme: {
94
154
  tokens: {
95
155
  colors: {
@@ -177,23 +237,27 @@ export const system = createSystem(designSystemStyles._config, {
177
237
  },
178
238
  },
179
239
  })
240
+
241
+ const ChakraProvider = ({ children }: { children: React.ReactNode }) => (
242
+ <EmotionProvider>
243
+ <ChakraProviderComponent value={customStylesSystem}>
244
+ {children}
245
+ </ChakraProviderComponent>
246
+ </EmotionProvider>
247
+ )
248
+
249
+ export default ChakraProvider
180
250
  ```
181
251
 
182
252
  ### Wrap ChakraProvider at the root of your app
183
253
 
184
254
  ```tsx
185
255
  import React from 'react'
186
- import { ChakraProvider } from '@chakra-ui/react'
187
- import { designSystemStyles } from "@worldresources/wri-design-systems";
188
- import { system } from './lib/theme'
256
+ import ChakraProvider from './path/to/your/ChakraProvider'
189
257
 
190
258
  function App() {
191
259
  return (
192
- {/* if you want to use the default WRI Theme colors */}
193
- {/* <ChakraProvider value={designSystemStyles}> */}
194
-
195
- {/* if you want to use your custom system Theme colors */}
196
- <ChakraProvider value={system}>
260
+ <ChakraProvider>
197
261
  <TheRestOfYourApplication />
198
262
  </ChakraProvider>
199
263
  )
@@ -470,7 +534,7 @@ line-height: ${getThemedLineHeight(600)};
470
534
  ## Building the lib
471
535
 
472
536
  ```
473
- yarn lint-fix
537
+ yarn lint:fix
474
538
  ```
475
539
 
476
540
  ```
package/dist/index.cjs.js CHANGED
@@ -1926,6 +1926,7 @@
1926
1926
 
1927
1927
  .ds-select-input-container {
1928
1928
  margin-bottom: 0;
1929
+ width: auto;
1929
1930
  }
1930
1931
 
1931
1932
  .chakra-slider__root {
package/dist/index.esm.js CHANGED
@@ -2009,6 +2009,7 @@ import{createSystem as e,defaultConfig as t,Button as n,Box as r,Spinner as o,Ic
2009
2009
 
2010
2010
  .ds-select-input-container {
2011
2011
  margin-bottom: 0;
2012
+ width: auto;
2012
2013
  }
2013
2014
 
2014
2015
  .chakra-slider__root {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldresources/wri-design-systems",
3
- "version": "2.204.0",
3
+ "version": "2.204.1",
4
4
  "description": "WRI UI Library",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -24,7 +24,7 @@
24
24
  "build-storybook": "storybook build",
25
25
  "lint": "eslint src/**/*.ts src/**/*.tsx",
26
26
  "prettier": "prettier --write --loglevel warn .",
27
- "lint-fix": "yarn lint --fix && yarn prettier",
27
+ "lint:fix": "yarn lint --fix && yarn prettier",
28
28
  "new-component": "tsx scripts/new-component.ts",
29
29
  "setup-ai": "node contributor-ai/setup-ai.mjs",
30
30
  "postinstall": "node -e \"const{existsSync}=require('fs');if(existsSync('contributor-ai/setup-ai.mjs')){require('child_process').execSync('node contributor-ai/setup-ai.mjs',{stdio:'inherit'})}\""