Is there an easy way to add fonts from Google Fonts in clojurescript/reagent? (other than just puting a link in the index.html) I tried using https://github.com/typekit/webfontloader npm library like:
(ns foo.core
(:require
["webfontloader" :as WebFont]))
(defn fonts-init! []
(.load WebFont {:google {:families ["Roboto:wght@100;300;400;500"]}}))
And then call that just before the
(r/render [views/init]
(.getElementById js/document "app"))
Not sure if I’m not using it right, or it just doesn’t want to work in this context, or it needs to be called at another point in the life cycle…
Anyone have experience with this or something similar?
It doesn’t have an error that I can see in the debuggernot sure you need all that. what about just:
(defn load-font []
(let [link (.createElement js/document "link")]
(doto link
(.setAttribute "rel" "stylesheet")
(.setAttribute "href" "<https://fonts.googleapis.com/css?family=Ubuntu&display=swap>"))
(.appendChild (-> js/document .-body)
link)))
that's what I've been using and works for my purposes
Are there timing issues of having it ether blocking the page or the page expecting the fonts loads before and you get some glitching? I’ll probably just put it in my index.html for now, but I was curious if there is a way to use the webfontloader. I think it has some nice features for accessing all different kinds of font libraries and deal with different weights etc..
you can add an onload attribute if you want to delay displaying the web page before loading the font.
it depends on how flexible you want your setup to be
Ok, thanks!
super quick question: how do you handle gating admin pages in a reagent SPA? in the app i steward, the admin pages are rendered serverside with their urls auth wrapped, but that makes development slow and cumbersome. is there a best-practices (that's not reframe) for moving the auth pages into the cljs
without making it easy for the user to just edit their localstorage data to get access to the admin screens?
I think it makes sense to make a separate SPA for admin.
the data needed to render the admin should require auth
yeah, having a separate app entirely is best
but fundamentally, they shouldn't be able to fetch any meaningful data to make the admin do anything
(without auth first, of course)
Completely agree.
Cool, that makes sense
what I've done in the past is have two builds (user, admin) and as apropriate share the same underlying namespaces
just making sure the shared libs can't expose admin functionality of course
right
because in practice the admin and the user interface are going to expose a lot of the same sorts of data, so writing the code twice is a waste of time
What does :>
mean? I am looking at some Reagent samples and couldn’t find the explanation
https://cljdoc.org/d/reagent/reagent/1.0.0-alpha2/doc/tutorials/react-features
Thanks @kenny