reagent

2023-03-28T02:33:02.151149Z

Are there any best practices regarding CSS? I used to use CSS modules in React, but that smells of syntax and we don't like syntax in CLJ, do we šŸ™‚ ? So then what? Inline styles and for more advanced things like media queries use https://github.com/noprompt/garden? I'd love to know what you guys are using, thanks.

superstructor 2023-03-31T02:16:12.614159Z

@hifumi123 Re > the DSLs are never complete; garden, cljss, shadow-css, etc. are all leaky abstractions that break down the moment you want media queries, keyframes, font faces, etc. At least for garden, this is a lack of documentation, not feature-set. You can do all the things in CSS in Garden but I've found it poorly documented how to do those things.

superstructor 2023-03-31T02:19:56.217089Z

e.g. defkeyframes in https://github.com/noprompt/garden/blob/master/src/garden/def.clj#L97 to do keyframes

2023-03-28T02:36:10.433339Z

https://github.com/clj-commons/cljss

hifumi123 2023-03-28T02:40:11.861469Z

I actually dislike CSS-in-CLJS for two reasons: 1. the DSLs are never complete; garden, cljss, shadow-css, etc. are all leaky abstractions that break down the moment you want media queries, keyframes, font faces, etc. 2. solutions like garden work by compiling to CSS at run-time — i dont want custom CSS solutions to provide additional runtime overhead

hifumi123 2023-03-28T02:40:30.384439Z

My projects tend to use Sass instead. You can modularize it in the same way as CSS modules, and you still get live reloading with shadow-cljs

šŸ‘† 2
hifumi123 2023-03-28T02:42:40.868619Z

If you’re fine with adding webpack to your project, then you can ā€œimportā€ CSS files and possibly get CSS modules in your CLJS project

2023-03-28T02:51:29.339699Z

Interesting, I haven't expected Sass to be on the list šŸ™‚

2023-03-28T02:51:37.551399Z

Thanks @hifumi123

hifumi123 2023-03-28T02:59:35.370719Z

Np. Note that you don’t have to use Sass. Again, using webpack, you should be able to ā€œimportā€ CSS files and use CSS modules just like in vanilla JS. You can go down the Garden route but have component-local styling, check out Herb

hifumi123 2023-03-28T03:00:04.514019Z

im just not a big fan of CSS-in-CLJS (or even CSS-in-JS solutions like Emotion, styled-components, etc.)

2023-03-28T03:05:07.210409Z

https://github.com/roosta/herb has been archived

hifumi123 2023-03-28T03:05:52.744089Z

Oh well. Guess it’s not an option then

2023-03-28T03:05:56.344399Z

I think I'm going to look for CSS components or something akin to them. Inline styling is a good start, but one quickly runs into limitations and global styles are bleh.

hifumi123 2023-03-28T03:06:47.916559Z

Definitely check out Sass modules if you want/can — there is a built-in module system and mixins, variables, etc. do not have to be placed in a global registry at all

hifumi123 2023-03-28T03:07:26.216539Z

But if you want CSS modules, then you’ll need to figure out how to set up webpack with shadow-cljs. It isn’t too hard, but it’s a lot of more setup compared to setting up Sass

tatut 2023-03-28T04:57:38.216499Z

You can use tailwind if you like the utility class approach, and enhance that with plugins to get more component-y approach (like daisyui)

p-himik 2023-03-28T08:52:30.244549Z

> https://github.com/roosta/herb has been archived > > Oh well. Guess it’s not an option then Why not? There are quite a few archived CLJ[S] libraries that are archived only because they're complete. There are no [important] issues, there are no features that are in the scope of the project. Can't say for sure whether it's the case for Herb, but at least there are no open issues at all.

hifumi123 2023-03-28T08:53:54.277829Z

I’ve been so accustomed to hearing this excuse from the Common Lisp community that I simply disagree with it out of principle. Many of these ā€œfinishedā€ libraries often have bugs, so are they really finished?

hifumi123 2023-03-28T08:54:23.069329Z

While it may be true for extremely simple libraries (e.g. wscljs), I’m not sure if something at the complexity of Herb is exactly ever complete or free of bugs

p-himik 2023-03-28T08:55:32.898229Z

Perhaps it's more true in Clojure community then. :) I have most definitely seen stable libraries without any reasonable issues that haven't received any updates in years.

