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

The best way to handle style sheets in Miso application or component library #746

Open
functora opened this issue Oct 4, 2024 · 0 comments

Comments

@functora
Copy link

functora commented Oct 4, 2024

I would like to discuss the best way to handle style sheets in Miso application or component library. I think styles abstractions (whatever it is) should be:

  • Composable with library/application Haskell code.
  • Composable with each other.
  • More or less typed (optional).

At the moment I see couple of options, but they all are kinda bad:

  1. Using the standard external CSS file. The problems are:
  • I don't see the right way to export it as a part of the library (these are no css-sources in cabal, unlike js-sources)
  • CSS class names are just Text which should be the same across Haskell (class_) and CSS codebase. Hard to maintain and refactor. Prone to errors.
  1. Using inline <style> tags next to every small component. I think kinda bad idea, and I'm not sure how to scope styles locally to component this way. Not sure it is possible or easy (not an expert in CSS).
  2. Using style_ attribute functions and different variants of compositions of it. It's a bit better, but:
  • Can not define styles for pseudo-elements (::hover, ::before, ::after etc)
  • Can not define advanced CSS animations like @keyframes my-animation-name
  1. Doing some smart CSS code generation from some Haskell style sheet source (.hs files), exporting class names (functions, utilities) used in Miso lib/app codebase, but having additional Setup step for the app/lib which doing corresponding CSS file code generation somehow.
  • Kinda sounds hard to do (maybe not, idk).

If I did miss some documentation or cool advanced CSS examples in Miso, please let me know. Best regards!

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

No branches or pull requests

1 participant