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

[PANGOO-2516][BpkNavigationTabGroup] Add Navigation-tab-group component #3599

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

kerrie625
Copy link
Contributor

@kerrie625 kerrie625 commented Aug 29, 2024

During we are doing unified header’s work, we found there is a new navigation tabs component which doesn’t existed in current Backpack components and we need to create one.
So add the Navigation Tab Group component for web, which align with the app

Figma Link

StoryBook

SurfaceContrast:

image

Without Icon SurfaceContrast:

image

CanvasDefault:

image

Without Icon CanvasDefault:
image

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [KOA-123][BpkButton] Updating the colour
  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@kerrie625 kerrie625 added the minor Non breaking change label Aug 29, 2024
Copy link

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

Copy link

github-actions bot commented Aug 29, 2024

Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

⚠️

Package source files (e.g. packages/package-name/src/Component.tsx) were updated, but type files weren't. Have you checked that no types have changed?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 4929ec2

Copy link

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

@kerrie625 kerrie625 changed the title [WIP][PANGOO-2516]Add Navigation-tab-group component [PANGOO-2516]Add Navigation-tab-group component Aug 30, 2024
const flightTextElement = screen.getByText('Flights');
const flightLink = flightTextElement.closest('a');

expect(flightLink).toHaveClass('bpk-navigation-tab-wrap--CanvasDefault');
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
expect(flightLink).toHaveClass('bpk-navigation-tab-wrap--CanvasDefault');
expect(flightLink).toHaveClass('bpk-navigation-tab-wrap--canvas-default');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit1 and commit2

@include borders.bpk-border-sm(tokens.$bpk-text-disabled-on-dark-day);

&:hover {
background-color: tokens.$bpk-core-primary-night;
Copy link
Member

Choose a reason for hiding this comment

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

This wouldn't be this night token and would be a private token :)

If they aren't created in Backpack foundations we will need to create them

Screenshot 2024-08-30 at 09 13 42

Copy link
Contributor Author

@kerrie625 kerrie625 Sep 3, 2024

Choose a reason for hiding this comment

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

I noticed Dark Sky 85 is only exist in Primitive colours . Do you mean I must add this color to Product colours by myself?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found bpk-private-navigation-tab-hover-day already have been added in bpk-foundations-web by this PR ,so use it in Navigation tab group this commit

}

&--canvas-default {
background-color: tokens.$bpk-canvas-day;
Copy link
Member

Choose a reason for hiding this comment

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

We might need to check this with design because I don't think this is to have a fixed background colour and is just an 'outline'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank your clarification, I got it wrong before. As button have default background-color ,so set background-color as transparent in commit

@include borders.bpk-border-sm(tokens.$bpk-core-accent-day);

&:hover {
background-color: tokens.$bpk-core-accent-day;
Copy link
Member

Choose a reason for hiding this comment

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

similar here

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 selected button hover color . It will change to white if not add this background-color.
image

background-color: tokens.$bpk-canvas-day;
color: tokens.$bpk-text-primary-day;

@include borders.bpk-border-sm(tokens.$bpk-text-disabled-day);
Copy link
Member

Choose a reason for hiding this comment

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

This token should be

Suggested change
@include borders.bpk-border-sm(tokens.$bpk-text-disabled-day);
@include borders.bpk-border-sm(tokens.$bpk-line-day);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit

className={tabStyling}
href={tab.href}
onClick={onClick}
aria-current={selected ? 'page' : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

According to the spec if you set aria-current to undefined it will set the value to true and tell the assistive tech that the tab is current: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current#values

So here I would probably see

Suggested change
aria-current={selected ? 'page' : undefined}
aria-current={selected ? 'page' : false}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion .Updated in this commit

className={tabStyling}
type="button"
onClick={onClick}
aria-current={selected ? 'page' : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

<nav
className={containerStyling}
role="navigation"
aria-label="Tab Navigation"
Copy link
Member

Choose a reason for hiding this comment

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

Should this be hard coded like this? What happens when it comes to localisation?

Maybe we need to make this value configurable?

Copy link
Contributor Author

@kerrie625 kerrie625 Sep 3, 2024

Choose a reason for hiding this comment

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

Add airalabel props in this commit

Comment on lines 122 to 132
{Icon ? (
<span
className={getClassName(
'bpk-navigation-tab-icon',
`bpk-navigation-tab-icon--${type}`,
selected && `bpk-navigation-tab-icon--${type}-selected`,
)}
>
<Icon />
</span>
) : null}
Copy link
Member

Choose a reason for hiding this comment

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

I think you can simplify this without the if else by changing to

Suggested change
{Icon ? (
<span
className={getClassName(
'bpk-navigation-tab-icon',
`bpk-navigation-tab-icon--${type}`,
selected && `bpk-navigation-tab-icon--${type}-selected`,
)}
>
<Icon />
</span>
) : null}
{Icon && (
<span
className={getClassName(
'bpk-navigation-tab-icon',
`bpk-navigation-tab-icon--${type}`,
selected && `bpk-navigation-tab-icon--${type}-selected`,
)}
>
<Icon />
</span>
)}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in this commit

selectedIndex={0}
/>,
);
expect(asFragment()).toMatchSnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

We tend to move away from snapshot testing as they can be unreliable.

So here we could do a check for the tabs rendering, such as checking for each of the tabs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove snapshot testing and tabs element test in this commit

Copy link

github-actions bot commented Sep 3, 2024

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

Copy link

github-actions bot commented Sep 3, 2024

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

Copy link

github-actions bot commented Sep 4, 2024

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

Copy link

github-actions bot commented Sep 4, 2024

Visit https://backpack.github.io/storybook-prs/3599 to see this build running in a browser.

@olliecurtis olliecurtis changed the title [PANGOO-2516]Add Navigation-tab-group component [PANGOO-2516][BpkNavigationTabGroup] Add Navigation-tab-group component Sep 6, 2024
@olliecurtis olliecurtis merged commit 6c63d61 into main Sep 6, 2024
9 checks passed
@olliecurtis olliecurtis deleted the navigation-tab-group branch September 6, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Non breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants