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

Having issues getting example code to work as expected #36

Open
simonsteer opened this issue Mar 3, 2023 · 0 comments
Open

Having issues getting example code to work as expected #36

simonsteer opened this issue Mar 3, 2023 · 0 comments

Comments

@simonsteer
Copy link

simonsteer commented Mar 3, 2023

Hello 👋 I'm trying to play around with the polyfill and am struggling to get the example paint module to work as expected. Hoping to get some clarity on where I'm going awry setting things up.

The site I'm working on is built with Remix, which is server-side rendered, so I can't get access to the window until after the initial mount. The way I've gotten around this is by using isomorphicLayoutEffect and node require to load in the polyfill prior to calling CSS.paintWorklet.addModule.

import { useIsomorphicLayoutEffect } from 'react-use'

export default function Index() {
  useIsomorphicLayoutEffect(() => {
    require('css-paint-polyfill')
    CSS.paintWorklet.addModule('worklets/paint/box')
  }, [])

  return (
    <div>
      <h1>Testing Houdini Polyfill</h1>
      <div
        style={{
          width: 500,
          height: 400,
          background: 'paint(box)',
          border: '1px solid blue',
        }}
      />
    </div>
  )
}

This seems to work fine; the network request fetching the module code succeeds:

Screen Shot 2023-03-03 at 12 50 45 PM

The custom elements are being injected after the document body:

Screen Shot 2023-03-03 at 1 18 26 PM

And inline styles are being walked after paint registration:

Screen Shot 2023-03-03 at 1 19 22 PM

However, the custom paint does not seem to apply to the div; it just renders as a rectangle with a blue border, as though I had never applied the custom paint style:

Screen Shot 2023-03-03 at 1 23 18 PM

I'm assuming there's something funky going on when it comes to writing the paint css rules to a stylesheet, but not entirely sure.

Browsers I've tested this locally on:

  • Safari 15.5 (17613.2.7.1.8)
  • Firefox 110.0.1 (64-bit)
  • Chrome 110.0.5481.177 (Official Build) (x86_64)

Minimal github repo where I can reproduce the issue:
https://github.com/simonsteer/remix-houdini-test

Thanks in advance to the contributors working on this awesome project! Very exciting stuff :)

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

1 participant