Skip to content

feat: Semantic HTML Audit#32

Merged
auaruss merged 1 commit intomainfrom
refactor--semantic-html
Dec 10, 2021
Merged

feat: Semantic HTML Audit#32
auaruss merged 1 commit intomainfrom
refactor--semantic-html

Conversation

@changangus
Copy link
Copy Markdown
Contributor

Description

  • Apprentice cmp
    • article to div
    • h2 to h3
    • pass name prop to SocialLinks for link aria labels
    • update test to reflect new alt text for images
  • Apprentice Status cmp
    • Add visually hidden span that will act as label for employee status
  • Link cmp
    • Use name prop to create dynamic aria labels for a tag
    • update tests
  • Previous Apprentice cmp
    • article to section
    • section to div
    • add z-index to scss module (padding was covering current apprentice links)
  • Previous Apprentice Group cmp
    • p to h3
    • add aria label to label apprentice group version
  • SocialLinks cmp
    • take passed in name prop and pass it into Link cmp
    • update tests
  • Home Page
    • move hero outside of main tag
  • Updated snapshot

FSA21V2-163

Spec

See Story: FSA21V2-163

To Test

  1. Make sure all PR Checks have passed (Github Actions, Netlify etc).
  2. Pull down all related branches.
  3. Confirm all tests pass: npm run test:ci

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for sb-apprentices ready!

🔨 Explore the source changes: 6d134ee

🔍 Inspect the deploy log: https://app.netlify.com/sites/sb-apprentices/deploys/61b38b039914bd00071a21fc

😎 Browse the preview: https://deploy-preview-32--sb-apprentices.netlify.app

@changangus changangus requested a review from jonoliver December 6, 2021 18:21
const Link = ({ href, children }) => (
<a className={styles.link} href={href}>{children}</a>
const Link = ({ href, name, children }) => (
<a className={styles.link} href={href} aria-label={`${name}'s ${children}'`}>{children}</a>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is a generic Link component, as opposed to something with a more specific purpose (eg a single SocialLink component), I don't think that name is the appropriate level of abstraction here. I think the prop should just be aria-label, and the current logic for formatting that string lifted from the component into the parent.

In this case, it looks like this is only used in the context of SocialLinks, so I think the string formatting can go directly in that component. Hypothetically, if we did need to reuse a component that included the name formatting, we could use composition: a SocialLink component which accepts the name, then passes the formatted name to the underlying generic Link component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds good to me


.status-label {
@include visually-hidden;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just making a note: Let's be sure to coordinate this merge with #31 since it includes the extracted mixin

/>
</svg>
<>
<span className={styles['status-label']}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

render(<Link href="http://some/url" name="name">hello</Link>);
expect(screen.getByRole('link')).toHaveTextContent('hello');
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to test the new label?

Copy link
Copy Markdown
Contributor

@catheraaine catheraaine left a comment

Choose a reason for hiding this comment

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

LGTM, once Jon checks that change he requested, I'm good if he wants to approve.

<p
<h3
className={styles['previous-apprentices-group__version']}
aria-label={`Previous apprentices group version ${version}`}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love this.

<link rel="icon" href="/favicon.ico" />
</Head>

<Hero />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, easy fix

@changangus changangus force-pushed the refactor--semantic-html branch 3 times, most recently from e3ca1a8 to c90ffd0 Compare December 9, 2021 17:03
name="name"
/>);
const links = screen.getAllByRole('link');
expect(links[0]).toHaveAttribute('href', 'https://www.facebook.com/');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@changangus since we moved the logic to format the ariaLabel prop to this component, I think it's appropriate to test that formatting here. I suggest that we split the current renders links given an href and text in the correct order test into two tests:

  • renders multiple social links in the correct order: use the current test data with 2 social links. the test will assert that screen.getAllByRole('link') has a length of 2, and that the text content of each link is correct. No need to test other link attributes in this test.
  • renders a social link: the test data will include a single social link, the test will assert that the link contains the href, text, and formatted aria label.

@changangus changangus requested a review from jonoliver December 10, 2021 13:28
@changangus changangus force-pushed the refactor--semantic-html branch from c90ffd0 to 8075c09 Compare December 10, 2021 13:29
@jonoliver
Copy link
Copy Markdown
Member

Hey Angus, there are just a few more minor spacing issues I noticed. The padding on the the left of the header elements and what appear to be additional columns in the grid layout cause a few minor differences across sections. These issues are mostly visible on large screens. I think that addressing these will bring all sections, other than apprentice qualities, into alignment.

Remove the left padding on this element, as well as the logo. This will align the left side with the sections below.
Screen Shot 2021-12-10 at 10 39 25 AM

Remove the additional spacing on the right of the grid in the hero:
Screen Shot 2021-12-10 at 10 38 58 AM

Remove the additional spacing on the right of the grid in the CTA:
Screen Shot 2021-12-10 at 10 39 44 AM

@changangus changangus force-pushed the refactor--semantic-html branch from 8075c09 to cd9207e Compare December 10, 2021 17:10
- Hero cmp
	- remove padding on logo and text container
	- remove 2 empty cols from hero art grid
- Apprentice cmp
	- article to div
	- h2 to h3
	- pass name prop to SocialLinks for link aria labels
	- update test to reflect new alt text for images
- Apprentice Status cmp
	-  Add visually hidden span that will act as label for employee status
- Link cmp
	- Use ariaLabel  prop to create dynamic aria labels for a tag
	- update tests
- Previous Apprentice cmp
	- article to section
	- section to div
	- add z-index to scss module (padding was covering current apprentice links)
- Previous Apprentice Group cmp
	- p to h3
	- add aria label to label apprentice group version
- SocialLinks cmp
	- take passed in name prop and pass it into Link cmp
	- update tests
- Cta cmp
	- remove 2 empty cols from cta art grid
- Home Page
	- move hero outside of main tag
- Updated snapshot

FSA21V2-163
@changangus changangus force-pushed the refactor--semantic-html branch from cd9207e to 6d134ee Compare December 10, 2021 17:14
Copy link
Copy Markdown
Member

@jonoliver jonoliver left a comment

Choose a reason for hiding this comment

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

Thanks for the updates Angus!

@auaruss auaruss merged commit 6d134ee into main Dec 10, 2021
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.

4 participants