diff.rs
diff.rs copied to clipboard
Regularize CSS
Not sure if this is good style, but I like to separate the tailwind component classes from the Rust code.
Some rules:
- all views should have a wrapping container with id
<name>-view(or similar) - all components should have an appropriate
classwith their name, including sub-components - CSS should be used with
@applyto separate tailwind CSS from components (declutter the code).
For example, instead of:
#[function_component]
fn MyComponent() -> Html {
html! {
<div class="flex flex-row flex-nowrap items-center">
...
</div>
}
}
I'd write it like this:
#[function_component]
fn MyComponent() -> Html {
html! {
<div class="my-component">
...
</div>
}
}
along with:
@layer components {
.my-component {
@apply flex flex-row flex-nowrap items-center;
}
}