diff.rs icon indicating copy to clipboard operation
diff.rs copied to clipboard

Regularize CSS

Open xfbs opened this issue 1 year ago • 0 comments

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 class with their name, including sub-components
  • CSS should be used with @apply to 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;
    }
}

xfbs avatar Oct 12 '24 17:10 xfbs