reuters-graphics / bluprint_graphics-kit

SvelteKit rig for graphics and newsapps
https://reuters-graphics.github.io/docs_graphics-kit/
21 stars 3 forks source link

Ai2svelte and ai2svelte scroller components #30

Closed MinamiFunakoshiTR closed 3 years ago

MinamiFunakoshiTR commented 3 years ago

After talking to Samu, who said he often has multiple static ai2html graphics on one page, I decided to build a reusable Ai2svelte.svelte component that pulls in ID's from the google doc and uses that to call ai2svelte components. To do that, I made ai2svelte components load onMount and in async.

This component is now in lib, but it might make sense to put it in graphics-svelte-components. To make this work, I added the Type:ai2svelte block in the master google doc. I am worried the master google doc is getting a bit cluttered.

I also finished making the scroller components, which are ready for you if you are curious. I am going to go through it with Feilding next week when he's back, so no need to touch the stuff in the Scroller folder, though.

hobbes7878 commented 3 years ago

Yeah, I'm worried a bit about how much boilerplate we're adding both in the google doc and the rig. Let's discuss tho. I think some of this may be better placed in the svelte components project, as you mention.

MinamiFunakoshiTR commented 3 years ago

Updates from Sept. 28:

Question:

MinamiFunakoshiTR commented 3 years ago

EOD Sept. 29

  1. Ai2SvelteContainerStatic.svelte Static version, working

  2. Ai2SvelteContainerOnChange.svelte Dynamically imports whenever the index changes. working, but performance not great since we're importing every time the index changes. the files seem to not cache since i see a flash every time i scroll.

  3. Ai2SvelteContainer.svelte Not done. Working on dynamically importing all components in one go, instead of when the index changes. I'm having trouble adding the loaded Ai2svelteGraphic component into an array (see lines 12-14). Would be great to talk about how to make this work, and what the best way to set the ai2svelte scroller might be in general.

MinamiFunakoshiTR commented 3 years ago

Sept. 30

hobbes7878 commented 3 years ago

Hey, so I checked these out and made some edits. They're working really, really well and are super configurable, especially the scroller, but you're gonna see a lotta new code from me, mostly in the scroller.

Here's some of what I did:

Anyway, I'd pull this down and play with the layout props in the content.json file to see how all the layouts work. I did that with Chris today just to check we weren't missing an obvious one. He figured we've got basically all standard use cases covered.

I'm also figured out a new way we could get these two components into the components lib that I want to talk about. One potential benefit of doing so is I actually think with the layout handled the way it is in the scroller now, we could make this a component that handles both AI and D3 backgrounds.

OK, OK. Take a look on Monday, and we'll follow up. I think we're dangerously close to something ridiculously cool that is going to sell this whole rig to APAC. :P

hobbes7878 commented 3 years ago

Published a version of both components in the components lib with docs on how to implement w/ archieML Google docs. Scroller now works with both ai2svelte graphics and just regular old Svelte components.

Talk next week if we want to use these in this bluprint:

Ai2svelte Scroller

hobbes7878 commented 3 years ago

This is ready to merge into master after you test @MinamiFunakoshiTR.

MinamiFunakoshiTR commented 3 years ago

I saw we had both static/img/graphics and statics/images/graphics in src/. We should have only statics/images -- I think the static/img/graphics folder came into being because I accidentally used the old ai2html setting when running the script and forgot to delete this folder.

I deleted the static/img/graphics folder and renamed the pngs in statics/images/graphics so that everything is lowercase. I also renamed the pngs to ai-scroller- so that the file name matches the component file name and what's in the google doc.

I tested the preview, all looks good.

The components are ready for Sam Granados!