Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More phenogrid features, scrollbar changes #372

Merged
merged 4 commits into from
Oct 6, 2023
Merged

More phenogrid features, scrollbar changes #372

merged 4 commits into from
Oct 6, 2023

Conversation

vincerubinetti
Copy link
Contributor

@vincerubinetti vincerubinetti commented Oct 5, 2023

Closes #363

  • allow all non-mocked requests to pass through msw. the list of exceptions was just getting to be too long and too hard to predict (e.g. hard to know what format vite will compile assets into in which contexts). the penalty will be once in a while a live api will be hit during mocked testing; probably will only happen when adding new endpoints.
  • replace sem sim compare fixture data with bigger example (for stress testing phenogrid)
  • update sem sim compare api func to derive some additional data, like totaling up the scores for each col and row
  • rearrange css z-indices
  • get rid of big arrows in table scroll
  • force scrollbars to be visible on macos chrome and safari (not firefox, not ios). more discussion on this below. add ability to add little dark shadow on scrollable elements. previously was just using an alpha mask, so it would just fade into the background, so sometimes you'd miss it if the gradient landed in-between elements. being a gray gradient will make it always visible on light/dark bgs.
  • phenogrid component: add scrolling, sticky col/row headers, info popup, download image
  • add util funcs to support the above

Discussions:

Maybe someone can provide me here with some content to put in the info tooltip per #362

I added a sorting method where the rows/cols get sorted based on the sum of their cells' scores. I'm not sure if this is useful, but it kind a seems like it to me because it basically puts the darker (higher score) cells closer to the top left corner. Does anyone know what's involved with doing the freq/rarity sorting and different calc methods here:

We can do phenogrid in two ways: HTML (table) or SVG, each with pros and cons:

  • A table is automatically (fairly) accessible, svg takes more work to make nicely accessible.
  • A table is harder and much to download as an image (taking a screenshot of the dom is brittle and prone to mysterious cross-browser/device errors, e.g. safari just fails to download when the grid has too many elements), with svg all you do is download the source as a text file.
  • A table requires setting background colors on several elements to make the "stick" col/row headers work (i.e. the top row has to have a white bg so when you scroll up and the cells go under it, they don't pop through), an svg has clip paths and masks that can "cut out" part of a shape without needing a background color, keeping things transparent (good for image export, and doesn't necessitate changing all the bg colors if you're using the widget on a site with a dark bg for example).
  • A table allows for "sticky" col/row headers more smoothly and easily with CSS, with svg this would necessitate javascript (syncing the scroll position of the container to the position of the clip paths and other svg elements) and result in some lag.
  • An svg should theoretically be more performant than a table and better able to handle larger grids. A table uses more elements per cell (e.g. a tbody wraps a tr wraps a td wraps a colored button, vs. a single svg colored rect element at a coordinate) and uses a more complex layout algorithm (i.e. in a table all cells can affect the sizing of other cells, vs. in an svg an element is just drawn at a coordinate with some transforms).

Regarding scrollbars. I didn't like the bulky arrows with the animations on the tables. Looks clunky, but more importantly, it's not "simple". Have to add new dom elements and restructure your component hierarchy to accommodate this. Instead, I added a utility class that adds a shadow that can simply be slapped on any element without changing anything else, however it can only work in one direction at a time (e.g., couldn't have a horizontal and vertical scrolling together), but I think that's an okay limitation. Also, I've added a utility class to force the scrollbar to always be visible, but it still won't work on macos firefox or ios. This is because apple has forced a design standard on ios where the scrollbar hides unless you are actively scrolling (I guess to make it look more slick and/or save screen space), and firefox has taken it further and completely ignores attempts to force scrollbar visibility on any platform (and instead just respect whatever the OS tells it to do). You can change this behavior in your OS settings, and we can recommend users do it, but there is no (good) way to us to force it. There are libraries like Perfect Scrollbar that can force scrollbars on any platform, but they are not good to use imo: they require adding new DOM elements to draw the scrollbar (despite them often claiming they don't affect the dom), and they basically (poorly) replicate the browser's native scrolling behavior with javascript. Sounds easy, but there are more things to account for than you'd think (speed, acceleration, snapping, wheel vs touch vs trackpad vs keyboard control, etc.), and if you check out Perfect Scrollbar for example, you can notice their website's scrolling feels a bit off from native behavior. All of this is to say, the solutions I've implemented here are as far as I'm willing to go. We should leave it here, with CSS properties and some basic shadows. If we still get these common complaints about scrollbars not being visible, e.g. in ios, we will have to just say it's the browser's/OS's fault for enforcing this bad design decision on us. This is the approach stackoverflow seems to take, for example, with its scrollbars in big code blocks. You will see they disappear on firefox. Going further is just too brittle and not within our scope to fix.

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for monarch-app ready!

Name Link
🔨 Latest commit 727e6a4
🔍 Latest deploy log https://app.netlify.com/sites/monarch-app/deploys/651ef2706ca2c00008e9968a
😎 Deploy Preview https://deploy-preview-372--monarch-app.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@vincerubinetti vincerubinetti changed the title Scroll More phenogrid features, scrollbar changes Oct 5, 2023
Copy link
Collaborator

@glass-ships glass-ships left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks alright to me!

@kevinschaper kevinschaper merged commit f75c376 into main Oct 6, 2023
9 checks passed
@kevinschaper kevinschaper deleted the scroll branch October 6, 2023 15:24
kevinschaper pushed a commit that referenced this pull request Nov 14, 2023
- update phenogrid readme instructions
- remove some unused fixture json files
- manually add really large phenogrid compare fixture json
- upgrade all packages to latest version. msw 1.0 to 2.0 (only major
bump). refactor to accommodate.
- add some missing toLocaleString() to numbers
- change phenogrid component from table to svg. pros and cons discussed
[here](#372)
- touchup behavior and look of phenogrid. add basic info tooltip. add
transpose feature. rework size event emitting for widget use. download
as svg instead of png
- touchup node page associations section
- fix small bug where clicking association count link in overview
section does not scroll to associations section
- tweak how async route loading is done to avoid flash of homepage while
loading
- add and tweak util funcs

Please take a look at the fixture data is being generated for the
frontend. If it's not being imported at the top of `/fixtures/index.ts`,
it's not being used and doesn't need to be generated.
@vincerubinetti vincerubinetti mentioned this pull request Jan 19, 2024
vincerubinetti added a commit that referenced this pull request Jan 19, 2024
Closes #541 

Tried to find a workaround, could not (in a reasonable time). Instead,
just turn off scroll feature in FF.

This was one of the known cons of switching to svg over table:
#372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Phenogrid: Add a scroll bar
3 participants