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

Issue 456/home page structure enhancements #516

Merged
merged 33 commits into from
Nov 27, 2023

Conversation

xscottxbrownx
Copy link
Contributor

This PR:

Resolves #456

1. Added PASS logo and text to use as h1 - my understanding is we are switching to this logo. Need a higher quality version.
2. Refactored headers of home page to follow semantic outline.
3. Added <main> to layout - only thing marked as main semantically previously was this home logged out page, nothing else.
4. Added some conditional rendering to solve issue of adding empty elements to DOM.

Screenshots:

Screen.Recording.2023-11-13.at.11.44.29.AM.mov

Future Steps/PRs Needed to Finish This Work (optional):

  • Need to figure out what to do for proper headers in footer - wasn't sure because it depends on what page is being rendered currently (I think.)
  • Also believe the Home.jsx page can be refactored. Seems like some props are being passed to child components, that could just be initialized in those components themselves. Could also possibly be arrays of objects and .map()'ed - but not sure that would cut down code or improve readability until attempted. I do believe it would make for easier maintainability/changes in future.

Issues needing discussion/feedback (optional):

1. Styling feedback
2. Code review

@xscottxbrownx xscottxbrownx added enhancement Enhancement of existing features refactor/optimization General label for refactoring, optimizing, or reorganizing codebase labels Nov 13, 2023
@xscottxbrownx xscottxbrownx self-assigned this Nov 13, 2023
Copy link
Member

@andycwilliams andycwilliams left a comment

Choose a reason for hiding this comment

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

Just some thoughts. I possibly overlooked a few things in this initial look through.

The tests are failing here, but I'm assuming they're waiting to be updated once we settle on what direction we want to go?

Also, I believe we discuss (a little) about slightly changing the desktop layout by having the images and associated text alternate side-by-side. That could free up a bit of space and make it flow a little more nicely but wouldn't really work on the mobile version, which should probably just remain as is. Assuming we even want this change.

src/components/Home/HomeSection.jsx Outdated Show resolved Hide resolved
src/pages/Home.jsx Outdated Show resolved Hide resolved
src/pages/Home.jsx Outdated Show resolved Hide resolved
src/pages/Home.jsx Outdated Show resolved Hide resolved
src/pages/Home.jsx Outdated Show resolved Hide resolved
src/components/Home/HomeSection.jsx Outdated Show resolved Hide resolved
src/layouts/Layout.jsx Show resolved Hide resolved
@xscottxbrownx
Copy link
Contributor Author

Latest attempt:
https://github.com/codeforpdx/PASS/assets/71395931/1d89fa06-7f5e-46c6-a9ae-8fa78803f14c

Still have some code work to do for proper headings, then to tackle tests.


Let me know any feedback on this design.

@andycwilliams
Copy link
Member

Latest attempt: https://github.com/codeforpdx/PASS/assets/71395931/1d89fa06-7f5e-46c6-a9ae-8fa78803f14c

Still have some code work to do for proper headings, then to tackle tests.

Let me know any feedback on this design.

The video isn't rendering but I downloaded it.

Overall I think it's getting better.


Line 70 I think could be an h4 on smaller viewports. On the desktop version it's fine.

Also, when I try out mobile I see this, where its not formatted as nicely as in the video.

Capture

I've tried reloading and resizing but it doesn't change. Not sure what's causing it.


Using our primary theme color instead of black would be nicer and more consistent in my opinion. I don't recall if we have a version of the PASS logo with that yet, though.

Also, we use a version of the logo with the PASS text within the image. So I'm not sure if we want to use that here as well. But it doesn't really seem necessary and would maybe limit our responsiveness a bit.


In case you weren't already aware, the Learn More button does not function correctly. Plus it overlaps with the other elements on certain viewports.


Honestly, at this point I'd just like to get UX's perspective. We may be winging it a bit too much.

@xscottxbrownx
Copy link
Contributor Author

Latest attempt: https://github.com/codeforpdx/PASS/assets/71395931/1d89fa06-7f5e-46c6-a9ae-8fa78803f14c
Still have some code work to do for proper headings, then to tackle tests.
Let me know any feedback on this design.

The video isn't rendering but I downloaded it.

Overall I think it's getting better.

Line 70 I think could be an h4 on smaller viewports. On the desktop version it's fine.

Also, when I try out mobile I see this, where its not formatted as nicely as in the video.

Capture I've tried reloading and resizing but it doesn't change. Not sure what's causing it.

Using our primary theme color instead of black would be nicer and more consistent in my opinion. I don't recall if we have a version of the PASS logo with that yet, though.

Also, we use a version of the logo with the PASS text within the image. So I'm not sure if we want to use that here as well. But it doesn't really seem necessary and would maybe limit our responsiveness a bit.

In case you weren't already aware, the Learn More button does not function correctly. Plus it overlaps with the other elements on certain viewports.

Honestly, at this point I'd just like to get UX's perspective. We may be winging it a bit too much.

video not rendering
yeah it seems when github changed that you can't just click in the textbox and add an image/video, but now have to click the paperclip button to do so - they also limited video size. Any larger files (haven't figured out exact size yet) seem to make you download file instead of just play it.


Changed line 70 per your thoughts, looks better in my opinion.


Changed to green, but we don't have logo in that color yet that I could find.


I was told the logo that has the PASS text combined is not properly optimized and doesn't scale well, so I didn't attempt it.


Learn More
Yeah, I haven't seemed to figure out anchor "scroll to" links in MUI yet. I'll dig into it - if you happen to know by chance, let me know.


UX perspective
yeah pretty much most of the discussion now is not technically in the scope of this PR to fix the headings.

Copy link
Contributor

@timbot1789 timbot1789 left a comment

Choose a reason for hiding this comment

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

Looks like this is failing a bunch of unit tests. If we still havent settled on a design for the front page, it may be worthwhile to loosen up these tests so they don't fail on areas we haven't finalized yet.

@xscottxbrownx
Copy link
Contributor Author

Looks like this is failing a bunch of unit tests. If we still havent settled on a design for the front page, it may be worthwhile to loosen up these tests so they don't fail on areas we haven't finalized yet.

Just tagged in milo to attempt to solve our idea for a better h1 for this page, and I'm moving onto the tests. Honestly, looking into them I don't believe they are the best written and may need to write a new approach. But I'm just starting this now.

@timbot1789
Copy link
Contributor

I think you can remove the HomeSection unit tests. It seems to me that this is a section in too heavy development for those to be all that useful (and there's not too much interesting behavior on this page anyway).

The Home.jsx snapshot test will need to either be updated with npm run test -- --update-snapshot, or replaced with a similar render test that shows it's rendering the content.

Copy link
Contributor

@leekahung leekahung left a comment

Choose a reason for hiding this comment

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

Finished going through the code, think it's about ready to go along with PR #531.

Just a few minor issues that needs addressing, but they seem pretty easy to fix/do (see feedback).

src/pages/Home.jsx Show resolved Hide resolved
src/pages/Home.jsx Outdated Show resolved Hide resolved
@leekahung leekahung self-requested a review November 22, 2023 21:54
Copy link
Contributor

@leekahung leekahung left a comment

Choose a reason for hiding this comment

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

From my end, think this is ready for merging.

@andycwilliams
Copy link
Member

I'm getting this error. Not sure if it's really app breaking or not. If it doesn't interfere then this should be good. The home page looks much cleaner and more professional now.

2023-11-22 (19)

And I'd like to have a primary color version of the logo but that can wait.

Also, just remembered that the "Request a demo" button goes directly to Hugh's email. Is that what we'll ultimately want?

@leekahung
Copy link
Contributor

I'm getting this error. Not sure if it's really app breaking or not. If it doesn't interfere then this should be good. The home page looks much cleaner and more professional now.

2023-11-22 (19) And I'd like to have a primary color version of the logo but that can wait.

Ah, good catch! Yeah, it looks like there's an extra ref set within one of the <HomeSection> components (Line 111 in Home.jsx). That should be removed to get rid of the error. Only the parent <div> needs it.

Copy link
Contributor

@leekahung leekahung left a comment

Choose a reason for hiding this comment

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

See feedback for error in console

src/pages/Home.jsx Outdated Show resolved Hide resolved
@@ -7,19 +7,19 @@ import createMatchMedia from '../../helpers/createMatchMedia';
const MockKeyFeaturesDefault = () => <KeyFeatures description="Example Text" />;
const MockKeyFeaturesMobile = () => <KeyFeatures isReallySmallScreen description="Example Text" />;

it('renders 67% width default', () => {
it('renders 85% width default', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine, but tests tied to specific CSS values like this probably won't be very resilient. I don't think we'd want this test to fail if someone decides that actually 84% is better for desktop than 85%. We may want to associate the test with more significant values/ranges. Here it looks like mobile always renders 100%, which seems like a pretty set value. So something like expect(descriptionStyles.width).not.toBe('100%') may be more reliable.

In general we may be able to make tests like 'It renders desktop display on desktop' which checks for a desktopLayout class, and then a 'It renders mobile display on mobile' which checks for a mobileLayout class. Then we can update the precise details of the class as we need without causing the tests to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fully agreed and something discussed in depth in our discord DM.

Changed all to have a base value so .toBe(basevalue) & .not.toBe(basevalue)

This is SLIGHTLY more resilient, but not by much as when base value changes you have the same effect.
I think all CSS value based tests are no good. Maybe adjusting tests to be more resilient is a future issue for the code base?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the bigger question is what exactly is this supposed to be testing? If we are testing whether or not our styles change at certain values, I think it would make more sense to create a function that tests whether this does what it's supposed to to set isReallySmallScreen in src/components/Messages/MessageButtonGroup.jsx:

  const isReallySmallScreen = useMediaQuery('(max-width: 480px)');

If we can test useMediaQuery, then we won't really need to use these tests, will we?

Copy link
Contributor

@milofultz milofultz Nov 25, 2023

Choose a reason for hiding this comment

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

I agree that they are very temperamental. Since they are directly coupled with hard coded values, it will either be annoying or ignored by future devs, which kind of invalidates the purpose of tests, which is an alarm for unexpected changes. All that being said, trying to ensure the DOM doesn't change based on what we perceive to be unrelated changes is useful, but that's a great case for snapshots, not behavior-driven tests.

If we can test behaviors for the user, like black-box testing, then that will be more resilient. And I think will also let us ask whether or not a test is useful, but that is only my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I follow 100%, but I also believe that testing that react is doing react is silly and unnecessary. The maintainers of react and MUI are testing them, we don't need to as well. I don't think we need to test if useMediaQuery works either. Kind of the point of using a library.

I feel like the behavior (testing onclicks and such) should be done.

I'm not sold on checking css/styling or if mobile component is rendering in mobile screen or if desktop component is rendering in desktop screen. It will render whatever we tell it to render.

I'm not sure, I'm still studying.

describe('Home Page', () => {
afterEach(cleanup);
// if tests are failing check this value vs value in Home.jsx
const h1FontSize = '144px';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as 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.

This is the same thing. This is the current base value - so .toBe(basevalue) & other tests expect .not.toBe(basevalue).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather it be something like this, so I can check the ordered of the rendered elements:

it('renders mobile', () => {
    window.matchMedia = createMatchMedia(599);
    render(<Home />);
    const h1 = screen.getByTestId('testStack');
    const { children } = h1;
    
    expect(children[0].toEqual(<Typography />));
  });

then desktop would just be like expect(children[0].not.toEqual(<Typography />));

but can't seem to figure out syntax or where in docs to find much besides the matchers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok this seemingly works for the intention:

describe('Home Page', () => {
  afterEach(cleanup);

  it('renders with correct order of logoSection on mobile', () => {
    window.matchMedia = createMatchMedia(599);
    render(<Home />);
    const h1 = screen.getByTestId('testStack');
    const children = Array.from(h1.children);

    expect(children.length).toBe(3);
    expect(children[0].tagName.toLowerCase()).toBe('span');
    expect(children[1].tagName.toLowerCase()).toBe('img');
    expect(children[2].tagName.toLowerCase()).toBe('span');
  });

  it('rrenders with correct order of logoSection on desktop', () => {
    window.matchMedia = createMatchMedia(1200);
    render(<Home />);
    const h1 = screen.getByTestId('testStack');
    const children = Array.from(h1.children);

    expect(children.length).toBe(2);
    expect(children[0].tagName.toLowerCase()).toBe('span');
    expect(children[1].tagName.toLowerCase()).toBe('span');
  });
});

Copy link
Contributor

Choose a reason for hiding this comment

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

This to me still feels very fragile. We're testing the exact order of the DOM, when for the user, none of this matters. If the goal is to ensure that the DOM doesn't change, let's just rely on snapshots as that seems more accurate for the purpose. Otherwise, I think tests should be testing the behavior that the user will experience

Copy link
Contributor Author

@xscottxbrownx xscottxbrownx Nov 26, 2023

Choose a reason for hiding this comment

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

This to me still feels very fragile. We're testing the exact order of the DOM, when for the user, none of this matters. If the goal is to ensure that the DOM doesn't change, let's just rely on snapshots as that seems more accurate for the purpose. Otherwise, I think tests should be testing the behavior that the user will experience

But the goal for this was not to ensure the DOM doesn't change. Quite the contrary. In this particular component that is being tested, the DOM should be different for mobile and desktop. This tests just that, without the reliance on a css style check.

This is your h1 section that you figured out the nested syntax of.

@xscottxbrownx
Copy link
Contributor Author

@milofultz feel like taking a look at these tests to see if anything sticks out to you as well?

@milofultz
Copy link
Contributor

Honestly, an overhaul of making our test suites more focused, resilient, and effective to their intended purposes should probably be a different issue/PR, as this can become really side quest-y

@xscottxbrownx xscottxbrownx merged commit d2c555a into Development Nov 27, 2023
3 checks passed
@xscottxbrownx xscottxbrownx deleted the issue-456/home-page-structure-enhancements branch November 27, 2023 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing features refactor/optimization General label for refactoring, optimizing, or reorganizing codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Different heading levels used for styling purposes instead of semantically on the home page
5 participants