ranile / material-yew

Yew wrapper for Material Web Components
https://material-yew.rm.rs
Apache License 2.0
225 stars 35 forks source link

Material UI doesn't work as provided in documentation #47

Open MadMed677 opened 1 week ago

MadMed677 commented 1 week ago

Hello @ranile! I've faced with the problem and maybe you could help me to understand how to fix it.

Problem description

Step 1

When I'm trying to use material yew based on documentation page

use material_yew::MatButton;
use yew::html;

html! {
    <MatButton label="Click me!" />
};

I've faced with an error: unresolved importmaterial_yew::MatButton the item is gated behind thebuttonfeature

Step 2

If I add button feature

material-yew = { version = "0.3.0", features = ["button"] }

I see the following error:

the trait bound `material_yew::MatButton: yew::Component` is not satisfied
the trait `yew::Component` is implemented for `yew::ContextProvider<T>`
required for `material_yew::MatButton` to implement `yew::BaseComponent`

I guess this is because I'm using a new version of yew which is 0.21.0 and the traits has been changed since last material-yew publish.

ranile commented 1 week ago

@MadMed677 yes, the published version is quite old. you should take a dependency from git, which should be fine

MadMed677 commented 1 week ago

Maybe I did something wrong but even if I fetch yew from Git and Material Yew from Git the result error will be the same

First option

Cargo.toml

[dependencies]
material-yew = { git = "https://github.com/ranile/material-yew", branch="material-3" }
web-sys = "0.3.69"
yew = { git = "https://github.com/yewstack/yew", features = ["csr"] }

The error says that 32 times for every component:

cannot find function `__dummy_loader` in this scope
crate::import_material_web_module!("/md-web/radio.js")
   |         ------------------------------------------------------ in this macro invocation

Other options

All other implementation have the same problem

<MatButton label="Add" raised=true>{"Add one"}</MatButton>
   |              ^^^^^^^^^ the trait `yew::Component` is not implemented for `MatButton`, which is required by `MatButton: yew::BaseComponent`
ranile commented 1 week ago

@MadMed667 right, the git one gives you an error, I should've expected that. It can't find the modules

I suggest you clone the repo and then use a path dependency for now. You'll you invoke rollup yourself

cd build
npm install
npm run build

This should fix your JS files not available issue.

One good way of permanently solving this problem is having a build script that calls npm run build. I would be happy to take a look at any PRs for it. I used to include build files in the repo but in light of the XZ exploit that was found, I'm not really comfortable doing that and telling others to use it. It would be best if end users invoked rollup themselves to bundle the martial components this library uses