hifumi123 2023-03-28T08:55:53.763129Z

Or at the very least, assuming Herb is a complete library, I do not feel confident recommending it to users simply because someone will need to fork it and maintain that, but nobody has done so. And when users inevitably run into a bug with the library, well, it is archived, so their only choice is ā€œfork it and possibly maintain it tooā€. A tough sell IMO.

hifumi123 2023-03-28T08:56:34.364329Z

Unfortunately I forgot the name of some tooling around Garden specifically for ā€œmodularizing itā€ and introduce hot reloading with it. Otherwise I’d recommend it over Herb.

2023-03-28T13:46:46.347559Z

@tatut personally I found Tailwind CSS's approach appalling. It might be solution for some, I'll stay away. Anyway it still wouldn't solve the need for a:hover, media queries etc.

🤷 2
2023-03-28T13:47:57.529539Z

@hifumi123 I'm with you on that one. To me if it's archived that's a bad sign. May have no open issues, well I don't think archived repos can take new issues!

tatut 2023-03-28T13:47:58.340299Z

there is no ā€œcorrectā€ answer on how to do CSS, only different tradeoffs

ā¬†ļø 1
tatut 2023-03-28T13:49:03.943789Z

https://github.com/Jarzka/stylefy is in the same vein as herb

šŸ‘ 1
Tom H. 2023-03-29T01:37:06.199509Z

@jakub.stastny.pt_serv not looking to convince you of Tailwind’s approach but I believe it does support pseudo-classes, media queries etc. https://tailwindcss.com/docs/hover-focus-and-other-states

2023-03-29T10:29:50.758359Z

@tomisme I didn't know that. Still don't like it at all, but new thing learnt.

2023-04-01T23:13:27.281729Z

I'll give you guys an update on this, in case any of you find this useful: I end up not using any of the CLJS space tools nor CSS modules. We started using Joy UI from MUI and its CSS capabilities are the most powerful thing of it (and something you can't get rid of even if you wanted). The styling solution is in fact defined in MUI system which Joy UI is using. Now me personally, I'm a bit of a purist and would have preferred something like CSS modules. With that said the approach these libraries take is very powerful and it is the future of the web apps. If your app isn't as heavy as this (we have a lot of spreadsheets that have to behave like spreadsheets, not just a plain HTML table, so we're going full in on heavy JS), you can get by just fine with CSS modules, but if you do have a heavy JS app, the approach take by those makes a lot of sense. For me it's a new thing, well I was out of programming for the past 2 years, the world has moved on clearly. https://mui.com/joy-ui/customization/approaches/

šŸ‘ 1
hifumi123 2023-04-02T00:00:22.115039Z

I use a mix of both sx prop and Sass in my app using Material UI 😁 I agree the sx prop is amazing. You can define a single primary color for a button and it computes the tints and shades for each button state for you. I will note that the sx prop is one of the slowest options, so do not use it too much https://mui.com/system/getting-started/usage/#performance-tradeoffs

hifumi123 2023-04-02T00:03:04.257019Z

Of course, the "real world" is much more blurry: these benchmarks render 1,000 components. If you need to render large amounts of data, you should use react-virtualized and avoiding rendering everything simultaneously

šŸ‘ 1
2023-04-02T00:05:08.567149Z

Yeah. Esp. don't js->clj the fucking theme in the callbacks šŸ˜‚ It's awfully huge.

2023-04-02T00:07:13.585279Z

It's a lot to learn with MUI/Joy UI. Not like I'd need more, I'm already new to CLJ, CLJS, Reagent & hiccup, Emacs, Org-mode/org-babel/literary programming. I spent the past few days in MUI system/Joy UI documentation trying to understand what's going on and how it translates into CLJS.

2023-03-28T13:50:58.380449Z

Just wanted to check: React 18 isn't supported or is it? I don't particularly care, I don't even know what it contains, but I'm getting this annoying message:

react-dom.development.js:87 Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.

rolt 2023-03-28T14:15:35.318069Z

experiment support, you can use reagent.dom.client/createRoot` if you want to try it out and give feedback

rolt 2023-03-28T14:16:00.293159Z

if you don't want the warning, i guess use react 17 in your dependencies instead of 18

2023-03-28T14:16:50.109849Z

Thanks @rolthiolliere, I'll give it a go.