Both of them share the same CSS. Instead of creating and duplicating the same CSS files for each of them, I can create just one, in a separate mod file, then "re-export" it, so both of those components (in separated files) can reuse the same CSS.
// button/default.rs
use super::super::utils::{ButtonClassName, BUTTON_STYLE_SHEET};
pub static STYLE_SHEET: &str = BUTTON_STYLE_SHEET;
impl yew::Component for Button {
// ...
}
// button/icon.rs
use super::super::utils::{ButtonClassName, BUTTON_STYLE_SHEET};
pub static STYLE_SHEET: &str = BUTTON_STYLE_SHEET;
impl yew::Component for ButtonIcon {
// ...
}
This is best I could come up with possible solution to solve this case.
Please let me know what do you think, or if you have a better solution for my case.
What?
Allow reusability of the same CSS (hashed) across multiple UI components files.
How?
Add
pub
modifier to the structClassName
Why?
Example from my recent case:
I have the components:
<Button />
<ButtonIcon />
Both of them share the same CSS. Instead of creating and duplicating the same CSS files for each of them, I can create just one, in a separate mod file, then "re-export" it, so both of those components (in separated files) can reuse the same CSS.
Example
This is best I could come up with possible solution to solve this case. Please let me know what do you think, or if you have a better solution for my case.
Thanks! ❤️