Fork me on GitHub
#shadow-cljs
<
2020-09-07
>
Aron09:09:30

What is the easiest way to take the output of the report and create a pie chart or something visual? So far I only tried to see if I can copy paste from the terminal or from html.

thheller10:09:43

not all of the data is exported in pure data form. you can check the .shadow-cljs/release-snapshots/<build-id>/latest/bundle-info.edn file, maybe it contains what you need?

thheller10:09:07

the HTML file also has the data in EDN format so you could get it from there

Aron10:09:00

that's going to be perfect, thanks

robert-stuttaford16:09:46

any js pros able to guide me on how to do this with cljs only, perhaps? (from the code inside the first example on https://react-select.com/advanced):

const SortableMultiValue = SortableElement(props => {
  const onMouseDown = e => {
    e.preventDefault();
    e.stopPropagation();
  };
  const innerProps = { onMouseDown };
  return <components.MultiValue {...props} innerProps={innerProps} />;
});
<SortableSelect
      components={{
        MultiValue: SortableMultiValue,
      }}
    />
one of the downfalls of working on cljs so long is i've long since forgotten all the javascript arcana!

thheller16:09:53

isn't JSX fun? 😛 you are using reagent I presume?

thheller17:09:04

(def SortableMultiValue
  (SortableElement
    (fn [props]
      (let [mouse-down
            (fn [e]
              ...)]
        
        (react/createElement
          components/MultiValue
          (js/Object.assign
            #js {:innerProps
                 #js {:mouseDown mouse-down}}
            props))))))

[:> SortableSelect {:components #js { :MultiValue SortableMultiValue}}]

Aron17:09:11

@robert-stuttaford what have you tried so far? This does not appear to be exceedingly difficult to translate, it's a function getting a lambda and returning a dynamically created element with an injected eventhandler. (I would probably ask the person who wrote the original code to either document why this convolution or to rewrite it though)

Aron17:09:42

why the object assign?

thheller17:09:40

I'm assuming those are React props which shouldn't be mutated (or even might be frozen)

Aron17:09:44

oh, that's the merge because they are spreading the original props, got it

Aron17:09:17

this kind of state management is very fragile 😞

robert-stuttaford17:09:23

@ashnur i have noooo experience translating any js using const - that's after my time. been cljsing since 2012 😅 it's super occasional that i need something like this. thank you @thheller! using rum actually, but yeah, this gets me there!

thheller17:09:57

just replace const with var, if that makes it more readable 😉

robert-stuttaford17:09:26

it would have been rad for the react-select folks to support multi-select as a first class feature, but this is the only method they offer. don't care to learn the whole thing's internals, just need the feature in. complexity budget reserved for the domain!

thheller17:09:03

yeah the react world likes to go crazy with HoCs 😛

alpox20:09:19

It seems that they lessen again since Hooks came into play. Now there are just tons of those ^^

robert-stuttaford17:09:03

yeah, i mean the whole es 2015 and onwards flavour of js. the last major js i wrote was raw gclosure in 2011/2012 😂

robert-stuttaford17:09:12

i appreciate the quick response and help, @thheller, thank you sir o7

robert-stuttaford17:09:44

old news to you, but shadow is fucking rad 👏

❤️ 6
Aron17:09:34

react-select is the issue here, i gathered several hundreds of downvotes speaking my mind in its issue pages

Aron17:09:12

and I can just agree with @thheller 🙂

robert-stuttaford17:09:37

it may not do it well, but man, it's such an upgrade to anything we were doing before

thheller18:09:28

but does it really justify adding 90kb to a release build? for a select thingy? feels like a little overkill

thheller18:09:27

but I guess as far as react components are concerned thats still pretty reasonable 😛

neilyio22:09:20

I'm not sure that my namespace dev.preload is being loaded from the :devtools {:preloads [dev.preload]} slot in my shadow-cljs.edn. I have (js/console.log "We are preloading.") right at the top of my dev.preload namespace and nothing is being printed in the browser. What should I try next?

neilyio22:09:03

I can confirm that the following, from my main application namespace, does indeed print "We are preloading" when the app loads, so I know that dev.preload is the correct namespace.

(ns app.core
  (:require [dev.preload]))

neilyio22:09:44

I thought that having :devtools {:preloads [dev.preload]} in my build config would have the same effect, please let me know if there's an extra step or if there's something that I missed. If it helps, my :source-paths is just ["src"], and the file is src/dev/preload.cljs.

thheller23:09:34

@neil.hansen.31 you need to be more specific WHERE you put the preloads. it is supposed to be in your build config. can't tell where you have it if you just paste a part, the part looks correct though.

neilyio23:09:04

Hey @thheller, thanks for the reply. I can confirm it's in the the build config, as in

:builds
  {:app
    {:target :npm-module
     ...
     :devtools {:preloads [dev.preload]}}}

thheller23:09:26

that is the correct position

neilyio23:09:38

Sorry just made an edit above

thheller23:09:43

:npm-module does not support preloads

thheller23:09:28

you are kinda responsible to loading it yourself since there is no clearly defined way which namespace is loaded first

thheller23:09:40

ie. the JS loading the code controls that

neilyio23:09:50

Got it, thanks for clarifying. I really dug through the shadow-cljs user guide on this one, but sorry if I missed a mention of this anywhere.

thheller23:09:24

well technically preloads is supported .. but they are only compiled and not loaded

neilyio23:09:52

Is that true for all the npm/node targets?

thheller23:09:00

what are you doing? :npm-module is sort of deprecated and kinda dead

thheller23:09:10

nope only :npm-module

neilyio23:09:02

I'm (still) working on a CLJS + StorybookJS integration. I'm using the npm-module target, and having the Storybook process load all the compiled .js files that are prefixed with my stories namespace.

neilyio23:09:13

Storybook asks for a glob path to the .js files that have your "stories" in them, so this was my solution. It feels kind of hacky (and is slow), but it's working right now. I'd love a tip if you have a suggestion!

thheller23:09:57

hmm yeah no clue about storybook. either way its going to be hacky 😛

neilyio23:09:13

What's the best alternative to :npm-module?

thheller23:09:28

in case of storybook none

thheller23:09:43

since that really wants multiple files

neilyio23:09:19

I think I can also just point it to a single file. Would :node-script be worth trying?

thheller23:09:41

unlikely since you are not running in node

thheller23:09:29

https://clojureverse.org/t/generating-es-modules-browser-deno/6116 :esm is the more modern :npm-module but its probably not an option for storybook

thheller23:09:05

mostly because storybook probably won't accept the already provided react version

neilyio23:09:32

The :esm target is coming pretty close... But I'm getting these two warnings:

Warning: unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.

neilyio23:09:42

Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
    in Transition (created by CSSTransition)
    in CSSTransition (created by app.sidebar.modal_left)
    in app.sidebar.modal_left (created by stories.core.sidebar_modal)
    in stories.core.sidebar_modal (created by reagent3)
    in reagent3 (created by storyFn)
    in div (created by storyFn)
    in storyFn
    in ErrorBoundary