Fork me on GitHub
#reagent
<
2018-07-31
>
Josh Horwitz01:07:19

What are everyones favorite ready to go CSS solutions for Reagent?

gadfly36101:07:10

@joshua.d.horwitz it is a big dependency, but if that isn't a concern then I like https://github.com/madvas/cljs-react-material-ui

gadfly36101:07:13

Also reached for this on a few projects https://github.com/gadfly361/soda-ash

gadfly36101:07:25

(That said, I think writing css from scratch with Garden is what I end up doing most and recommend that a lot)

Josh Horwitz01:07:51

Ok, I can try that. Admittidly , my css is not very strong

gadfly36101:07:03

Oh no worries, and as an aside, I will say that the material ui one (first link) looks particularly good on mobile :)

Josh Horwitz01:07:06

Thanks! I need to get better at css

lilactown02:07:55

we use emotion.sh at work and it’s pretty great

lilactown02:07:28

any css-in-js solution is 👌

lilactown02:07:47

anything that uses css loaders is 🙅

lilactown14:07:21

It's coupled to webpack or some other specific build tool

lilactown14:07:32

CSS-in-JS is build-tool agnostic

p-himik14:07:24

Ah, I misunderstood "css loader". 🙂

p-himik14:07:47

Webpack now is almost a de-facto standard.

lilactown14:07:50

yeah but I don't want none 😛

lilactown14:07:39

I think that CSS-in-JS is more portable. between languages, frameworks, build tools. you shouldn't curse people with webpack if it's not already part of their stack

grav05:07:54

CSS-In-JS rules. But damn do I miss media queries

p-himik05:07:49

CLJSS says it supports media queries, but I did not try it. So does Stylefy and Garden.

lilactown14:07:22

media queries work in emotion 😉

grav19:07:53

The challenge in my case is media-queries server-side. The server has no explicit knowledge of the client’s window dimensions etc. There’s a good thread about it here: https://github.com/reactjs/react-future/issues/8 In my case, I don’t even have any dynamism on the server (eg for reponding to the user agent), since it’s just html stored in an s3 bucket.

lilactown19:07:01

if you use an actual CSS-in-Js library, instead of inline styles, you can use media queries

lilactown19:07:26

we do server rendering of emotion styles and they just get injected as a <style> tag on the page, media queries and all

grav20:07:22

Ah, ok, I need to look into that

grav20:07:14

Still magic to me - how will the server know what to inject? How does it know what device it responds to?

pesterhazy06:07:59

Can you all explain why css-in-js is desirable?

lilactown14:07:42

1. Module scoped CSS written close to the component that uses it 2. Write styling in a language I'm already familiar with (JS or CLJS vs Sass or Less) 3. Isn't coupled to a specific build tool pipeline.

kennytilton13:07:02

@joshua.d.horwitz “I need to get better at CSS” sounds like “I need to get better at driving in Boston.” You may not be what needs to improve. 🙂

kennytilton13:07:42

Regarding confusion over form-N components, I remember being flabbergasted by this bit of doc:

Note: In the example above, hello-component might just as well have been called ...with parenthesis instead of square brackets. ... More advanced components though (see below) must be called with square brackets.
Really?

4
p-himik13:07:31

What surprises you? 🙂

justinlee15:07:52

That is terrible advice and I argued for its removal. There is no reason whatsoever to suggest that users call components using function invocation

justinlee15:07:03

It is true that it will sometimes work but there is never a reason to do it and if you get in the habit of mixing in direct function invocations the code will not only be confusing but will be bug prone

p-himik16:07:05

Maybe it's just a poor choice of words? I always thought of the phrase above not as an advice but as caveat emptor, or something like "that fact that it works doesn't mean you should use it".

justinlee16:07:05

The advice should be “don’t call components with parenthesis” and doesn’t need a whole confusing paragraph.

kennytilton18:07:59

No, no, no! AAAARGH! 🙂

kennytilton18:07:03

Wait, I need a better emoji….🤯 I guess emojis cannot have hands so there is no :pulling-hair-out

kennytilton18:07:39

Do I have to explain why differentiating to wholly different software behaviors by their punctuation is almost guaranteed to prevent noobs fron learning what is going on?

kennytilton18:07:47

“one way to make sure you have no duplicates is to use an octothorpe before the braces of your literal”

kennytilton18:07:57

“if the two sides of the equation are separated by a slice of pizza, reverse the direction of the pizza slice when multiplying by a negative”

justinlee18:07:32

well what language doesn’t differentiate behavior based on punctuation? () [] and {} are all different in clojure. you need to differentiate, i just think that you need to give clear advice on what to do because reagent’s treatment of vectors is not obvious to the beginner

kennytilton19:07:47

Why did you say “vector” instead of “square brackets”? The punctuation we deal with on page one, from then on we talk about vectors. In the case of Reagent, we should not even talk about vectors, we should talk about immediate evaluation vs deferred. Form-N is OK I guess as a shorthand, as long as the shorthand is not defined according to punctuation.

justinlee20:07:47

I don’t really understand. They are hiccup vectors.

kennytilton20:07:02

Wait. Is that how folks actually understand form-Ns? “with parentheses” or “with brackets”? Maybe I am too close to the domain and am assuming too much. (My framework has a somewhat similar issue that bites me when I happen not to wrap child elements in the necessary syntax.)

kennytilton20:07:38

I mean (foo) calls foo now and evaluates to what foo returns. [foo] is just a literal vector holding a reference to the function foo. The Reagent framework will call the contents of the vector sometime later.

justinlee21:07:32

yes exactly. if you call the function, then that function just gets evaluated as a function. if you place the symbol in the first slot of the hiccup vector, then reagent will create a react component and will only invoke the render function when needed (i.e. when either the function arguments change or a watched ratom is updated)

justinlee21:07:06

so we should be telling people always to return a vector when referencing another component. no [] no component

rnagpal14:07:23

I was going through the source code and didnt get how temp-reaction is set/used

rnagpal14:07:08

When I add logs statements I see temp-reaction being set as the ratom which the component uses

rnagpal14:07:23

but dont see the code where temp-reaction is set

rnagpal14:07:53

Also what does (make-reaction nil) mean ?

rnagpal14:07:02

How is it used/useful ?

lilactown14:07:24

`temp-reaction` is set in the fn below it run-in-reaction I see, not sure where it gets set to the ratom yet