This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-29
Channels
- # adventofcode (8)
- # babashka (12)
- # beginners (91)
- # calva (6)
- # cider (2)
- # circleci (11)
- # clj-kondo (19)
- # clojure (202)
- # clojure-australia (7)
- # clojure-brasil (1)
- # clojure-europe (123)
- # clojure-nl (2)
- # clojure-poland (24)
- # clojure-uk (6)
- # clojured (1)
- # clojurescript (91)
- # core-async (23)
- # cursive (16)
- # data-science (5)
- # datomic (26)
- # emacs (27)
- # events (2)
- # graalvm-mobile (50)
- # graphql (4)
- # honeysql (4)
- # instaparse (33)
- # lsp (24)
- # meander (22)
- # nrepl (3)
- # off-topic (26)
- # pedestal (1)
- # re-frame (15)
- # releases (1)
- # sci (1)
- # shadow-cljs (20)
- # tools-deps (22)
Anyone know how to replicate the following imports using figwheel-main?
import Highcharts from 'highcharts';
import Heatmap from 'highcharts/modules/heatmap.js';
Heatmap(Highcharts);
I tried
(ns highcharts.demo
(:require
["highcharts" :as Highcharts]
["highcharts/modules/heatmap.js" :as Heatmap]))
but no diceI’m getting Highcharts ok, just not the nested heatmap module
I’ve tried with and without the .js
suffix
I guess you can't nav to the heatmap from Highcharts - or don't want to without bringing in all the modules? requiring a single module/file from an npm lib is not possible in cljs afaik. maybe shadow can do it? I don't know highcharts, but googling cljs highcharts there seems to be quite a few results, so maybe something there?
yeah, can’t navigate through the Highcharts object sadly
> requiring a single module/file from an npm lib is not possible in cljs afaik do you know if there’s a reference somewhere for the cljs string requires? I’m struggling to find the right google search terms
... but actually the feature that's described as new is not what you're after. I think it's just sugar for navigating js object
yeah but good shout, maybe if I look back over the release notes
https://github.com/clojure/clojurescript/blob/a4673b880756531ac5690f7b4721ad76c0810327/src/test/cljs_build/npm_deps_test/string_requires.cljs#L3 seems to be able to pick a single module/file out of an npm lib?
I wonder if I’m doing something dumb
oh holup it looks like its working now
did a restart and a refresh etc and used the “highcharts/modules/heatmap” incantation
I am creating a very simple landing page as a ClojureScript Single Page App. I have identified 4 different views, home, reference, tutorials, support, which are fairly separate from each other. There may be a few functions shared between these views, but the overall layout will be different. What is the simplest approach to displaying each view based on a user action, eg clicking on the tutorials button on the home view changes the view to the tutorials view. • do i just hide and unhide the • do i need to include some kind of router like a compojure equivallent (seems a little excessive) I am using reagent, http://bulma.io for CSS and figwheel-main as I am most familiar with these and would prefer to avoid JavaScript and npm (not familiar and its supposed to be a simple site). Thank you for sharing any ideas or examples.
Simplest - indeed the "hide and unhide" approach. And tad less simple but more scalable and useful in general - the router approach. If your app is limited to those four views and it's OK that people can't share links to particular views, then the first approach is reasonable.
Just to clarify - what do you refer to by 'hide'/'unhide'? Is this better/worse compared to using a cond? Like in https://github.com/henrik42/solo/blob/83064f711b3cec897fd5f59fec50dd418b309f88/src/cljs/solo/spa.cljs#L276
I am strugling with http://goog.net.Cookies.prototype.set: https://github.com/google/closure-library/blob/master/closure/goog/net/cookies.js#L167-L229 I have:
(.set goog.net.Cookies.prototype "test" "test" #js{:maxAge 1000
:path "/"
:domain "localhost"
:sameSite (.-LAX goog.net.Cookies.SameSite)
:secure true})
but this keeps telling me "this.document_ is undefined". I don't know, how to provide the context so that goog.net.Cookies
understands where to set the cookies. Any clues?Don't call prototype
functions. Instead, create a concrete object and call a regular method on it.
In this case, use
to get the actual Cookies
instance and call the set
method on it instead of its prototype.
(.set (.getInstance js/goog.net.Cookies) "test" "test" #js{:maxAge 1000
:path "/"
:domain "localhost"
:sameSite (.-LAX http://goog.net.Cookies.SameSite)
:secure true})
Thank you for the explanation. It works!
Also, don't use js/goog ...
. Instead, require it properly. E.g. (:require [goog.net.Cookies :as Cookies])
with a consequent (Cookies/getInstance)
.
This is all related to my problem in the shadow-cljs channel: https://github.com/reagent-project/reagent-utils/issues/19 basically, it works in dev and doesn't work in release. Something is totally off here. I feel like I have learned a great deal in the last day, but this really is a problem I must fix - we need to set the SameSite option. Thank you for your mentoring
I'm trying to make https://clojars.org/tick/versions/0.4.32 work with https://www.npmjs.com/package/react-datepicker but so far I'm unable to convert from tick/joda's LocalDate to a Date that react-datepicker can recognize. Is there a recommended datepicker to use with tick, or can anyone point me to an example of how to convert to javascript native date-fns? @henryw374
I like to keep all my dates in UTC with the location data because of daylight savings time.
because time varies based on location even when in the same longitude... and UTC is coordinated across all locations and time zones
what libraries do you use for managing temporal data and for date-picking UI ?
I actually wrote a machine learning algo to recognize the hundreds of ways to write dates/times. Fun project.
Formatting If you want to create custom formatters from patterns, such as "dd MMM yyyy", add this require
Looks like tick has a way to custom format but it is not very well documented... this is only in alpha?
I always use UTC since a manager told the team to switch over our servers at midnight on Tuesday...
I'll try to add clarity by pasting in the errors I'm getting. One sec.
So I've got a LocalDate object, and I get this error when passing it in to react-datepicker:
No protocol method IConversion.inst defined for type object: 2020-01-23
so I need to find the right set of conversion(s) if I want to use this datepicker UI that relies on native javascript date objects
you need to search the correct way to instantiate an object for that react date picker
the LocalDate object is not compatible with the React object... those are two different classes
#(tick/date %)
where the argument is a string
tick makes use of js-joda ....
you need to focus on creating the React object... then read the tick string into it...
Trying to make that code work. I'm currently seeing this error: No protocol method IExtraction.date defined for type null
so, if user selects a date, and that api gives you a native Date obj, convert it to a LocalDate with :
(-> js-date-obj
t/instant
(cljc.java-time.zoned-date-time/of-instant (t/zone "UTC"))
t/date)
it does seem a bit complicated... I'm thinking this specific thing should be documented as it seems like a normal thing to want to do. longer term.. this will all become easier with the new js date objects . fyi see https://github.com/henryw374/tempo
So I've got a date from a postgres db that I've coerced to LocalDate via #(t/date %) In the DatePicker I'm formatting the value as you said, I think: `(-> start-date (tick/midnight) (tick/in (tick/zone "UTC")) (tick/inst))`
Does the No protocol method IExtraction.date defined for type null
error make sense to you?
aha, sorry, I had some old code in a let block that was throwing that error
so it does appear to be working! Thank you both so much
@henryw374 good job