Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manganis CSS Modules Support #3578

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DogeDark
Copy link
Member

@DogeDark DogeDark commented Jan 16, 2025

Adds a macro that generates a struct for type-safe, globally unique, classes and ids. This reuses the asset macro with a new AssetOption variant for CSS modules.

styles!(MY_CSS, STYLES, "/mycss.module.css");

#[component]
fn App() -> Element {
    rsx! {
        document::Link { rel: "stylesheet", href: MY_CSS }
        div {
            id: STYLES.goodbye,
            class: STYLES.hello,
            p { "This div's class is {STYLES.hello}" }
            p { "This div's id is {STYLES.goodbye}" }
        }
    }
}
/* mycss.module.css */
.hello {
  background-color: rgb(68, 75, 88);
  padding: 20px;
}

#goodbye {
  color: white;
}

@DogeDark DogeDark added enhancement New feature or request cli Related to the dioxus-cli program manganis Related to the manganis crate labels Jan 16, 2025
@DogeDark DogeDark added this to the 0.7.0 milestone Jan 16, 2025
@DogeDark
Copy link
Member Author

This is still more or less an experiment, but I created this PR to track it, as I believe it could be viable for 0.7 if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the dioxus-cli program enhancement New feature or request manganis Related to the manganis crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant