Fork me on GitHub
#clojurescript
<
2022-01-05
>
witek11:01:42

Hello. How can I access a custom value, defined in :compiler-options inside of (defmacro ...)? I got the tip, that it can be accessed througt &env , but I can not find it there. And I can not find any documentation on this.

thheller11:01:48

I answered this in #shadow-cljs?

witek11:01:06

I see. Sorry, I overlooked.

kennytilton13:01:27

I lay out in some detail here a problem I had getting a dependency automatically pulled from Clojars. https://clojurians.slack.com/archives/C6N245JGG/p1641343140421100 A manual clojure -P did the trick, but is there anything like leiningens ability to pull dependencies automagically with deps?

frozenlock16:01:39

Is there a trick to generate externs when the library is written in typescript? I tried http://jmmk.github.io/javascript-externs-generator/, but most of the externs are missing when comparing to the original "vanilla" JS version.

Noah Bogart16:01:42

Maybe compile the typescript into JavaScript and then run the generator on the dist folder?

thheller16:01:06

don't use externs generators. you only need externs for the stuff you actually use and for that its better to rely on externs inference and use some ^js hints where necessary

thheller16:01:42

externs generators generate way too much typically. no point in generating 1000 externs if you only use 2 things that would actually need them

frozenlock16:01:38

Alas, it's for packaging in cljsjs, so I need to provide the externs 😕

thheller17:01:40

that is not true. if you write a library and properly typehint where needed your own library code then no further externs should be needed at all

thheller17:01:26

oh wait .. ok this is only JS code no actual CLJS code? then externs would indeed be required

frozenlock17:01:46

Yes it's a JS library

ccann23:01:20

@U0ERZQ1K2 did you ever figure this out? I’m trying to do the same thing for the same library. I did find this generator https://jmmk.github.io/javascript-externs-generator/ but I’m not sure if it will work

frozenlock23:01:48

You might have missed it, but a few lines above I mentioned trying this exact generator 😉

frozenlock23:01:26

You can use my fork until it's processed into cljsjs https://github.com/cljsjs/packages/pull/2221

ccann23:01:27

thanks @U0ERZQ1K2 I’m also looking into using https://github.com/jgrodziski/keycloak-clojure with our python backend which uses Flask which uses Authlib OIDC.

diego.videco21:01:33

is there a way to tell if some data is a javascript entity (instead of a clojure entity), i.e. an object or an array vs a vector or a keyword?

p-himik22:01:59

And if you need to check just for plain JS objects and arrays, there are array? and object? .

raspasov11:01:49

I believe coll? should cover all cases of the built-in Clojure(Script) data structures, please correct me if I'm wrong.

p-himik11:01:38

Oh, seems like you're correct, nice!

👍 1
raspasov10:01:55

That being said, you mentioned keywords as well. Obviously coll? for a keyword would be false.

(coll? :a)
=> false

diego.videco23:01:08

Thanks @U051V5LLP, that's what I needed.

woohoo 1
emccue22:01:54

:<> is a react fragment. :> adapts react components

ccann22:01:22

thank you both

tabidots23:01:47

What is the simplest way/library to do color gradients given a value from say, 0-100? I don’t need to do full-on dataviz like maps or charts—literally just coloring table cells. (Sorry if this isn’t a CLJS-specific question per se; I’m doing front-end for the first time in years)

isak23:01:11

I've used this library for similar things: https://vis4.net/chromajs/

❤️ 1
tabidots00:01:48

This is exactly the level of simplicity I was looking for! Thanks!

valtteri09:01:11

If you’d like to avoid pulling in a dependency, the Google closure library has https://google.github.io/closure-library/api/goog.color.html

2
👍 1
wow 1
valtteri09:01:30

See lighten darken and blend functions especially

valtteri09:01:36

(require '[goog.color :as gcolor])
(-> "#0073e6" gcolor/hexToRgb (gcolor/darken 0.5) gcolor/rgbArrayToHex)
=> "#003a73"

valtteri09:01:13

I’ve created gradients like this

;; Zone colors
(def base-color "#0073e6")
(def zone-colors
  (into {}
        (for [n (range 1 (inc 10))]
          [(keyword (str "zone" n))
           (-> base-color
               gcolor/hexToRgb
               (gcolor/lighten (/ n 10))
               gcolor/rgbArrayToHex)])))

❤️ 1
valtteri09:01:07

If you use emacs, repl and rainbow-mode are your best friends. 🙂

tabidots03:01:20

Very cool, thanks!

tabidots17:01:59

@U6N4HSMFW Got the color scaling working with Google Closure and it’s pretty great! Thanks again

👍 1