-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/2162-vertical-rhythm
- Loading branch information
Showing
172 changed files
with
2,625 additions
and
1,622 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,5 @@ | ||
--- | ||
'@swisspost/design-system-components': minor | ||
--- | ||
|
||
Added the `post-popover` component. This component can display text and interactive elements in a popover in front of the page content. |
This file contains 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,5 @@ | ||
--- | ||
'@swisspost/design-system-styles': patch | ||
--- | ||
|
||
Fixed close button color in high contrast mode. The button is now visible when forced colors are active. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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 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 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,71 @@ | ||
describe('popover', { baseUrl: null, includeShadowDom: true }, () => { | ||
describe('default', () => { | ||
beforeEach(() => { | ||
cy.visit('./cypress/fixtures/post-popover.test.html'); | ||
// Aria-expanded is set by the web component, therefore it's a good measure to indicate the component is ready | ||
cy.get('[data-popover-target="popover-one"][aria-expanded]').as('trigger'); | ||
cy.get('div.popover-container').as('popover'); | ||
}); | ||
|
||
it('should show up on click', () => { | ||
cy.get('@popover').should('not.be.visible'); | ||
cy.get('@trigger').should('have.attr', 'aria-expanded', 'false'); | ||
cy.get('@trigger').click(); | ||
cy.get('@popover').should('be.visible'); | ||
cy.get('@trigger').should('have.attr', 'aria-expanded', 'true'); | ||
// Void click light dismiss does not work in cypress for closing | ||
}); | ||
|
||
it('should close on X click', () => { | ||
cy.get('@trigger').click(); | ||
cy.get('@popover').should('be.visible'); | ||
cy.get('.btn-close').click(); | ||
cy.get('@popover').should('not.be.visible'); | ||
}); | ||
|
||
it('should open and close on enter', () => { | ||
cy.get('@popover').should('not.be.visible'); | ||
cy.get('@trigger').focus().type('{enter}'); | ||
cy.get('@popover').should('be.visible'); | ||
cy.get('@trigger').type('{enter}'); | ||
cy.get('@popover').should('not.be.visible'); | ||
}); | ||
|
||
it('should open and close with the API', () => { | ||
Promise.all([cy.get('@trigger'), cy.get('@popover')]) | ||
.then( | ||
([$trigger, $popover]: [JQuery<HTMLButtonElement>, JQuery<HTMLPostPopoverElement>]) => [ | ||
$trigger.get(0), | ||
$popover.get(0), | ||
], | ||
) | ||
.then(([trigger, popover]: [HTMLButtonElement, HTMLPostPopoverElement]) => { | ||
cy.get('@popover').should('not.be.visible'); | ||
popover.show(trigger); | ||
cy.get('@popover').should('be.visible'); | ||
popover.hide(); | ||
cy.get('@popover').should('not.be.visible'); | ||
popover.toggle(trigger); | ||
cy.get('@popover').should('be.visible'); | ||
popover.toggle(trigger); | ||
cy.get('@popover').should('not.be.visible'); | ||
}); | ||
}); | ||
|
||
it('should switch position', () => { | ||
cy.get('post-popover').invoke('attr', 'placement', 'top').should('not.be.visible'); | ||
Promise.all([cy.get('@trigger'), cy.get('@popover')]) | ||
.then( | ||
([$trigger, $popover]: [JQuery<HTMLButtonElement>, JQuery<HTMLPostPopoverElement>]) => [ | ||
$trigger.get(0), | ||
$popover.get(0), | ||
], | ||
) | ||
.then(([trigger, popover]: [HTMLButtonElement, HTMLPostPopoverElement]) => { | ||
const t = trigger.getBoundingClientRect(); | ||
const p = popover.getBoundingClientRect(); | ||
expect(t.top < p.top); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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,58 @@ | ||
describe('popovercontainer', { baseUrl: null, includeShadowDom: true }, () => { | ||
describe('default', () => { | ||
let selector = isPopoverSupported() ? ':popover-open' : '.\\:popover-open'; | ||
|
||
beforeEach(() => { | ||
// There is no dedicated docs page for the popovercontainer | ||
cy.visit('./cypress/fixtures/post-popover.test.html'); | ||
cy.get('[data-popover-target="popover-one"][aria-expanded]').as('trigger'); | ||
cy.get('div.popover-container').as('container'); | ||
}); | ||
|
||
it('should show up on click', () => { | ||
cy.get('@container').should('not.be.visible'); | ||
cy.get(selector).should('not.exist'); | ||
cy.get('@trigger').click(); | ||
cy.get('@container').should('be.visible'); | ||
cy.get(selector).should('exist'); | ||
// Light dismiss does not work with cypress triggers | ||
cy.get('.btn-close').click(); | ||
cy.get('@container').should('not.be.visible'); | ||
cy.get(selector).should('not.exist'); | ||
}); | ||
|
||
it('should listen to API calls', () => { | ||
cy.get('@container').should('not.be.visible'); | ||
cy.get(selector).should('not.exist'); | ||
Promise.all([cy.get('@trigger'), cy.get('@container')]) | ||
.then( | ||
([$trigger, $container]: [JQuery<HTMLButtonElement>, JQuery<HTMLPostPopoverElement>]) => [ | ||
$trigger.get(0), | ||
$container.get(0), | ||
], | ||
) | ||
.then(async ([trigger, container]: [HTMLButtonElement, HTMLPostPopoverElement]) => { | ||
await container.show(trigger); | ||
cy.get('@container').should('be.visible'); | ||
cy.get(selector).should('exist'); | ||
await container.hide(); | ||
cy.get('@container').should('not.be.visible'); | ||
cy.get(selector).should('not.exist'); | ||
await container.toggle(trigger); | ||
cy.get('@container').should('be.visible'); | ||
cy.get(selector).should('exist'); | ||
await container.toggle(trigger); | ||
cy.get('@container').should('not.be.visible'); | ||
cy.get(selector).should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function isPopoverSupported() { | ||
return ( | ||
typeof HTMLElement !== 'undefined' && | ||
typeof HTMLElement.prototype === 'object' && | ||
'popover' in HTMLElement.prototype | ||
); | ||
} |
This file contains 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
15 changes: 15 additions & 0 deletions
15
packages/components/cypress/fixtures/post-popover.test.html
This file contains 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,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<script src="../../dist/post-components/post-components.esm.js" type="module"></script> | ||
</head> | ||
<body> | ||
<button data-popover-target="popover-one">toggle</button> | ||
<post-popover id="popover-one"> | ||
<p>This is a test</p> | ||
</post-popover> | ||
</body> | ||
</html> |
This file contains 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 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
Oops, something went wrong.