@codecademy/styleguide 79.1.3-alpha.ef9197.0 → 79.1.3-alpha.f73629.0

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,9 +12,6 @@ import {
12
12
  } from '@codecademy/gamut-styles/src';
13
13
  import { Theme } from '@emotion/react';
14
14
 
15
- /** Nonce passed to GamutProvider so Storybook works behind strict CSP (e.g. style-src 'nonce-{value}'). This is a test and will be removed*/
16
- const STORYBOOK_CSP_NONCE = 'storybook-csp-nonce';
17
-
18
15
  /**
19
16
  * Story functions must be called as a regular function to avoid full-remounts
20
17
  * See: https://github.com/storybookjs/storybook/issues/12255
@@ -58,7 +55,6 @@ export const withEmotion = (Story: any, context: GlobalsContext) => {
58
55
  if (process.env.NODE_ENV === 'test') {
59
56
  return (
60
57
  <GamutProvider
61
- nonce={STORYBOOK_CSP_NONCE}
62
58
  useCache={false}
63
59
  useGlobals={false}
64
60
  theme={currentTheme as unknown as Theme}
@@ -76,10 +72,7 @@ export const withEmotion = (Story: any, context: GlobalsContext) => {
76
72
 
77
73
  // Wrap all stories in minimal provider
78
74
  return (
79
- <GamutProvider
80
- nonce={STORYBOOK_CSP_NONCE}
81
- theme={currentTheme as unknown as Theme}
82
- >
75
+ <GamutProvider theme={currentTheme as unknown as Theme}>
83
76
  <Background
84
77
  alwaysSetVariables
85
78
  bg={themeBackground[colorMode]}
package/CHANGELOG.md CHANGED
@@ -3,11 +3,9 @@
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-alpha.ef9197.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.2...@codecademy/styleguide@79.1.3-alpha.ef9197.0) (2026-02-24)
6
+ ### [79.1.3-alpha.f73629.0](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.2...@codecademy/styleguide@79.1.3-alpha.f73629.0) (2026-02-26)
7
7
 
8
- ### Bug Fixes
9
-
10
- - **CSP:** add better nonce support ([afdff6e](https://github.com/Codecademy/gamut/commit/afdff6e78aa8bed6ce8e051742b3e52822b9ba82))
8
+ **Note:** Version bump only for package @codecademy/styleguide
11
9
 
12
10
  ### [79.1.2](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.1...@codecademy/styleguide@79.1.2) (2026-02-12)
13
11
 
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-alpha.ef9197.0",
4
+ "version": "79.1.3-alpha.f73629.0",
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": "e696eb4261721163f277e8add23dc7705edb1232"
11
+ "gitHead": "bc86647c14e137b537eb8460ae51834595e2831f"
12
12
  }
@@ -39,21 +39,44 @@ 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
+
42
44
  ```tsx
43
45
  import React from 'react';
44
- import { render } from 'react-dom';
46
+ import { createRoot } from 'react-dom/client';
45
47
  import { GamutProvider, theme } from '@codecademy/gamut-styles';
46
48
 
47
49
  import { App } from './App';
48
50
 
49
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
+ ```
50
61
 
51
- render(
52
- <GamutProvider>
53
- <App />
54
- </GamutProvider>,
55
- rootElement
56
- );
62
+ **React 18:**
63
+
64
+ ```tsx
65
+ import React from 'react';
66
+ import { render } from 'react-dom';
67
+ import { GamutProvider, theme } from '@codecademy/gamut-styles';
68
+
69
+ import { App } from './App';
70
+
71
+ const rootElement = document.getElementById('root');
72
+ if (rootElement) {
73
+ render(
74
+ <GamutProvider>
75
+ <App />
76
+ </GamutProvider>,
77
+ rootElement
78
+ );
79
+ }
57
80
  ```
58
81
 
59
82
  GamutProvider handles a few critical tasks that need to happen in order for components to work.
@@ -63,22 +86,6 @@ GamutProvider handles a few critical tasks that need to happen in order for comp
63
86
  3. Adds Global styles and CSS Variables
64
87
  4. Sets the current Color Mode context and variables.
65
88
 
66
- ### Content Security Policy (CSP)
67
-
68
- 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:
69
-
70
- ```tsx
71
- <GamutProvider nonce={yourCspNonce}>
72
- <App />
73
- </GamutProvider>
74
- ```
75
-
76
- Your nonce should be the same value you use in your CSP header (e.g. `style-src 'self' 'nonce-{value}'`). Gamut uses the [get-nonce](https://www.npmjs.com/package/get-nonce) singleton so that style tags injected by react-style-singleton (e.g. from FocusTrap) also receive this nonce.
77
-
78
- **Motion components:** When you pass a nonce to GamutProvider, it also wraps children in framer-motion's MotionConfig so that motion components (Drawer, Alert, List, Toaster, etc.) get the nonce on their injected style tags. No extra wrapper is needed.
79
-
80
- **Video (Vidstack):** The Video component uses `@vidstack/react`, which applies styles via inline styles (element.style / CSSOM). CSP nonces apply only to `<style>` and `<script>` elements, not to inline style attributes, so **nonce cannot fix** Vidstack's CSP violations. If you use strict CSP and the Video component, relax CSP for that context (e.g. allow the Video route or sandbox) or avoid using Video where strict CSP is required.
81
-
82
89
  **Note:** For react frameworks like Next and Gatsby this will be slightly different (see the SSR section for further steps for each framework). Your entry points for each framework will be:
83
90
 
84
91
  - **Next** `_app.tsx`