abishekatp / stylers

Fully compile time scoped CSS for Leptos components
MIT License
135 stars 11 forks source link

css generated directory #22

Closed luoxiaozero closed 1 year ago

luoxiaozero commented 1 year ago

I have an application that uses melt-ui (leptos UI library), and melt-ui uses stylers, but the css files generated by stylers are in the melt-ui directory. I tried to solve it, but it didn't work.

luoxiaozero commented 1 year ago

Is there any solution

abishekatp commented 1 year ago

Yeah there is a solution,

For your use case: In your use case you want to export the components to other users. so you can't export separate css file for each component. I think you can use either style_str! or styel_sheet_str!. you can find code snippet in readme or detailed example in examples directory

luoxiaozero commented 1 year ago

I know the solution

  1. Repeated use of components results in multiple style {P_YX48$F~IKP}F1E`2II L
  2. style in the head. Create the component again to check if the head exists. There's going to be a runtime

It don't feel elegant

luoxiaozero commented 1 year ago

Ideally, the user would use that component and that component's css would be added to the main.css file, but this feels like a difficult feature to implement.

abishekatp commented 1 year ago

I am checking weather there is better way to do this. Please give me some time.

Edit: Can't we just attach global style element with some unique id. whenever user reuses the component we will just check whether style tag with that id exists or not, if not then add one style for that component.

luoxiaozero commented 1 year ago

ok

abishekatp commented 1 year ago

Since this problem is solvable using the above discussed approach I am closing this issue now.