Conversation
|
✔️ 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 |
components/link/link.js
Outdated
| 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> |
There was a problem hiding this comment.
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.
|
|
||
| .status-label { | ||
| @include visually-hidden; | ||
| } |
There was a problem hiding this comment.
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']}> |
| render(<Link href="http://some/url" name="name">hello</Link>); | ||
| expect(screen.getByRole('link')).toHaveTextContent('hello'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Is it possible to test the new label?
catheraaine
left a comment
There was a problem hiding this comment.
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}`} |
| <link rel="icon" href="/favicon.ico" /> | ||
| </Head> | ||
|
|
||
| <Hero /> |
e3ca1a8 to
c90ffd0
Compare
| name="name" | ||
| />); | ||
| const links = screen.getAllByRole('link'); | ||
| expect(links[0]).toHaveAttribute('href', 'https://www.facebook.com/'); |
There was a problem hiding this comment.
@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 thatscreen.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.
c90ffd0 to
8075c09
Compare
8075c09 to
cd9207e
Compare
- 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
cd9207e to
6d134ee
Compare
jonoliver
left a comment
There was a problem hiding this comment.
Thanks for the updates Angus!



Description
FSA21V2-163
Spec
See Story: FSA21V2-163
To Test
npm run test:ci