Skip to content

Update to yew 0.21 and material-web-3#49

Open
constructableconcepts wants to merge 14 commits intoranile:material-3from
constructableconcepts:update-yew-0.21
Open

Update to yew 0.21 and material-web-3#49
constructableconcepts wants to merge 14 commits intoranile:material-3from
constructableconcepts:update-yew-0.21

Conversation

@constructableconcepts
Copy link

@constructableconcepts constructableconcepts commented Sep 25, 2025

This updates the package to support yew 0.21.0

google-labs-jules bot and others added 14 commits September 23, 2025 09:07
This commit updates the `material-yew` framework to Yew version 0.21.

The main changes involve:
- Updating the `yew` and `yew-router` dependencies in `Cargo.toml`.
- Refactoring all components to align with the new property and attribute handling in Yew 0.21.
- Replacing the usage of `js_sys::JsValue` for passing props with direct passing of Rust types.
- Using attributes instead of properties for most custom element properties.
- Handling boolean attributes with the `.then(|| AttrValue::from(""))` pattern.
- Removing the `use_effect_with` hook for module imports and calling the `import_material_web_module!` macro directly.

Due to limitations in the execution environment, I was unable to fully test the changes by running the `usages` example application. The `trunk` build tool could not be installed. However, both the `material-yew` library and the `usages` application compile successfully.

Some complex properties (`form`, `labels`, `anchor_element`, etc.) and custom event handlers have been temporarily commented out to allow the project to compile. These will need to be addressed in a future commit.
This commit updates the framework to Yew v0.21.

The migration involved several key changes:
- Updated the `yew` and `yew-router` dependencies to `0.21` and `0.18` respectively.
- Refactored all components to use the new Yew 0.21 property syntax. Standard attributes are passed directly, and boolean attributes are handled by making them present or absent.
- Implemented a new pattern for handling custom DOM events (e.g., `onclosing` in `md-menu`). This pattern uses a `NodeRef` and a `use_effect_with` hook to imperatively add and remove event listeners on the underlying web component.
- Implemented a new pattern for setting complex JavaScript properties (e.g., `form` on `md-button`). This also uses a `NodeRef` and a `use_effect_with` hook to set the property directly on the DOM node using `js_sys::Reflect::set`.
- The `usages` example has been configured to build with `wasm-pack`.

All components have been updated to be compatible with the new APIs, and the project now successfully compiles with Yew 0.21.
This commit updates the framework to Yew v0.21.

The migration involved several key changes:
- Updated the `yew` and `yew-router` dependencies to `0.21` and `0.18` respectively.
- Refactored all components to use the new Yew 0.21 property syntax. Standard attributes are passed directly, and boolean attributes are handled by making them present or absent.
- Implemented a new pattern for handling custom DOM events (e.g., `onclosing` in `md-menu`). This pattern uses a `NodeRef` and a `use_effect_with` hook to imperatively add and remove event listeners on the underlying web component.
- Implemented a new pattern for setting complex JavaScript properties (e.g., `form` on `md-button`). This also uses a `NodeRef` and a `use_effect_with` hook to set the property directly on the DOM node using `js_sys::Reflect::set`.
- The `usages` example has been configured to build with `wasm-pack`.

All components have been updated to be compatible with the new APIs, and the project now successfully compiles with Yew 0.21.
This commit updates the framework to Yew v0.21.

The migration involved several key changes:
- Updated the `yew` and `yew-router` dependencies to `0.21` and `0.18` respectively.
- Refactored all components to use the new Yew 0.21 property syntax. Standard attributes are passed directly, and boolean attributes are handled by making them present or absent.
- Implemented a new pattern for handling custom DOM events (e.g., `onclosing` in `md-menu`). This pattern uses a `NodeRef` and a `use_effect_with` hook to imperatively add and remove event listeners on the underlying web component.
- Implemented a new pattern for setting complex JavaScript properties (e.g., `form` on `md-button`). This also uses a `NodeRef` and a `use_effect_with` hook to set the property directly on the DOM node using `js_sys::Reflect::set`.
- The `usages` example has been configured to build with `wasm-pack`.

All components have been updated to be compatible with the new APIs, and the project now successfully compiles with Yew 0.21.
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

Successfully merging this pull request may close these issues.

1 participant