Skip to content

Commit a781158

Browse files
committed
feat: updated example project to match the consuming project's dom structure and theme settings
1 parent 266aee5 commit a781158

4 files changed

Lines changed: 81 additions & 12 deletions

File tree

examples/react-example/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@chakra-ui/hooks": "^1.7.1",
67
"@chakra-ui/icons": "1.1.1",
7-
"@chakra-ui/react": "~1.8.9",
8-
"@emotion/react": "^11.14.0",
9-
"@emotion/styled": "^11.14.1",
8+
"@chakra-ui/react": "^1.6.7",
9+
"@emotion/react": "^11",
10+
"@emotion/styled": "^11",
1011
"@imagekit/editor": "workspace:*",
1112
"@types/node": "^20.11.24",
1213
"@types/react": "^17.0.2",

examples/react-example/src/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Box, ChakraProvider, Portal } from "@chakra-ui/react"
12
import {
23
ImageKitEditor,
34
type ImageKitEditorProps,
@@ -8,6 +9,7 @@ import {
89
} from "@imagekit/editor"
910
import React, { useCallback, useEffect } from "react"
1011
import ReactDOM from "react-dom"
12+
import { hostTheme } from "./theme/hostTheme"
1113

1214
const TEMPLATE_STORAGE_KEY = "ik-editor:templates:v1"
1315

@@ -422,15 +424,23 @@ function App() {
422424
</div>
423425
</div>
424426

425-
{open && editorProps && <ImageKitEditor {...editorProps} ref={ref} />}
427+
{open && editorProps && (
428+
<Portal>
429+
<Box zIndex="modal" position="relative">
430+
<ImageKitEditor {...editorProps} ref={ref} />
431+
</Box>
432+
</Portal>
433+
)}
426434
</>
427435
)
428436
}
429437

430438
const root = document.getElementById("root")
431439
ReactDOM.render(
432440
<React.StrictMode>
433-
<App />
441+
<ChakraProvider theme={hostTheme}>
442+
<App />
443+
</ChakraProvider>
434444
</React.StrictMode>,
435445
root,
436446
)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { extendTheme } from "@chakra-ui/react"
2+
3+
/**
4+
* Mirrors consuming project's theme's z-index.ts
5+
* and the component overrides that reference those tokens (tooltip, modal, popover).
6+
*/
7+
const zIndices = {
8+
hide: -1,
9+
auto: "auto" as const,
10+
base: 0,
11+
docked: 10,
12+
dropdown: 1000,
13+
sticky: 1100,
14+
banner: 1200,
15+
overlay: 1300,
16+
modal: 2100,
17+
popover: 2000,
18+
skipLink: 1600,
19+
toast: 1700,
20+
tooltip: 2200,
21+
}
22+
23+
export const hostTheme = extendTheme({
24+
zIndices,
25+
styles: {
26+
global: {
27+
html: { overflow: "hidden" },
28+
},
29+
},
30+
components: {
31+
Tooltip: {
32+
baseStyle: {
33+
zIndex: "tooltip",
34+
},
35+
},
36+
Popover: {
37+
baseStyle: {
38+
popper: {
39+
zIndex: "popover",
40+
},
41+
},
42+
},
43+
Modal: {
44+
baseStyle: {
45+
overlay: {
46+
zIndex: "modal",
47+
},
48+
dialogContainer: {
49+
zIndex: "modal",
50+
},
51+
dialog: {
52+
zIndex: "modal",
53+
},
54+
},
55+
},
56+
},
57+
})

yarn.lock

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ __metadata:
683683
languageName: node
684684
linkType: hard
685685

686-
"@chakra-ui/hooks@npm:1.9.1":
686+
"@chakra-ui/hooks@npm:1.9.1, @chakra-ui/hooks@npm:^1.7.1":
687687
version: 1.9.1
688688
resolution: "@chakra-ui/hooks@npm:1.9.1"
689689
dependencies:
@@ -986,7 +986,7 @@ __metadata:
986986
languageName: node
987987
linkType: hard
988988

989-
"@chakra-ui/react@npm:1.8.9, @chakra-ui/react@npm:~1.8.9":
989+
"@chakra-ui/react@npm:1.8.9, @chakra-ui/react@npm:^1.6.7":
990990
version: 1.8.9
991991
resolution: "@chakra-ui/react@npm:1.8.9"
992992
dependencies:
@@ -1505,7 +1505,7 @@ __metadata:
15051505
languageName: node
15061506
linkType: hard
15071507

1508-
"@emotion/react@npm:^11.14.0, @emotion/react@npm:^11.8.1":
1508+
"@emotion/react@npm:^11, @emotion/react@npm:^11.14.0, @emotion/react@npm:^11.8.1":
15091509
version: 11.14.0
15101510
resolution: "@emotion/react@npm:11.14.0"
15111511
dependencies:
@@ -1546,7 +1546,7 @@ __metadata:
15461546
languageName: node
15471547
linkType: hard
15481548

1549-
"@emotion/styled@npm:^11.14.1":
1549+
"@emotion/styled@npm:^11, @emotion/styled@npm:^11.14.1":
15501550
version: 11.14.1
15511551
resolution: "@emotion/styled@npm:11.14.1"
15521552
dependencies:
@@ -6420,10 +6420,11 @@ __metadata:
64206420
version: 0.0.0-use.local
64216421
resolution: "react-example@workspace:examples/react-example"
64226422
dependencies:
6423+
"@chakra-ui/hooks": "npm:^1.7.1"
64236424
"@chakra-ui/icons": "npm:1.1.1"
6424-
"@chakra-ui/react": "npm:~1.8.9"
6425-
"@emotion/react": "npm:^11.14.0"
6426-
"@emotion/styled": "npm:^11.14.1"
6425+
"@chakra-ui/react": "npm:^1.6.7"
6426+
"@emotion/react": "npm:^11"
6427+
"@emotion/styled": "npm:^11"
64276428
"@imagekit/editor": "workspace:*"
64286429
"@types/node": "npm:^20.11.24"
64296430
"@types/react": "npm:^17.0.2"

0 commit comments

Comments
 (0)