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

Help with Portfonio + Mantine CSS #21

Closed
rafaeldelboni opened this issue Jan 26, 2024 · 3 comments
Closed

Help with Portfonio + Mantine CSS #21

rafaeldelboni opened this issue Jan 26, 2024 · 3 comments

Comments

@rafaeldelboni
Copy link

rafaeldelboni commented Jan 26, 2024

Hey, first of all, thanks for this tool it will help a lot and is a missing (updated) piece in the cljs ecosystem.

I'm trying to set it up to work with mantine component library, but It uses a wrapper component called MantineProvider to handle themes and CSS stuff.

And even wrapping my component with it on the defscene, it looks like is not able to do all the CSS changes it does in a normal app.

(defscene mantine-button
  ($ MantineProvider {:theme c/theme}
     ($ c/button {:text "My Button"
                  :on-click #(js/console.log "clicked!")
                  :color "blue"})))

Normal app:
image

Portfolio:
image

Other than that all components, apart from the visuals are working as they should.

I've made a sample repo to help you to see this happening:
https://github.com/rafaeldelboni/helix-jsdom-portfolio-mantine

My question is, is there a way to declare a root component to defscene run all components inside of it? Because this bug can happen in a normal app, if you add mantine css, but do not use the MantineProvider, so looks like the MantineProvider in the defscene is conflicting with some wrap portfolio may be doing.

@cjohansen
Copy link
Owner

You are probably running into Portfolio's by now most famous shortcoming. Portfolio assumes that components are free of side-effects, and calls the component function in one browser window, but renders the result into an iframed document. If your component either has side-effects during the component function call, or it uses document, those will happen in the wrong document.

There is a sketch for a fix here, I'm pretty sure it will fix your problem: #16

I'm a little behind in processing that PR, but will get to it shortly.

@vloth
Copy link

vloth commented Feb 5, 2024

I've looked a bit into this and made it work by adding a custom canvas with forced light theme
image
The component MantineProvider seems to be adding the data theme property to the html element as a side effect, which is important to apply the correct CSS variables.
It might be easier to understand by looking at the changeset: vloth/helix-jsdom-portfolio-mantine@e403538
I'm not entirely sure how the side effects are handled by portfolio, but the css classes seems to be applied correctly. I can see the html has the class light-mode.
I hope that helps troubleshooting ?

@rafaeldelboni
Copy link
Author

Thanks @vloth, that fixed the problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants