Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
the heat goes wrong
Dec 31, 2005
I´m watching you...

A Cup of Ramen posted:

For the most part I'm quite comfortable with HTML and CSS now, haven't really done much in JS though... don't suppose anyone would have any course recommendations that cover JS really well would they?
As for Typescript it wasn't even on my radar until now so hey glad I actually upped and asked about this.

Get Wes Bos´es Beginner JavaScript course. Its a 28 hour javascript course that will cover everything you need in a way that you understand it. Right now its on 50% sale also.

e; https://beginnerjavascript.com/

the heat goes wrong fucked around with this message at 21:41 on Nov 29, 2020

Adbot
ADBOT LOVES YOU

prom candy
Dec 16, 2005

Only I may dance
Wes Bos is good

Ytlaya
Nov 13, 2005

This is a kind of broad question, but I have a problem where I need to load a large amount of data into a table (50,000+ rows) and I'm not sure if the solution I have in mind makes sense. Currently the data is passed into the template as JSON and loaded into DataTables (which uses the Scroller plug-in), but this is obviously not really viable when there's a ton of data.

My thinking is that I can store the JSON in a file and then create an endpoint (I'm using Python Flask) that takes the filename (or some ID associated with it) as a parameter and returns the JSON (that was stored in the file), and then DataTables loads the data from an AJAX call to that. Does this make sense?

(The reason I'm not considering server-side processing for this table is that it isn't practical without largely redoing the way the page in question works.)

Ruggan
Feb 20, 2007
WHAT THAT SMELL LIKE?!


Ytlaya posted:

This is a kind of broad question, but I have a problem where I need to load a large amount of data into a table (50,000+ rows) and I'm not sure if the solution I have in mind makes sense. Currently the data is passed into the template as JSON and loaded into DataTables (which uses the Scroller plug-in), but this is obviously not really viable when there's a ton of data.

My thinking is that I can store the JSON in a file and then create an endpoint (I'm using Python Flask) that takes the filename (or some ID associated with it) as a parameter and returns the JSON (that was stored in the file), and then DataTables loads the data from an AJAX call to that. Does this make sense?

(The reason I'm not considering server-side processing for this table is that it isn't practical without largely redoing the way the page in question works.)

If you are creating 50k HTML table rows from data you're going to have a bad time. Your user will need to wait for the template to load, which will be huge. The user isn't going to be able to effectively see/use all the rows anyway so don't do that.

If you are loading the blank page, then loading 50k JSON objects into memory and paginating through them in your table plugin that's better. But it still isn't great. You are forcing the user to download 50k JSON objects through the wire which will be costly. The user will be able to interact with the page early but will need to wait for the 50k objects to download.

Can you separate your large amount of data into page-sized sets? For example, if you could separate the file into 100 objects per file, you could request any "chunk" of data (each as its own JSON file) and that would be quick to load. That would basically emulate server-side pagination.

Ytlaya
Nov 13, 2005

Ruggan posted:

If you are creating 50k HTML table rows from data you're going to have a bad time. Your user will need to wait for the template to load, which will be huge. The user isn't going to be able to effectively see/use all the rows anyway so don't do that.

If you are loading the blank page, then loading 50k JSON objects into memory and paginating through them in your table plugin that's better. But it still isn't great. You are forcing the user to download 50k JSON objects through the wire which will be costly. The user will be able to interact with the page early but will need to wait for the 50k objects to download.

Can you separate your large amount of data into page-sized sets? For example, if you could separate the file into 100 objects per file, you could request any "chunk" of data (each as its own JSON file) and that would be quick to load. That would basically emulate server-side pagination.

It won't be that many HTML rows; I'm using DataTables with the Scroller plug-in that loads rows on demand as you scroll. I think Scroller essentially accomplishes the same thing paging would as far as displaying the actual html goes. Pagination isn't preferred in this situation (my boss doesn't like it, lol).

But (as you mentioned) I think it would still end up needing to download all the data, even if it's not directly loading it into the template (which is what it was doing before, with results truncated to allow for this). I think it largely depends upon how exactly DataTables deals with AJAX-sourced data with the deferred loading option enabled (I don't know if it will immediately load some of the rows or if it will have to download all of the data first). I've looked into something like streaming data with Flask, but I'm not sure how that would work with DataTables. Tomorrow I'll get it working with Scroller and sourcing the data from an AJAX call, so I'll at least know how that performs. It's not the end of the world if it's a little slow (only a small fraction of results will be really large - the context in this case is displaying genome mapping results, so length corresponds to number of markers in the genotype file).

Splitting the results up into chunks is possible, but I'm not sure how to feed that to a single DataTables table. It might actually be possible to use server-side processing somehow (without rewriting a bunch of stuff); a coworker seemed to think it wasn't easily doable, but it seems to me like it should be doable since it just needs to refer to an existing JSON file for the data.

Tei
Feb 19, 2011
Probation
Can't post for 3 days!

Ruggan posted:

If you are loading the blank page, then loading 50k JSON objects into memory and paginating through them in your table plugin that's better. But it still isn't great. You are forcing the user to download 50k JSON objects through the wire which will be costly. The user will be able to interact with the page early but will need to wait for the 50k objects to download.

