-
Notifications
You must be signed in to change notification settings - Fork 17
New Breadcrumbs component #1828
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
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b7390b4
Breadcrumbs initial version
GomezIvann 37ccdc1
The Breadcrumbs now uses our Dropdown
GomezIvann d219534
Adding tooltip to the Breadcrumbs
GomezIvann 61c0262
Adding core tokens, stories & more
GomezIvann 925309c
Breadcrumbs component tests
GomezIvann 5bc19e7
Adding jest types
GomezIvann 22bca10
Merge branch 'master' into gomezivann/breadcrumbs
GomezIvann 66a39b9
Merge branch 'master' into gomezivann/breadcrumbs
GomezIvann 9b80c6d
Breadcrumbs compatibility with other library links
GomezIvann 3ed3f67
Some fixes to the breadcrumbs
GomezIvann 93b2f6c
Update on the breadcrumbs API
GomezIvann a263c56
More updates to the Breadcrumbs
GomezIvann 99c6510
Merge branch 'master' into gomezivann/breadcrumbs
Mil4n0r c4932dc
Updates based on feedback
GomezIvann 8144ae8
Merge branch 'gomezivann/breadcrumbs' of https://github.com/dxc-techn…
GomezIvann 6de03bd
Added accessibility fixes
Mil4n0r 430ea8a
Merge branch 'gomezivann/breadcrumbs' of github.com:dxc-technology/ha…
Mil4n0r c2f8883
Added @types for jest-axe to move from js to tsx tests
Mil4n0r d023c14
Fixed typo in breadcrumbs import extension
Mil4n0r c66893b
Breadcrumbs updates based on feedback
GomezIvann 26f3851
Merge branch 'master' into gomezivann/breadcrumbs
Jialecl 7f47f8f
Breadcrumbs updates based on feedback
GomezIvann ec7841e
Breadcrumbs stories updated
GomezIvann 1849ef6
More breadcrumbs stories
GomezIvann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| import { toHaveNoViolations } from "jest-axe"; | ||
| import { toHaveNoViolations } from 'jest-axe'; | ||
|
|
||
| expect.extend(toHaveNoViolations); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import React from "react"; | ||
| import { render } from "@testing-library/react"; | ||
| import { axe } from "../../test/accessibility/axe-helper.js"; | ||
| import DxcBreadcrumbs from "./Breadcrumbs"; | ||
| import { disabledRules as rules } from "../../test/accessibility/rules/specific/breadcrumbs/disabledRules.js"; | ||
|
|
||
| const disabledRules = { | ||
| rules: rules.reduce((rulesObj, rule) => { | ||
| rulesObj[rule] = { enabled: false }; | ||
| return rulesObj; | ||
| }, {}), | ||
| }; | ||
|
|
||
| const items = [ | ||
| { | ||
| label: "Home", | ||
| href: "/", | ||
| }, | ||
| { | ||
| label: "User Menu", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Preferences", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Dark Mode", | ||
| href: "", | ||
| }, | ||
| ]; | ||
|
|
||
| describe("Breadcrumbs component accessibility tests", () => { | ||
| it("Should not have basic accessibility issues", async () => { | ||
| const { container } = render(<DxcBreadcrumbs items={items} itemsBeforeCollapse={3} ariaLabel="example" />); | ||
| const results = await axe(container, disabledRules); | ||
| expect(results).toHaveNoViolations(); | ||
| }); | ||
|
|
||
| it("Should not have basic accessibility issues without root", async () => { | ||
| const { container } = render( | ||
| <DxcBreadcrumbs items={items} itemsBeforeCollapse={3} ariaLabel="example" showRoot={false} /> | ||
GomezIvann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| const results = await axe(container, disabledRules); | ||
| expect(results).toHaveNoViolations(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| import React from "react"; | ||
| import Title from "../../.storybook/components/Title"; | ||
| import ExampleContainer from "../../.storybook/components/ExampleContainer"; | ||
| import DxcBreadcrumbs from "./Breadcrumbs"; | ||
| import DxcContainer from "../container/Container"; | ||
| import { HalstackProvider } from "../HalstackContext"; | ||
| import { userEvent, within } from "@storybook/testing-library"; | ||
| import { disabledRules } from "../../test/accessibility/rules/specific/breadcrumbs/disabledRules"; | ||
| import preview from "../../.storybook/preview"; | ||
|
|
||
| export default { | ||
| title: "Breadcrumbs", | ||
| component: DxcBreadcrumbs, | ||
| parameters: { | ||
| a11y: { | ||
| config: { | ||
| rules: [ | ||
| ...disabledRules.map((ruleId) => ({ id: ruleId, enabled: false })), | ||
| ...preview?.parameters?.a11y?.config?.rules, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const items = [ | ||
| { | ||
| label: "Home", | ||
| href: "/", | ||
| }, | ||
| { | ||
| label: "User Menu", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Preferences", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Customization", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Dark Mode", | ||
| href: "", | ||
| }, | ||
| ]; | ||
|
|
||
| const Breadcrumbs = () => ( | ||
| <> | ||
| <Title title="Default" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcBreadcrumbs | ||
| items={[ | ||
| { | ||
| label: "Home", | ||
| href: "/", | ||
| }, | ||
| { | ||
| label: "User Menu", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Preferences", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Dark Mode", | ||
| href: "", | ||
| }, | ||
| ]} | ||
| /> | ||
| </ExampleContainer> | ||
| <Title title="Collapsed variant" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcBreadcrumbs items={items} /> | ||
| </ExampleContainer> | ||
| <Title title="Collapsed variant without root" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcBreadcrumbs items={items} showRoot={false} /> | ||
| </ExampleContainer> | ||
| <Title title="Focus state" theme="light" level={3} /> | ||
| <ExampleContainer pseudoState="pseudo-focus"> | ||
| <DxcBreadcrumbs items={items} /> | ||
| </ExampleContainer> | ||
| <Title title="Hover state" theme="light" level={3} /> | ||
| <ExampleContainer pseudoState="pseudo-hover"> | ||
| <DxcBreadcrumbs items={items} /> | ||
| </ExampleContainer> | ||
| <Title title="Active state" theme="light" level={3} /> | ||
| <ExampleContainer pseudoState="pseudo-active"> | ||
| <DxcBreadcrumbs items={items} /> | ||
| </ExampleContainer> | ||
| <Title title="Truncation and text ellipsis with tooltip (only when collapsed)" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcContainer width="200px"> | ||
| <DxcBreadcrumbs | ||
| items={[ | ||
| { | ||
| label: "Root", | ||
| href: "/", | ||
| }, | ||
| { | ||
| label: "Main folder", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "User", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Very long label for the link", | ||
| href: "", | ||
| }, | ||
| ]} | ||
| itemsBeforeCollapse={3} | ||
| /> | ||
| </DxcContainer> | ||
| </ExampleContainer> | ||
| <Title title="Truncation, text ellipsis with tooltip and without root" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcContainer width="200px"> | ||
| <DxcBreadcrumbs | ||
| items={[ | ||
| { | ||
| label: "Root", | ||
| href: "/", | ||
| }, | ||
| { | ||
| label: "Main folder", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "User", | ||
| href: "", | ||
| }, | ||
| { | ||
| label: "Very long label for the link", | ||
| href: "", | ||
| }, | ||
| ]} | ||
| itemsBeforeCollapse={3} | ||
| showRoot={false} | ||
| /> | ||
| </DxcContainer> | ||
| </ExampleContainer> | ||
| <Title title="Dropdown theming doesn't affect the collapsed trigger" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <Title title="Opinionated theming" theme="light" level={4} /> | ||
| <ExampleContainer> | ||
| <HalstackProvider | ||
| theme={{ | ||
| dropdown: { | ||
| baseColor: "#fabada", | ||
| fontColor: "#999", | ||
| optionFontColor: "#4d4d4d", | ||
| }, | ||
| }} | ||
| > | ||
| <DxcBreadcrumbs items={items} itemsBeforeCollapse={3} /> | ||
| </HalstackProvider> | ||
| </ExampleContainer> | ||
| <Title title="Advanced theming" theme="light" level={4} /> | ||
| <ExampleContainer> | ||
| <HalstackProvider | ||
| advancedTheme={{ | ||
| dropdown: { | ||
| buttonBackgroundColor: "#fabada", | ||
| buttonHeight: "100px", | ||
| buttonBorderThickness: "2px", | ||
| buttonBorderStyle: "solid", | ||
| buttonBorderColor: "#000", | ||
| }, | ||
| }} | ||
| > | ||
| <DxcBreadcrumbs items={items} itemsBeforeCollapse={3} /> | ||
| </HalstackProvider> | ||
| </ExampleContainer> | ||
| </ExampleContainer> | ||
| <Title title="Collapsed variant with dropdown menu opened" theme="light" level={3} /> | ||
| <ExampleContainer> | ||
| <DxcContainer height="200px"> | ||
| <DxcBreadcrumbs items={items} /> | ||
| </DxcContainer> | ||
| </ExampleContainer> | ||
| </> | ||
| ); | ||
|
|
||
| export const Chromatic = Breadcrumbs.bind({}); | ||
| Chromatic.play = async ({ canvasElement }) => { | ||
| const canvas = within(canvasElement); | ||
| const dropdowns = canvas.getAllByRole("button"); | ||
| await userEvent.click(dropdowns[dropdowns.length - 1]); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.