Skip to content

learning resource drawer v2 run comparison table #1782

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

Merged
merged 11 commits into from
Nov 8, 2024

Conversation

gumaerc
Copy link
Contributor

@gumaerc gumaerc commented Oct 31, 2024

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/5681#issuecomment-2450078182

Description (What does it do?)

This PR adds a table to the new learning resource drawer comparing the price and format between runs of a course, if they are different.

Screenshots (if appropriate):

image
image

How can this be tested?

  • If you have Posthog set up locally, enable the lr_drawer_v2 flag
  • If you don't have Posthog set up locally, you can force drawerV2 to be true in LearningResourceDrawer.tsx
  • Spin up this branch of mit-learn
  • Ensure you have sufficient data backpopulated into your local instance, especially Sloan courses
  • Search for courses that have differing run data:
    • Leading the AI-Driven Organization
    • Becoming a More Digitally Savvy Board Member
    • Managing Product Platforms: Delivering Variety and Realizing Synergies
    • Communication and Persuasion in the Digital Age
  • Ensure that the differing runs table shows up on each of these courses and that the style matches the design
  • Click some other courses on the search page and ensure that they do not show the differing runs table

@gumaerc gumaerc force-pushed the cg/lrd-v2-run-comparison branch 2 times, most recently from 3c8e756 to 2c9c5da Compare November 5, 2024 22:03
@gumaerc gumaerc marked this pull request as ready for review November 6, 2024 18:37
@gumaerc gumaerc added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Nov 6, 2024
Copy link
Contributor

@jonkafton jonkafton left a comment

Choose a reason for hiding this comment

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

Looks good. Veery small changes are to remove decimals from exact dollar amounts and a new line for the location display.

distinctLocations.length > 1
) {
return (
<DifferingRuns data-testid="differing-runs-table">
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work better as an html table? Thinking in terms of Voiceover / accessibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just looked into this a little bit. My impression is that real HTML tables are nice because screenreaders read row and column headers pretty logically and support arrow key navigation more naturally. (Example: with VoiceOver, VO = voiceover modifier combo... VO + down = navigate down, and VO reads header for new row but not for column, since it's the same).

But with the current layout of this table, it's hard to actually implement as a real HTML table:

Screenshot 2024-11-07 at 1 19 20 PM

We can make it look right by using colspan, but then "Location" loses its association with its row, which defeats the a lot of the purpose of using a real table.

I could be wrong, but I don't see a good way to make this a real table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the current navigation, at least in voiceover, seems pretty fine to me.

VO reads
"November 11, 1250 dollars, in person, location: Cambridge, MA, February 10, ..."

which seems ok.

@jonkafton
Copy link
Contributor

It's from a previous PR, but is the title section intended to be fixed/sticky? @steven-hatch @mbilalmughal

Thought it looked a bit odd - could just be me and not an issue on touchscreen.

image

@gumaerc
Copy link
Contributor Author

gumaerc commented Nov 7, 2024

It's from a previous PR, but is the title section intended to be fixed/sticky? @steven-hatch @mbilalmughal

Thought it looked a bit odd - could just be me and not an issue on touchscreen.
image

The header is meant to be sticky, but what seems to be happening here is that the image is having z-index precedence over it.

@gumaerc
Copy link
Contributor Author

gumaerc commented Nov 7, 2024

@jonkafton Thanks for your review. This is ready for another look. @ChristopherChudzicki and I chatted about this some more and we think it's best to not change this to an actual table element, at least not for now. Given how screen readers seem to respond to colspan, I think we should wait for an accessibility review. If they recommend that we change it, we can take another look at the design with @steven-hatch and @mbilalmughal.

@gumaerc gumaerc force-pushed the cg/lrd-v2-run-comparison branch from 4d35704 to 2723143 Compare November 7, 2024 20:05
<span>{run.delivery?.map((dm) => dm?.name).join(", ")}</span>
</DifferingRunData>
)}
{run.delivery.filter((d) => d.code === "in_person").length > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Is run.delivery always an array here as there are conditionals on it above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, according to the API spec it should always be an array. I've also seen it return an array with a single element:

delivery: Array<CourseResourceDeliveryInner>

@@ -88,6 +88,7 @@ const Image = styled(NextImage)({
borderRadius: "8px",
width: "100%",
objectFit: "cover",
zIndex: -1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙃

Copy link
Contributor

@jonkafton jonkafton left a comment

Choose a reason for hiding this comment

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

Comment on lines 44 to 47
.sort(
(a: LearningResourcePrice, b: LearningResourcePrice) =>
Number(a.amount) - Number(b.amount),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

@gumaerc gumaerc force-pushed the cg/lrd-v2-run-comparison branch from 2723143 to 7f0e85f Compare November 8, 2024 17:05
@gumaerc gumaerc merged commit f27d2ce into main Nov 8, 2024
11 checks passed
This was referenced Nov 14, 2024
mbertrand pushed a commit that referenced this pull request Nov 22, 2024
* add first draft of run comparison table

* hide labels on mobile

* update differing run table styles

* add tests

* display table if location is different

* move DifferingRunsTable to its own file

* use getDisplayPrice

* fix CTA image z-index issue

* remove errant console.log

* fix location display

* remove duplicate sort
@rhysyngsun rhysyngsun deleted the cg/lrd-v2-run-comparison branch February 7, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review An open Pull Request that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants