Skip to content

Commit

Permalink
feat: Add useCanvasProvider hook and customTheme prop
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel.carrera committed Oct 25, 2024
1 parent d5be4cb commit 77bc04e
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 430 deletions.
29 changes: 14 additions & 15 deletions cypress/component/Breadcrumbs.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ function getDropdownMenu() {
return cy.findByRole('menu');
}

function getDropdownMenuItem(number?: number) {
return number ? cy.findAllByRole('menuitem').eq(number) : cy.findAllByRole('menuitem');
}

function openDropdownMenu() {
const dropdownButton = getDropdownButton();
dropdownButton.focus();
Expand Down Expand Up @@ -113,7 +109,6 @@ describe('Breadcrumbs', () => {
() => {
beforeEach(() => {
cy.mount(<OverflowBreadcrumbs />);
cy.wait(150);
});

it('should not have any axe errors', () => {
Expand All @@ -139,9 +134,11 @@ describe('Breadcrumbs', () => {
context('when action list container is only 480px wide', () => {
beforeEach(() => {
cy.findByRole('button', {name: '480px'}).click();
cy.findByText('Current Container Width: 480px');
});

it('should have 4 items inside the "list"', () => {
// cy.findByText('Current Container Width: 480px');
cy.findByRole('list').findAllByRole('listitem').should('have.length', 4);
});

Expand All @@ -155,18 +152,19 @@ describe('Breadcrumbs', () => {
});

it('should contain second link as the first menu item', () => {
cy.findAllByRole('menuitem').eq(0).should('contain', 'Second Link');
cy.get('[role="menuitem"]').first().should('contain', 'Second Link');
});

it('should contain fifth link as the last menu item', () => {
cy.findAllByRole('menuitem').eq(-1).should('contain', 'Fifth Link');
cy.get('[role="menuitem"]').last().should('contain', 'Fifth Link');
});
});
});

context('when action list container is only 250px wide', () => {
beforeEach(() => {
cy.findByRole('button', {name: '250px'}).click();
cy.findByText('Current Container Width: 250px');
});

it('should have 3 list items inside the "list"', () => {
Expand All @@ -183,18 +181,19 @@ describe('Breadcrumbs', () => {
});

it('should contain second link as the first menu item', () => {
cy.findAllByRole('menuitem').eq(0).should('contain', 'Second Link');
cy.get('[role="menuitem"]').first().should('contain', 'Second Link');
});

it('should contain fifth link as the last menu item', () => {
cy.findAllByRole('menuitem').eq(-1).should('contain', 'Sixth Link');
cy.get('[role="menuitem"]').last().should('contain', 'Sixth Link');
});
});
});

context('when action list container is only 150px wide', () => {
beforeEach(() => {
cy.findByRole('button', {name: '150px'}).click();
cy.findByText('Current Container Width: 150px');
});

it('should have 2 list items inside the "list"', () => {
Expand Down Expand Up @@ -227,9 +226,10 @@ describe('Breadcrumbs', () => {
() => {
beforeEach(() => {
cy.mount(<OverflowBreadcrumbs />);
cy.wait(150);
cy.findByRole('button', {name: '480px'}).click();
cy.findByText('Current Container Width: 480px');
openDropdownMenu();
cy.findByText('Overflow visibility: visible');
});

it('should not have any axe errors', () => {
Expand All @@ -254,14 +254,13 @@ describe('Breadcrumbs', () => {

context('when the dropdown menu is toggled with a keypress', () => {
it('should set focus to the first menu item', () => {
getDropdownMenuItem(0).should('have.focus');
cy.get('[role="menuitem"]').first().focused().should('contain', 'Second Link');
});
});

context('when the first menu item is focused', () => {
beforeEach(() => {
cy.focused().realType('{downarrow}');
cy.wait(0);
});

it('should toggle focus to the second menu item on down keypress', () => {
Expand All @@ -279,14 +278,13 @@ describe('Breadcrumbs', () => {
cy.focused().realType('{downarrow}');
cy.focused().realType('{downarrow}');
cy.focused().realType('{downarrow}');
getDropdownMenuItem(0).should('have.focus');
cy.get('[role="menuitem"]').first().should('contain', 'Second Link');
});
});

context('when the down arrow key is pressed on the dropdown menu', () => {
beforeEach(() => {
cy.focused().realType('{downarrow}');
cy.wait(0);
});

it('should toggle focus to the next menu item on down keypress', () => {
Expand All @@ -303,7 +301,8 @@ describe('Breadcrumbs', () => {

it('should toggle focus to the previous list item', () => {
cy.focused().realType('{uparrow}');
getDropdownMenuItem(0).should('have.focus');
cy.focused().contains('Second Link').should('exist');
cy.focused().first().should('contain', 'Second Link');
});

it('should return focus from the first menu item to the last', () => {
Expand Down
5 changes: 5 additions & 0 deletions modules/react/_examples/stories/mdx/Density.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
import {Density} from './examples/Density';
import {DensityComponents} from './examples/DensityComponents';

<Meta title="Examples/Forms/Density and Alignment" />

Expand All @@ -10,3 +11,7 @@ options to users, especially in the context of forms. Below is an example of how
from elements to achieve the desired density.

<ExampleCodeBlock code={Density} />

To view how density is being applied to components, view below.

<ExampleCodeBlock code={DensityComponents} />
Loading

0 comments on commit 77bc04e

Please sign in to comment.