@codecademy/styleguide 79.1.3-alpha.f73629.0 → 79.1.3
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.
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
} from '@codecademy/gamut-styles/src';
|
|
13
13
|
import { Theme } from '@emotion/react';
|
|
14
14
|
|
|
15
|
+
const STORYBOOK_CSP_NONCE = 'storybook-csp-nonce';
|
|
16
|
+
|
|
15
17
|
/**
|
|
16
18
|
* Story functions must be called as a regular function to avoid full-remounts
|
|
17
19
|
* See: https://github.com/storybookjs/storybook/issues/12255
|
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
### [79.1.3
|
|
6
|
+
### [79.1.3](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.2...@codecademy/styleguide@79.1.3) (2026-03-02)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **GamutProvider:** CSP improvements ([1026353](https://github.com/Codecademy/gamut/commit/10263537c190aff0e5686872da2be2a30b1d9201)), closes [/github.com/adobe/react-spectrum/issues/8273#issuecomment-3897820426](https://github.com/Codecademy//github.com/adobe/react-spectrum/issues/8273/issues/issuecomment-3897820426)
|
|
9
11
|
|
|
10
12
|
### [79.1.2](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.1...@codecademy/styleguide@79.1.2) (2026-02-12)
|
|
11
13
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/styleguide",
|
|
3
3
|
"description": "Styleguide & Component library for codecademy.com",
|
|
4
|
-
"version": "79.1.3
|
|
4
|
+
"version": "79.1.3",
|
|
5
5
|
"author": "Codecademy Engineering",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"repository": "git@github.com:Codecademy/gamut.git",
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "3e7f8b5d0df3e4617e5dc93eef096b6dce16d096"
|
|
12
12
|
}
|
|
@@ -39,28 +39,6 @@ yarn add @codecademy/gamut-kit @emotion/react @emotion/styled
|
|
|
39
39
|
|
|
40
40
|
3. Wrap your application root with `GamutProvider` and give it the theme you would like to use for your app.
|
|
41
41
|
|
|
42
|
-
**React 19:**
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
import React from 'react';
|
|
46
|
-
import { createRoot } from 'react-dom/client';
|
|
47
|
-
import { GamutProvider, theme } from '@codecademy/gamut-styles';
|
|
48
|
-
|
|
49
|
-
import { App } from './App';
|
|
50
|
-
|
|
51
|
-
const rootElement = document.getElementById('root');
|
|
52
|
-
if (rootElement) {
|
|
53
|
-
const root = createRoot(rootElement);
|
|
54
|
-
root.render(
|
|
55
|
-
<GamutProvider>
|
|
56
|
-
<App />
|
|
57
|
-
</GamutProvider>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**React 18:**
|
|
63
|
-
|
|
64
42
|
```tsx
|
|
65
43
|
import React from 'react';
|
|
66
44
|
import { render } from 'react-dom';
|
|
@@ -69,14 +47,13 @@ import { GamutProvider, theme } from '@codecademy/gamut-styles';
|
|
|
69
47
|
import { App } from './App';
|
|
70
48
|
|
|
71
49
|
const rootElement = document.getElementById('root');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
50
|
+
|
|
51
|
+
render(
|
|
52
|
+
<GamutProvider>
|
|
53
|
+
<App />
|
|
54
|
+
</GamutProvider>,
|
|
55
|
+
rootElement
|
|
56
|
+
);
|
|
80
57
|
```
|
|
81
58
|
|
|
82
59
|
GamutProvider handles a few critical tasks that need to happen in order for components to work.
|
|
@@ -91,7 +68,7 @@ GamutProvider handles a few critical tasks that need to happen in order for comp
|
|
|
91
68
|
- **Next** `_app.tsx`
|
|
92
69
|
- **Gatsby** `gatsby-ssr.js` `gatsby-browser.js` and use `wrapRootElement` in each.
|
|
93
70
|
|
|
94
|
-
|
|
71
|
+
5. Add required types for your theme, which will determine what props Gamut components allow.
|
|
95
72
|
|
|
96
73
|
```tsx
|
|
97
74
|
// theme.d.ts
|
|
@@ -107,7 +84,7 @@ declare module '@emotion/react' {
|
|
|
107
84
|
|
|
108
85
|
For more information this declaration please checkout the [official emotion documentation](https://emotion.sh/docs/typescript#define-a-theme)!
|
|
109
86
|
|
|
110
|
-
|
|
87
|
+
6. Start Building!
|
|
111
88
|
|
|
112
89
|
```tsx
|
|
113
90
|
import { Background } from '@codecademy/gamut-styles';
|
|
@@ -119,3 +96,15 @@ export const App = () => (
|
|
|
119
96
|
</Background>
|
|
120
97
|
);
|
|
121
98
|
```
|
|
99
|
+
|
|
100
|
+
### Content Security Policy (CSP)
|
|
101
|
+
|
|
102
|
+
If your app uses a strict Content-Security-Policy (e.g. `style-src` without `'unsafe-inline'`), pass a nonce to `GamutProvider` so Emotion and other Gamut-managed style tags are allowed:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<GamutProvider nonce={yourCspNonce}>
|
|
106
|
+
<App />
|
|
107
|
+
</GamutProvider>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Your nonce should be the same value you use in your CSP header (e.g. `style-src 'self' 'nonce-{value}'`).
|