abishekatp / stylers

Fully compile time scoped CSS for Leptos components
MIT License
139 stars 13 forks source link

`style_sheet!` macro not working. #56

Open tkr-sh opened 1 year ago

tkr-sh commented 1 year ago

I can't get style_sheet! macro to work. Step to reproduce:

cargo leptos new --git https://github.com/leptos-rs/start

Create a file src/test.css with the content:

h1 {
    color: red !important;
}

And in HomePage add:

  let class_name = style_sheet!("./src/test.css");
  ...
  view! { class = class_name,
     ...
  }

The expected result is the text being red, but no style is applied no matter what.

If you can not reproduce, I can make a Dockerfile of it.

abishekatp commented 1 year ago

can you please push the sample code on github and share the link?

Garkatron commented 9 months ago

can you please push the sample code on github and share the link?

I have the same error, I can give code:

use leptos::*;
use leptos_meta::Stylesheet;
use stylers::style_sheet;

#[component]
fn App() -> impl IntoView {
    let class_name = style_sheet!("./css/styles2.css");

    view! {class = class_name,
        <div id="pepe">
            <h4>MainContainer</h4>
            <div>
                <h4>ContactsSidebar</h4>

            </div>
            <div>
                <h4>ChatHeader</h4>

            </div>
            <div>
                <h4>ChatContainer</h4>
                <div>
                    <h5>Name</h5>
                    <p>Message</p>
                    <span>Date</span>
                </div>
            </div>

        </div>
    }
}

fn main() {
    mount_to_body(|| {
        view! {
            <App />
        }
    })
}

Error

error: Expected to read file
 --> web-app\src\main.rs:6:22
  |
6 |     let class_name = style_sheet!("./css/styles2.css");
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `style_sheet` (in Nightly builds, run with -Z macro-backtrace for more info)
Garkatron commented 9 months ago

More beautiful image