Skip to content

Commit 142e080

Browse files
authored
Nonce support for material in example (#59)
* nonce support in material * downgrade notistack
1 parent d9981a8 commit 142e080

3 files changed

Lines changed: 40 additions & 33 deletions

File tree

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@mui/icons-material": "^5.15.0",
1616
"@mui/material": "^5.15.0",
1717
"@piwikpro/react-piwik-pro": "file:..",
18-
"notistack": "^3.0.1",
18+
"notistack": "^2.0.8",
1919
"react": "^18.2.0",
2020
"react-dom": "^18.2.0",
2121
"react-router-dom": "^6.20.1"

example/src/main.tsx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,49 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
33
import { createRoot } from 'react-dom/client'
44
import { routes } from './routes.tsx'
55
import { Box, CssBaseline } from '@mui/material'
6+
import { CacheProvider } from '@emotion/react'
7+
import createCache from '@emotion/cache'
68
import { SnackbarProvider } from 'notistack'
79
import PiwikPro from '@piwikpro/react-piwik-pro'
810

11+
// to test the nonce, we need to build the app and serve it with CSP policy
12+
const nonce = '8IBTHwOdqNKAWeKl7plt8g==' // nonce placeholder
13+
const cache = createCache({
14+
key: 'css',
15+
prepend: true,
16+
nonce: nonce
17+
})
18+
919
PiwikPro.initialize(
1020
'957285ba-7867-4c6b-a8be-5e3e6c069b71',
1121
'https://astralprojection.promilci.com',
12-
{ dataLayerName: 'myDataLayer' }
22+
{ dataLayerName: 'myDataLayer', nonce }
1323
)
1424

1525
const App = () => (
16-
<SnackbarProvider
17-
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
18-
maxSnack={10}
19-
>
20-
<Router>
21-
<Box sx={{ display: 'flex' }}>
22-
<CssBaseline />
23-
<Header />
24-
<Box
25-
component='main'
26-
sx={{ flexGrow: 1, bgcolor: 'background.default', p: 3 }}
27-
>
28-
<Routes>
29-
{routes.map(({ path, element }, index) => (
30-
<Route key={index} path={path} element={element} />
31-
))}
32-
</Routes>
26+
<CacheProvider value={cache}>
27+
<SnackbarProvider
28+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
29+
maxSnack={10}
30+
>
31+
<Router>
32+
<Box sx={{ display: 'flex' }}>
33+
<CssBaseline />
34+
<Header />
35+
<Box
36+
component='main'
37+
sx={{ flexGrow: 1, bgcolor: 'background.default', p: 3 }}
38+
>
39+
<Routes>
40+
{routes.map(({ path, element }, index) => (
41+
<Route key={index} path={path} element={element} />
42+
))}
43+
</Routes>
44+
</Box>
3345
</Box>
34-
</Box>
35-
</Router>
36-
</SnackbarProvider>
46+
</Router>
47+
</SnackbarProvider>
48+
</CacheProvider>
3749
)
3850

3951
const container = document.getElementById('root')

example/yarn.lock

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,11 +1249,6 @@ globby@^11.1.0:
12491249
merge2 "^1.4.1"
12501250
slash "^3.0.0"
12511251

1252-
goober@^2.0.33:
1253-
version "2.1.13"
1254-
resolved "https://registry.npmjs.org/goober/-/goober-2.1.13.tgz"
1255-
integrity sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==
1256-
12571252
graphemer@^1.4.0:
12581253
version "1.4.0"
12591254
resolved "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz"
@@ -1276,7 +1271,7 @@ hasown@^2.0.0:
12761271
dependencies:
12771272
function-bind "^1.1.2"
12781273

1279-
hoist-non-react-statics@^3.3.1:
1274+
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1:
12801275
version "3.3.2"
12811276
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz"
12821277
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -1466,13 +1461,13 @@ natural-compare@^1.4.0:
14661461
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
14671462
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
14681463

1469-
notistack@^3.0.1:
1470-
version "3.0.1"
1471-
resolved "https://registry.npmjs.org/notistack/-/notistack-3.0.1.tgz"
1472-
integrity sha512-ntVZXXgSQH5WYfyU+3HfcXuKaapzAJ8fBLQ/G618rn3yvSzEbnOB8ZSOwhX+dAORy/lw+GC2N061JA0+gYWTVA==
1464+
notistack@^2.0.8:
1465+
version "2.0.8"
1466+
resolved "https://registry.yarnpkg.com/notistack/-/notistack-2.0.8.tgz#78cdf34c64e311bf1d1d71c2123396bcdea5e95b"
1467+
integrity sha512-/IY14wkFp5qjPgKNvAdfL5Jp6q90+MjgKTPh4c81r/lW70KeuX6b9pE/4f8L4FG31cNudbN9siiFS5ql1aSLRw==
14731468
dependencies:
14741469
clsx "^1.1.0"
1475-
goober "^2.0.33"
1470+
hoist-non-react-statics "^3.3.0"
14761471

14771472
object-assign@^4.1.1:
14781473
version "4.1.1"

0 commit comments

Comments
 (0)