aleph.js icon indicating copy to clipboard operation
aleph.js copied to clipboard

Material-UI implementation

Open italodeandra opened this issue 5 years ago • 7 comments
trafficstars

Hi,

I'm currently trying to implement the usage of Material-UI.

Any component that I try to import and use throws me this error: TypeError: window.getComputedStyle is not a function. I checked the place where this error in thrown, and even though window exists, the getComputedStyle isn't defined. Maybe something related to SSR but I also tried disabling SSR and gave a totally different error.

Material-UI does work with SSR though. I have worked with Next.js and you can see an example here: mui-org/material-ui/blob/master/examples/nextjs

Any suggestions of what I could try?

Steps to reproduce

  1. Create a new project using CLI init command
  2. Add a Button to the index page:
import { Button } from "https://esm.sh/@material-ui/core";
<Button>Test</Button>
  1. Error TypeError: window.getComputedStyle is not a function is thrown

italodeandra avatar Nov 20 '20 02:11 italodeandra

https://github.com/alephjs/aleph.js/blob/master/project.ts#L597 here we can implement a virtual getComputedStyle function for SSR.

ije avatar Nov 20 '20 02:11 ije

@italodeandra can you share how/if you got this working?

SuperManfred avatar Mar 23 '21 05:03 SuperManfred

Hi @SuperManfred,

I dropped it. I ended up deciding on waiting for deno/aleph to become more mainstream before trying to implement something as I currently don't have time to contribute myself. Feel free to hijack my issue here or create another one yourself if you're going to keep researching further on this. It's a nice subject and I see there's more people interested based on the likes.

italodeandra avatar Mar 23 '21 07:03 italodeandra

@SuperManfred @italodeandra I will take a look at implementing support for MUI in the weekend (or maybe before).

noverby avatar Mar 23 '21 07:03 noverby

Thanks... I'm about at that point too. In discord people say got it working, and antd and semantic ui, but I can't get any of it working. Wait and see

SuperManfred avatar Mar 23 '21 09:03 SuperManfred

https://github.com/alephjs/aleph.js/blob/master/project.ts#L597 here we can implement a virtual getComputedStyle function for SSR.

@ije Link is broken 😮

vicasas avatar Mar 30 '21 10:03 vicasas

@SuperManfred You can disable SSR to experiment with alephjs:

// aleph.config.ts
export default (): Config => ({
  ssr: false
})

noverby avatar Mar 31 '21 15:03 noverby