Fork me on GitHub
#clojurescript
<
2021-10-25
>
maverick09:10:16

How can I add tooltip for options in select?

p-himik09:10:39

You cannot do that with the default select. Perhaps some libraries might offer that functionality.

maverick09:10:13

Thanks @U2FRKM4TW I got it working.

p-himik09:10:01

How exactly, if you don't mind sharing?

p-himik09:10:39

I double checked it and seems like you can add the title attribute to the option tag. It used to be the case not so long ago that some browsers didn't show it at all - perhaps now the situation is different.

maverick10:10:03

Yes, I am using bootstrap so I used data-toggle="tooltip" with title . It worked

πŸ‘ 1
Ian Fernandez13:10:01

how can I use cljs.repl/source-fn at cljs repl time to fetch a string for a var definition?

dpsutton13:10:52

% clojure -A:cljs -M -m cljs.main -re node -r
ClojureScript 1.10.773
cljs.user=> (source inc)
(defn inc
  "Returns a number one greater than num."
  [x] (cljs.core/+ x 1))
nil
cljs.user=>

Ian Fernandez13:10:52

I want to not return nil

Ian Fernandez13:10:01

to have the string for the function πŸ™‚

dpsutton13:10:18

(with-out-str (source inc))
"(defn inc\n  \"Returns a number one greater than num.\"\n  [x] (cljs.core/+ x 1))\n"

dpsutton13:10:48

look at the source of source with (source source). Notice it is calling println. Just make your own source function that just returns the string

πŸ‘ 1
sun-one19:10:45

I'm getting an error on a production cljs build Uncaught TypeError: goog.global.setTimeout is not a function From looking at goog.global it's set with this which by default tends to be the window (thus assigning setTimeout to window.setTimeout). When I'm building a production build it's undefined (the cause I believe is that webpack is wrapping it's js code with (()=>{var __webpack_modules__= therefore this is no longer the window which violates the expectation in a lib I'm using that goog.global will have setTimeout. Is their a special way to handle closure lib during webpack bundling?

sun-one19:10:18

Ah perhaps it's this that I'm looking for

sun-one19:10:28

Yep that worked, I somehow skipped over this when I was reading compiler options ...

bad_ash19:10:29

hi. is there anything similar to https://github.com/mdgriffith/elm-ui for clojurescript?

😨 1
lilactown19:10:09

I would refer to any of the React libraries that cover this kind of use case

lilactown19:10:00

that being said, i am suspicious of anything that claims to abstract HTML and CSS for you. in almost all cases i'd rather have easy access to the underlying primitives

bad_ash19:10:53

thanks. yeah, i'm not sure about how it will work out in practice. but ideally i'm all for abstracting away from html and css

lilactown20:10:27

I used dreamweaver quite a bit to build websites, years ago, and burned myself on things that attempt to abstract HTML and CSS from me while building anything for the web πŸ˜›

phronmophobic20:10:30

There's also https://github.com/lelandrichardson/react-primitives which was inspired by React Native Web

phronmophobic20:10:04

If you can compile ruby, clojure, go, scala, c, typescript, etc. to javascript, I don't see why it shouldn't be possible to compile some sane graphics and event model to html+css

lilactown20:10:58

depends on the graphics and event model πŸ™‚

phronmophobic20:10:18

I'm not sure it does

lilactown20:10:56

I guess I'm implicitly adding in to your sentence that the HTML & CSS compiled to would be acceptable to deploy

lilactown20:10:06

i.e. is accessible, efficient, etc.

phronmophobic20:10:19

I think it could be more accessible and efficient.

lilactown20:10:20

I would love to see it!

lilactown20:10:43

I just don't think that the HTML, CSS and event system in browsers is well formed enough to not have to make hard tradeoffs

lilactown20:10:16

but I could be wrong. I'm only speaking to why I don't think I want to try πŸ˜›

phronmophobic20:10:06

I do think it would be a lot of work, but I think it makes sense long term.

lilactown20:10:47

certainly React is a different model than "traditional" HTML and CSS.

p-himik20:10:12

We compile CLJS to JS. And yet, we use interop all the time. It's not abstracted away, it's not hidden - it's all there. Just a . away.

phronmophobic20:10:34

React is certainly an improvement over what I used before (which was jquery and that was an improvement over the options before)

phronmophobic20:10:56

I still think there's a lot of room for improvement.

lilactown20:10:04

I think that's greatly helped by the fact that the semantic differences between ClojureScript and JS are very few

lilactown20:10:32

it's easy to just pepper in some interop where it's needed

lilactown20:10:19

interoping between React and imperative DOM manipulation is harder IME because the models are more different

lilactown20:10:36

in Elm, the language and compiler fights you at every step if you want to drop down to JS

p-himik20:10:46

Yeah, CLJS makes deliberate choices to not stray too far from the platform. And if a web UI framework decides to go way too far from the underlying HTML/CSS/JS, the abstraction becomes either incredibly leaky or incredibly restrictive.

βž• 1
lilactown20:10:53

I like sitting at about the level of abstraction that CLJS and React does, personally

βž• 1
phronmophobic20:10:39

10 years ago, using a compile to JS language seemed crazy, but there's a ton of options now. I would bet that compile to html/css (or potentially canvas) will be accepted as normal 10 years from now. 🀞

phronmophobic20:10:12

> And if a web UI framework decides to go way too far from the underlying HTML/CSS/JS, the abstraction becomes either incredibly leaky or incredibly restrictive. I think that's an argument for why we shouldn't be using html/css as UI primitives in the first place.

p-himik20:10:18

Alas, that ship has sailed. Will be quite a while till something new arrives and replaces it.

πŸ΄β€β˜ οΈ 1
p-himik20:10:23

Oh, and that ship keeps on sailing with full mast. :) And is growing by the minute. Like Katamari Damacy of the software world.

2
phronmophobic20:10:15

I think it feels like it going fast, but it's a giant, slow, rudderless, leaky boat with no captain.

lilactown20:10:41

would be great to have something other than a web browser to deliver applications remotely

leif23:10:12

I was looking at the cljs-ajax library (https://github.com/JulianBirch/cljs-ajax) and in its GET/`POST` examples it seems to be using GET synchronously. For example ((GET "/hello"), is this correct?

lilactown00:10:09

they are asynchronous. the results are not returned, but rather passed to the handler function on completion

lilactown00:10:31

the responses written in comments are what the handler logs to the console

leif00:10:28

So, if you don't provide a :handler function, does it just grab whatever function is called handler in your current namespace and use that?

lilactown00:10:55

I think the examples are not fully fleshed out. if you don’t specify the :handler fn, then it will simply fire and forget it once complete

leif00:10:36

Ah, okay, that makes more sense.

leif23:10:44

And if that is correct, what would be the best way to set up the library to actually work asynchronously?