50KB of json weight has much 50KB of jpg and people don't mind that

but pagination is another thing that databases do better than any other software because pagination depend on sorting and sorting is anything but simple

Tei
Feb 19, 2011
Probation
Can't post for 3 days!
I manually implemented a infinite scroll thing once

What I did is calculate the height of the full table with 50000+ records

[table with forced height-- showing a scroll if the tbody is "too big"]
[empty TR with height the height total - the visible+bottom]
[visible tr's with data]
[empty tr with height the height total - heightvisible - top]
[/table]

scrolling would request the current page and receive such page and that one before and after - results where cached at page level

it worked but it was not too smooth

since the table only had like 2 empty TR's and 50 records --- it was not too heavy on the browser

I guess that doing this + having the data already on the clientside would result on a much more smooth experience but still not perfect
---

I did this manually but I guess theres infinite scroll libraries that can be convinced to get the data from local and not remote source

--

the conclusion here is that a html with too many elements will make the user experience miserable but having large invisible objects (such has a huge empty TR) don't seems to affect the browser in any way

is the number of elements and no their "surface" that can be a problem for the browser

Tei fucked around with this message at 13:48 on Dec 2, 2020

marumaru
May 20, 2013



did the css for SA change or am i just crazy

The Fool
Oct 16, 2003


Both things can be true

I guess there’s a qcs thread about it but I didn’t look

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
https://forums.somethingawful.com/showthread.php?threadid=3950003#post510407763

just lmfao

e: it's got good contrast tho

marumaru
May 20, 2013



Grump posted:

e: it's got good contrast tho



was literally about to do that. for some reason it feels like it doesnt

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
You aren't using your own CSS for the forums?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I've looked at the forums CSS and immediately regretted it so I'm not feeling especially keen on janitoring my own bespoke version.

marumaru
May 20, 2013



nexus6 posted:

You aren't using your own CSS for the forums?

i am now! and you can bet that it's ugly as gently caress

Tei
Feb 19, 2011
Probation
Can't post for 3 days!
maybe not related - but heres the custom css I use to make JIRA dark

code:
body {
  filter: invert(88%);
  background-color: #1f1f1f !important;
}
#page img,
.img-wrapper,
span[role="img"] {
   filter: invert(88%);
}
( I did not made it - it invert things that did not need to be inverted but I don't care )

Tei fucked around with this message at 17:46 on Dec 3, 2020

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes

Inacio posted:

i am now! and you can bet that it's ugly as gently caress



uncle blog
Nov 18, 2012

Anybody got experience using Cypress with a React SPA?

I'm trying to set up e2e tests to check the different pages of the app. I heard it was possible to manually set the state when testing, removing the need for the test to navigate through a series of pages in the UI to get to the page I want to test (it's not possible to go to this page directly, as the router checks if a certain state has been set in the containing component). I installed the plugin cypress-react-selector which seemed to fit the bill. The trouble is that I'm having trouble accessing my components. Opening up the app and checking in devtools, I clearly see the component names matching what is written in code.

I follow the example on https://github.com/abhinaba-ghosh/cypress-react-selector, and try to locate one of my components:
code:
it('it should validate react selection with component name', () => {
  cy.react('StartPage');
});
This fails, saying it can't locate the component. This continues with the other names I try. To troubleshoot I input a wildcard into the react method, and log all the components it finds.

code:
cy.react("*").each(function ($el, index, $list) {
      console.log($el);
    });
It obviously finds a bunch of stuff, but nothing that is recognizeable to me. This is an excerpt of what gets logged:
code:
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
I must honestly admit I don't understand what I'm seeing here. A bunch of div elements? And some undefined stuff?

Any tips to what I might be doing wrong in trying to get access to my components?

prom candy
Dec 16, 2005

Only I may dance
I have a tiny bit of experience with this and the experience I had was that it's easier to write little helpers that simulate doing all the right clicks and filling in the right fields rather than trying to edit your state directly.

Impotence
Nov 8, 2010
Lipstick Apathy
I feel like testing any SPA with anything short of a headless browser ends up being mindnumbingly annoying


edit: I mean as in the "simulate typing/clicks" part, instead of trying to patch values

Impotence fucked around with this message at 20:15 on Dec 4, 2020

prom candy
Dec 16, 2005

Only I may dance
Cypress is a headless browser

Doom Mathematic
Sep 2, 2008
My experience with Cypress in a React SPA is that Cypress is intended to interact with a web browser in the same way that a human being does. Manually messing around with the state of the application in a way which is impossible for a regular person is counter to that; you end up with unrealistic tests. It might be that this test should be shifted left and become a component or unit test? Or it might be that the navigation process to reach this page the "normal" way should be part of the test too?

Having said that... are you sure your React components have the correct names? I vaguely recall that a functional component like const MyComponent = ({ blah }) => <div>{blah}</div> does not actually have a name unless you also set MyComponent.displayName = 'MyComponent'.

Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.

uncle blog posted:

code:
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
undefined
jQuery.fn.init [div.page-root]
I don't have any answers, but I find it extremely curious that you're getting back a list of jQuery collections from a library that's meant for selecting React components.

Violator
May 15, 2003


I've been taking a look at my current workflow so the recent JS talk has been good.

What's the thinking on Bootstrap? Is there a better alternative? I used to build everything by hand on every project but then started using Bootstrap to simplify things since I was redoing a lot on every project.

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Violator posted:

I've been taking a look at my current workflow so the recent JS talk has been good.

What's the thinking on Bootstrap? Is there a better alternative? I used to build everything by hand on every project but then started using Bootstrap to simplify things since I was redoing a lot on every project.

Yeah there are tons of good css frameworks these days, just depends on what things you’re looking for.

The Fool
Oct 16, 2003


Violator posted:

I've been taking a look at my current workflow so the recent JS talk has been good.

What's the thinking on Bootstrap? Is there a better alternative? I used to build everything by hand on every project but then started using Bootstrap to simplify things since I was redoing a lot on every project.

I use semantic/fomantic ui and it works quite well

Violator
May 15, 2003


Chenghiz posted:

Yeah there are tons of good css frameworks these days, just depends on what things you’re looking for.

Main thing is simple structure to get responsive breakpoints easily. I like the rows/columns and breakpoints of bootstrap. I also like how they have some pre-built elements that you can use to jazz simple things like forms up a little. I'm building a top Laravel if that matters, not sure if that community has particular favorite frontend frameworks.

The Fool posted:

I use semantic/fomantic ui and it works quite well

Nice, I'll check it out.

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer
I've been slowly putting together my own kind of framework over the years, and it turns out it has a lot of similarities to Bulma. I really like Bulma, it's the cleanest CSS-only framework I've found.

prom candy
Dec 16, 2005

Only I may dance
I haven't spent much time with the CSS frameworks because I pretty much always work with a designer but Bulma always seemed like the nicest one to me.

Violator
May 15, 2003


Well it turns out Laravel has switched from bootstrap to Tailwind CSS as the frontend framework in 8.0. Guess I need to dig into that and see what's up.

prom candy
Dec 16, 2005

Only I may dance
Tailwind rocks but that's a weird switch. Bootstrap and tailwind are pretty different.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
Yeah - protip: tailwind has a build script thing that you need to run each time you use a new class or it won't know what you're talking about. It's not like Bootstrap where you can just use a classname and expect the relevant CSS to be applied.

lunar detritus
May 6, 2009


nexus6 posted:

Yeah - protip: tailwind has a build script thing that you need to run each time you use a new class or it won't know what you're talking about. It's not like Bootstrap where you can just use a classname and expect the relevant CSS to be applied.

That's only if you have purgeCSS enabled in development which... you shouldn't.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes

lunar detritus posted:

That's only if you have purgeCSS enabled in development which... you shouldn't.

Or if you inherit a project built with Tailwind that is already live :smith:

lunar detritus
May 6, 2009


nexus6 posted:

Or if you inherit a project built with Tailwind that is already live :smith:

If you can, try changing this setting in tailwind.config.js
https://tailwindcss.com/docs/optimizing-for-production#enabling-manually

code:
enabled: process.env.NODE_ENV === 'production',
could work, depending on your build process

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
Thanks, just pointing out it's a gotcha if you're not already familiar with Tailwind

prom candy
Dec 16, 2005

Only I may dance
The other thing to be aware of with PurgeCSS is it can't detect classes in your code if you build them dynamically.

code:
const color = "red"

return <div className={`text-{color}`} />
PurgeCSS won't know that you want to keep .text-red in this scenario. You can either add the full class name instead of building it dynamically, write the classname somewhere else in your file as a comment (i.e. if you might have red, blue, or green text just add a comment like // text-red text-green text-blue) or I think you can add it to your ignore patterns in the PurgeCSS config (you'll likely end up having to do this if you use any third party libraries that provide CSS classes)

You can choose not to use PurgeCSS but tailwind generates a lot of CSS so it's worth it.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
lol, just had a couple of online forms that gave you a little box to draw a signature in. How are you supposed to do that with a mouse?

RadiRoot
Feb 3, 2007
Is input type=color not working as expected for anyone else using macos safari 14?

Selecting a color doesnt update the value and I cant find anything about it being a bug? I also tried disabling all extensions.

prom candy
Dec 16, 2005

Only I may dance

nexus6 posted:

lol, just had a couple of online forms that gave you a little box to draw a signature in. How are you supposed to do that with a mouse?

if your signature is as lovely as mine you can try it with a mouse just as well as you can write it with a pen

Adbot
ADBOT LOVES YOU

RadiRoot
Feb 3, 2007

Tei posted:

maybe not related - but heres the custom css I use to make JIRA dark

code:
body {
  filter: invert(88%);
  background-color: #1f1f1f !important;
}
#page img,
.img-wrapper,
span[role="img"] {
   filter: invert(88%);
}
( I did not made it - it invert things that did not need to be inverted but I don't care )

Nice, wish Jira had this built in already. Adding hue-rotate(180deg) to the filter will keep the original color hue also.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply