Skip to content

Instantly share code, notes, and snippets.

@austintackaberry
Created February 19, 2023 22:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austintackaberry/e9453b715eff0124cb3427e5731a0b69 to your computer and use it in GitHub Desktop.
Save austintackaberry/e9453b715eff0124cb3427e5731a0b69 to your computer and use it in GitHub Desktop.
Plasmo Chakra UI Modal
import Calendar from "~components/Calendar"
import { useEffect, useRef, useState } from "react"
import cssTextFcDaygrid from "data-text:@fullcalendar/daygrid/main.css"
import cssTextFcCommon from "data-text:@fullcalendar/common/main.css"
import cssTextFcTimegrid from "data-text:@fullcalendar/timegrid/main.css"
import cssTextGlobals from "data-text:~styles/globals.css"
import {
ChakraProvider,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalOverlay
} from "@chakra-ui/react"
import createCache from "@emotion/cache"
import { CacheProvider } from "@emotion/react"
export const config = {
matches: ["https://mail.google.com/mail/*"]
}
const styleElement = document.createElement("style")
const styleCache = createCache({
key: "plasmo-emotion-cache-modal",
prepend: true,
container: styleElement
})
styleCache.sheet.insert(cssTextFcTimegrid)
styleCache.sheet.insert(cssTextFcCommon)
styleCache.sheet.insert(cssTextFcDaygrid)
styleCache.sheet.insert(cssTextGlobals)
export const getStyle = () => styleElement
const container = document.createElement("div")
const shadowHost = document.createElement("div")
const shadowRoot = shadowHost.attachShadow({ mode: "closed" })
document.body.insertAdjacentElement("beforebegin", shadowHost)
shadowRoot.appendChild(getStyle())
shadowRoot.appendChild(container)
export const getRootContainer = () => {
return container
}
@oliveiracdz
Copy link

Hi there, Austin!

Did you manage Chakra UI Modals in your Web Extension?
My modals does not open within shadow host. Any tips?

Thank you!

@caelinsutch
Copy link

Commenting to follow this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment