Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] How to use tailwindcss style for suspended elements in custom components in contentui? #951

Open
2 of 3 tasks
sshallow opened this issue Apr 19, 2024 · 0 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@sshallow
Copy link

sshallow commented Apr 19, 2024

What happened?

I have successfully used tailwindcss with popup and contentui. But when I use a custom tsx component, which contains suspended elements, such as popover, selector drop-down box, etc., tailwindcss cannot be applied to these suspended elements. I inspected the web elements and found that the suspended elements were outside of plasmo-csui. How to make these custom components maintain the tailwindcss style when there are floating elements.

The popover in the popup can be displayed correctly,
image

In contentui, the surface element can be displayed correctly, but the floating element popover contained inside cannot be displayed correctly

image

code:

import cssText from "data-text:~style.css"
import type {PlasmoCSConfig, PlasmoGetInlineAnchor} from "plasmo"
import {persistor, store} from "~store";
import {Provider} from "react-redux"
import {PersistGate} from "@plasmohq/redux-persist/integration/react";
import {ATMSpaceSwitcher} from "~features/space-switcher";
import {ThemeProvider} from "~components/theme-provider";
import {NotionStatus} from "~features/notion/notion-status";
import {ATMSwitch} from "~features/switch";
import {ATMPopover} from "~features/popover";
import {CircleHelp} from "lucide-react";

export const getStyle = () => {
    const style = document.createElement("style")
    style.textContent = cssText.replaceAll(':root', ':host(plasmo-csui)');
    return style
}
export const config: PlasmoCSConfig = {
    matches: ["*://*.bing.com/*"]
}

export const getInlineAnchor: PlasmoGetInlineAnchor = async () => ({
    element: document.querySelector("#b_context"),
    insertPosition: "afterbegin"
})

const PlasmoCSUI = () => {

    const handleSwitchChange = (checked) => {
        console.log("Switch checked:", checked)
        // 在这里执行其他操作
    }

    return (
        <ThemeProvider
            attribute="class"
            defaultTheme="light"
            enableSystem
            disableTransitionOnChange>
            <Provider store={store}>
                <PersistGate loading={null} persistor={persistor}>
                    <div className="pb-8 w-full">
                    <span className="text-red-700 text-3xl">
                    AtMyNotion

                    </span>
                        <NotionStatus/>

                        <ATMSpaceSwitcher/>
                        <ATMSwitch
                            id="Advanced-search-mode"
                            label="Search with Filters"
                            onChange={handleSwitchChange}>
                            <ATMPopover
                                tooltipContent={
                                    "Apply advanced filters and sorting on the search page."
                                }>
                                <CircleHelp className="h-4 w-4 text-slate-400"/>
                            </ATMPopover>
                        </ATMSwitch>
                    </div>
                </PersistGate>
            </Provider>
        </ThemeProvider>

    )
}

export default PlasmoCSUI

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

No response

Relevant log output

No response

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@sshallow sshallow added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant