-
Notifications
You must be signed in to change notification settings - Fork 3
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
Revamp Spotlight state landing page #477
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holding off on a more thorough review for now, since there's not a whole lot to comment on just yet!
@jessex Hey, Josh! So I have something like this for now: @cawarren suggested using other charts to preview sentencing and parole data and they are much easier to manage. The solution for the preview is using a boolean flag, depending on which we render different charts. The only thing I need to do is to get rid of prison population minimap. Maybe @macfarlandian know simple and effective solution for that? |
@nasaownsky hmm tricky .... I don't think that can be disabled, probably you will have to sub out the |
One quick thing: is it possible for this to be deployed to the staging site (spotlight-staging.recidiviz.org)? This would make it easy for @agronomic and I to review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far, @nasaownsky! Local testing went smoothly.
@@ -91,6 +102,41 @@ const NarrativeLink: React.FC<{ | |||
from: { opacity: 0 }, | |||
})); | |||
|
|||
const renderChartPreview = () => { | |||
if (tenantId === "US_ND") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a better approach for scaling this over time than just having to keep appending to this conditional block with new state codes. For example, would it be possible to configure which charts correspond to which narrative per state in /src/contentApi/sources/
? Then all that renderChartPreview
would need to do is invoke retrieveContent(tenantId)
and then return the appropriate MetricVizMapper
depending on the current narrative.id
.
That would seem preferable because /src/contentApi/sources/
is already the location where we expect to add more content and config with each new state, so adding one more thing there means we won't miss it. But if we add one more thing that has to be updated with each new state here in this part of the codebase, we will inevitably miss it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about implementation... If we'll have more states, then we still would need this conditional statement, telling us which exactly types of charts needed for a given state. Or you mean explicitly specify in api files (us_nd
, us_pa
) some sort of flag or list, that would tell us which charts to use as preview? This will need more exploration in types system. @jessex @macfarlandian any thoughts?
Also, other requested changes are resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think expanding the us_nd
and us_pa
content objects to include this configuration sounds like a good idea - that has generally been the pattern we try to follow in this application. That configuration might look similar to what sections
looks like for a narrative: an array of objects that specify a MetricTypeId and whatever other metadata you might need, if any.
It's fine to change the type definition for those content objects as needed, there aren't really any restrictions on what we can include there. It's just meant to collect as much tenant-specific configuration as possible in one place for visibility and ease of making changes.
spotlight-client/src/VizDemographicsByCategory/VizDemographicsByCategory.tsx
Show resolved
Hide resolved
spotlight-client/src/VizDemographicsByCategory/VizDemographicsByCategory.tsx
Show resolved
Hide resolved
spotlight-client/src/VizHistoricalPopulationBreakdown/VizHistoricalPopulationBreakdown.tsx
Outdated
Show resolved
Hide resolved
@macfarlandian I would deploy the frontend to staging myself but it looks like the .ZIP file with the env vars in 1Password is empty for |
@jessex uh oh i'll get on that |
@hobuobi latest version here is on staging now |
Pull Request Test Coverage Report for Build 1217031816
💛 - Coveralls |
@jessex Hey! In case you have missed this - take a look, it should be ready to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me! Thanks so much for this, @nasaownsky. Functionality looks solid in local testing, UI looks like the mocks, and I have no more code comments.
@macfarlandian, would you mind taking a pass through this this week? Ilya has shifted back to some final pre-launch updates for the Cost Calculator for the rest of this week so you have some time. But since this has some non-trivial modeling updates, I want to make sure you're on board before we merge.
@@ -132,7 +160,6 @@ const OtherNarrativeLinks = (): React.ReactElement | null => { | |||
|
|||
const narrativesToDisplay = [ | |||
...Object.values(tenant.systemNarratives), | |||
tenant.racialDisparitiesNarrative, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit of a problem here ... this component is also used at the bottom of each narrative page to provide navigation links to the other pages. The changes here break that feature, such that the link to Racial Disparities never shows up and all of these charts are rendered at the bottom of every page. I think this either needs to be broken out into a separate component (leaving the old component in place for uses other than the homepage) or it needs to have some kind of flag that puts it into "homepage mode" and causes it to render this new format with the chart previews and different link text. I think it would probably be more straightforward to just make a new component for the homepage and restore this one to its former state? It ought to be able to reuse all of the same styled components so hopefully that wouldn't lead to a lot of duplication.
spotlight-client/src/RacialDisparitiesNarrativePage/RacialDisparitiesNarrativePage.test.tsx
Outdated
Show resolved
Hide resolved
@@ -151,6 +151,8 @@ type SystemNarrativeSection = NarrativeSection & { | |||
|
|||
export type SystemNarrativeContent = { | |||
title: string; | |||
subtitle?: string; | |||
preview?: MetricTypeId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the preview field is actually optional in practice? could simplify things a little by just having it be required at the type level, we wouldn't have to check if it's defined before rendering
@@ -90,4 +89,4 @@ export type SystemNarrativeMapping = { | |||
[key in SystemNarrativeTypeId]?: SystemNarrative; | |||
}; | |||
|
|||
export type Narrative = SystemNarrative | RacialDisparitiesNarrative; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per comments about the links above, I don't think we are going to want to make this change in the end.
axes={[ | ||
{ | ||
orient: "left", | ||
tickFormat: formatAsNumber, | ||
tickSize: 0, | ||
}, | ||
]} | ||
baseMarkProps={BASE_MARK_PROPS} | ||
lines={data} | ||
lineStyle={(d: DataSeries) => ({ | ||
fill: | ||
highlighted && highlighted.label !== d.label | ||
? highlightFade(d.color) | ||
: d.color, | ||
stroke: colors.background, | ||
strokeWidth: 1, | ||
})} | ||
// @ts-expect-error Semiotic typedefs are incomplete, this works | ||
lineType={{ type: "stackedarea", sort: null }} | ||
// @ts-expect-error Semiotic typedefs are wrong, can be true for default matte | ||
matte | ||
pointStyle={{ display: "none" }} | ||
xAccessor="date" | ||
yAccessor="count" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think by doing it this way we are creating a bunch of expensive React and Semiotic stuff that we don't intend to render, as well as defining most of the props redundantly?
Rather than duplicating all these props, we should just collect them in a base object that we extend as needed with the additional props needed for the minimap. And instead of instantiating both Frame components we should just conditionally pick one ... could either store that as a variable or conditionally render {preview ? <XYFrame {...chartProps} /> : <MinimapXYFrame {...chartProps} />}
instead of what's currently there.
Hey, @macfarlandian! So I've made all the changes you have requested. Check that out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting very close, @nasaownsky ! other than a couple of nits I commented on here, the main remaining issue is with the navigation links at the bottom of the narrative pages.
If you were to look at, e.g., this page on the live site, it still looks a little different than it does with these changes:
The layout is a bit tighter (can fit four to a row) and the labels don't say "Data" like they do on the new homepage design. We still want the links on those pages to remain unchanged from what they were before, so I think there needs to be even more separation between the components than you have here. And just to give you a heads-up, there is a further change coming (still being spec'ed out, will be a separate ticket) that will include the Racial Disparities link on the homepage but also reshuffle the order, so the functionality of the homepage versus the other pages will diverge even more. I don't think there's going to be much benefit in trying to adapt one component to render both versions, so if breaking the homepage links out into a whole new component makes this easier then you should feel free to make that change now
@macfarlandian ok, I've added brand new component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did one more QA pass and noticed that some of the preview labels didn't match the data we were showing ... noted them in the comments here. I think that should be the last thing on this PR
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Description of the change
Revamp Spotlight state landing page
Type of change
Related issues
Checklists
Development
These boxes should be checked by the submitter prior to merging:
Code review
These boxes should be checked by reviewers prior to merging: