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

Narrative pages with animated transitions #288

Merged
merged 14 commits into from
Jan 11, 2021
Merged

Conversation

macfarlandian
Copy link
Collaborator

@macfarlandian macfarlandian commented Jan 7, 2021

Description of the change

Builds out the bulk (but not all) of the basic layout UI for the narrative pages.

Screen Shot 2021-01-07 at 10 49 14 AM

Screen Shot 2021-01-07 at 10 49 38 AM

Functionality you should see:

  • all the content is present on each page
  • the sections smoothly "snap" into place as you scroll up and down the page
  • up/down chevrons on the left can also be used to page through the sections
  • the page progress bar in the left navigation updates as the page scrolls
  • the URL updates with the section number as the page scrolls
  • if you navigate directly to a URL with a section number (paste it in or just reload the page), the page will scroll to that section once it loads

The animations are somewhat inspired by this article, although I didn't really use any of their code directly. We will probably wind up implementing a similar "wipe" transition on this site eventually, but full motion designs are still TBD. I'm also using a different animation library than they did, React Spring, which has a nice, concise API and seems to be the newest hotness? Seems good so far in this limited context. (And, after a brief scare, has been verified to work in IE 11!)

There is some slightly funky state management within this page to integrate the animations and prevent the router from clobbering the page (the section "routes" are kind of fake since they do not actually map to different components), but I tried to comment voluminously to keep it sensible.

Other work to do on this page (other than the charts, obviously) includes adding a page footer for navigating to the other narratives and adding some more interactions to the section navigation component (jumping to a specific section in addition to advancing one at a time). This PR was already getting big enough, though, so I will defer that stuff for the next one.

Also in this PR I removed all of the "data portal" stuff since that is now out of scope for the first release.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Configuration change (adjusts configuration to achieve some end related to functionality, development, performance, or security)

Related issues

part of #276

Checklists

Development

These boxes should be checked by the submitter prior to merging:

  • Manual testing against realistic data has been performed locally

Code review

These boxes should be checked by reviewers prior to merging:

  • This pull request has a descriptive title and information useful to a reviewer
  • This pull request has been moved out of a Draft state, has no "Work In Progress" label, and has assigned reviewers
  • Potential security implications or infrastructural changes have been considered, if relevant

@coveralls
Copy link

coveralls commented Jan 8, 2021

Pull Request Test Coverage Report for Build 478270227

  • 74 of 80 (92.5%) changed or added relevant lines in 13 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.6%) to 64.04%

Changes Missing Coverage Covered Lines Changed/Added Lines %
spotlight-client/src/SystemNarrativePage/SectionNavigation.tsx 22 23 95.65%
spotlight-client/src/SystemNarrativePage/SystemNarrativePage.tsx 27 32 84.38%
Totals Coverage Status
Change from base Build 440710187: 0.6%
Covered Lines: 1369
Relevant Lines: 2085

💛 - Coveralls

Copy link

@daschi daschi left a comment

Choose a reason for hiding this comment

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

The transitions seem pretty smooth! It's great that the navigation for the sections is keyboard accessible. I just had a couple small questions.

// look like normal links. calling the setter is the critical step
to={`${urlBase}/${activeSection - 1}`}
onClick={() => {
setActiveSection(activeSection - 1);
Copy link

Choose a reason for hiding this comment

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

Do you need to add e.preventDefault() here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no actually I should have removed it in both places! and the preventdefault was what was causing the URL history to mysteriously not update in reference to your second comment, which I spent like ....... an hour-plus trying to debug. wow


// Jest/JSDOM don't support layout features
// so we can't really test anything related to scroll position :(
// (this also includes URL management because of how the page works)
Copy link

Choose a reason for hiding this comment

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

Does this mean you wouldn't be able to look at the history returned from renderNavigableApp to assert the page URL?

@macfarlandian macfarlandian merged commit ca03f50 into master Jan 11, 2021
@macfarlandian macfarlandian deleted the ian/276-narrative-ui branch January 11, 2021 18:44
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.

None yet

3 participants