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

Check CSS syntax at compile time #3

Open
lukidoescode opened this issue Mar 18, 2020 · 3 comments
Open

Check CSS syntax at compile time #3

lukidoescode opened this issue Mar 18, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@lukidoescode
Copy link
Owner

It would be a neat feature to be informed of Syntax errors in the CSS at compile time.

@lukidoescode lukidoescode added the enhancement New feature or request label Mar 18, 2020
@thedodd
Copy link

thedodd commented Jul 13, 2020

Yea, I think compile time verification is the feature which would get me on board with using this project. Great work so far. Stoked to see this project is still making headway.

@cakekindel
Copy link

Howdy, here's some strawman syntax inspired by my own brain and rsx

use css_in_rust::{Px, Color, css};

let color: Color = Color::Keyword::Red.into();
let width: Px = 100.into();

let style = css! {
    // interpolate variables in rule assignment
    background-color: {color};

    .nested {
        background-color: blue;
        // not necessary, but slightly more ergonomic
        // shorthand for when variable + rule names the same
        {width}
    }
};
original (expand)
let style = match css_in_rust::Style::create(
    "Component", // The class prefix
    // The actual css
    r#"
    background-color: red;

    .nested {
        background-color: blue;
        width: 100px
    }"#,
) {
    Ok(style) => style,
    Err(error) => {
        panic!("An error occured while creating the style: {}", error);
    }
};

@cakekindel
Copy link

I'm probably available to help implement this as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants