reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
rberger 2020-07-13T01:13:17.345500Z

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 debugger

phronmophobic 2020-07-13T01:18:35.346200Z

not 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&amp;display=swap>"))
    (.appendChild (-&gt; js/document .-body)
                  link)))

phronmophobic 2020-07-13T01:20:51.346400Z

that's what I've been using and works for my purposes

rberger 2020-07-13T01:21:48.346600Z

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..

phronmophobic 2020-07-13T01:24:53.346800Z

you can add an onload attribute if you want to delay displaying the web page before loading the font.

phronmophobic 2020-07-13T01:25:05.347Z

it depends on how flexible you want your setup to be

rberger 2020-07-13T01:25:37.347200Z

Ok, thanks!

NoahTheDuke 2020-07-13T19:36:47.350200Z

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?

pez 2020-07-13T19:40:29.351400Z

I think it makes sense to make a separate SPA for admin.

2020-07-13T19:40:31.351500Z

the data needed to render the admin should require auth

2020-07-13T19:40:41.351800Z

yeah, having a separate app entirely is best

2020-07-13T19:41:19.352500Z

but fundamentally, they shouldn't be able to fetch any meaningful data to make the admin do anything

2👍
2020-07-13T19:41:27.352700Z

(without auth first, of course)

pez 2020-07-13T19:41:41.353200Z

Completely agree.

NoahTheDuke 2020-07-13T19:41:47.353300Z

Cool, that makes sense

2020-07-13T19:42:23.353900Z

what I've done in the past is have two builds (user, admin) and as apropriate share the same underlying namespaces

2020-07-13T19:42:48.354400Z

just making sure the shared libs can't expose admin functionality of course

NoahTheDuke 2020-07-13T19:43:10.354800Z

right

2020-07-13T19:43:31.355300Z

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

adam 2020-07-13T21:36:09.358600Z

What does :&gt; mean? I am looking at some Reagent samples and couldn’t find the explanation

adam 2020-07-13T22:12:50.359Z

Thanks @kenny