-
Notifications
You must be signed in to change notification settings - Fork 20
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 staging/chansey
- Loading branch information
Showing
13 changed files
with
201 additions
and
48 deletions.
There are no files selected for viewing
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 @@ | ||
--- | ||
"@rhds/elements": patch | ||
--- | ||
|
||
`<rh-tile>`: corrected icon slot visibility with a slotted icon |
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 @@ | ||
--- | ||
"@rhds/elements": patch | ||
--- | ||
|
||
`<rh-dialog>`: ensure that `cancel`, `open`, and `closed` events fire |
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
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,37 @@ | ||
<form id="dialog-events"> | ||
<rh-dialog id="dialog" trigger="trigger"> | ||
<h2 slot="header">Modal dialog with a header</h2> | ||
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt | ||
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut | ||
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu | ||
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit | ||
anim id est laborum.</p> | ||
<rh-cta> | ||
<a href="#bar">Learn more</a> | ||
</rh-cta> | ||
</rh-dialog> | ||
<rh-button id="trigger">Open</rh-button> | ||
<fieldset> | ||
<legend>Events Fired</legend> | ||
<output name="events">No events yet</output> | ||
</fieldset> | ||
</form> | ||
|
||
<script type="module"> | ||
import '@rhds/elements/rh-button/rh-button.js'; | ||
import '@rhds/elements/rh-cta/rh-cta.js'; | ||
import '@rhds/elements/rh-dialog/rh-dialog.js'; | ||
|
||
const dialog = document.getElementById('dialog'); | ||
const form = document.getElementById('dialog-events'); | ||
const events = []; | ||
form.addEventListener('submit', e => e.preventDefault()); | ||
const onDialogEvent = event => { | ||
events.push(event.type); | ||
form.elements.events.value = events.join(', '); | ||
}; | ||
dialog.addEventListener('close', onDialogEvent); | ||
dialog.addEventListener('open', onDialogEvent); | ||
dialog.addEventListener('cancel', onDialogEvent); | ||
</script> | ||
|
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 |
---|---|---|
@@ -1,18 +1,97 @@ | ||
import { expect, html } from '@open-wc/testing'; | ||
import { expect, html, oneEvent } from '@open-wc/testing'; | ||
import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js'; | ||
import { clickElementAtOffset } from '@patternfly/pfe-tools/test/utils.js'; | ||
import { sendKeys } from '@web/test-runner-commands'; | ||
import { RhDialog } from '@rhds/elements/rh-dialog/rh-dialog.js'; | ||
import { RhButton } from '@rhds/elements/rh-button/rh-button.js'; | ||
|
||
const element = html` | ||
<rh-dialog></rh-dialog> | ||
`; | ||
function press(key: string) { | ||
return async function() { | ||
await sendKeys({ press: key }); | ||
}; | ||
} | ||
|
||
describe('<rh-dialog>', function() { | ||
it('should upgrade', async function() { | ||
const el = await createFixture<RhDialog>(element); | ||
const el = await createFixture<RhDialog>(html` | ||
<rh-dialog></rh-dialog> | ||
`); | ||
const klass = customElements.get('rh-dialog'); | ||
expect(el) | ||
.to.be.an.instanceOf(klass) | ||
.and | ||
.to.be.an.instanceOf(RhDialog); | ||
}); | ||
describe('with a trigger', function() { | ||
let element: RhDialog; | ||
let trigger: RhButton; | ||
const updateComplete = () => element.updateComplete; | ||
beforeEach(async function() { | ||
element = await createFixture(html` | ||
<rh-dialog trigger="trigger"> | ||
<h2 slot="header">Header</h2> | ||
<p>Body</p> | ||
<rh-button slot="footer">Footer Action</rh-button> | ||
</rh-dialog> | ||
<rh-button id="trigger">Open</rh-button> | ||
`); | ||
trigger = document.getElementById('trigger')!; | ||
}); | ||
describe('clicking the trigger', function() { | ||
let openEventPromise: Promise<Event>; | ||
let closeEventPromise: Promise<Event>; | ||
let cancelEventPromise: Promise<Event>; | ||
beforeEach(function() { | ||
openEventPromise = oneEvent(element, 'open'); | ||
closeEventPromise = oneEvent(element, 'close'); | ||
cancelEventPromise = oneEvent(element, 'cancel'); | ||
}); | ||
beforeEach(() => trigger.click()); | ||
beforeEach(updateComplete); | ||
it('opens the dialog', function() { | ||
expect(element.open).to.be.true; | ||
}); | ||
it('fires "open" event', async function() { | ||
const openEvent = await openEventPromise; | ||
expect(openEvent.type).to.equal('open'); | ||
}); | ||
describe('pressing Escape', function() { | ||
beforeEach(press('Escape')); | ||
beforeEach(updateComplete); | ||
it('closes the dialog', function() { | ||
expect(element.open).to.be.false; | ||
}); | ||
it('fires the cancel event', async function() { | ||
const cancelEvent = await cancelEventPromise; | ||
expect(cancelEvent.type).to.equal('cancel'); | ||
}); | ||
}); | ||
describe('clicking outside the dialog', function() { | ||
beforeEach(() => clickElementAtOffset(document.body, [10, 10])); | ||
beforeEach(updateComplete); | ||
it('closes the dialog', function() { | ||
expect(element.open).to.be.false; | ||
}); | ||
it('fires the cancel event', async function() { | ||
const cancelEvent = await cancelEventPromise; | ||
expect(cancelEvent.type).to.equal('cancel'); | ||
}); | ||
}); | ||
describe('clicking the close button', function() { | ||
// ordinarily we try our best to avoid querying the shadow root in test files | ||
// in this case, we feel justified in making an exception, because the "close-button" | ||
// css part is already included in the element's public API. | ||
// NOTE: we query specifically for the element with that part, not by shadow class or id | ||
beforeEach(() => element.shadowRoot.querySelector('[part="close-button"]')?.click()); | ||
beforeEach(updateComplete); | ||
it('closes the dialog', function() { | ||
expect(element.open).to.be.false; | ||
}); | ||
it('fires the close event', async function() { | ||
const closeEvent = await closeEventPromise; | ||
expect(closeEvent.type).to.equal('close'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,36 @@ | ||
<!-- Slotted Icon --> | ||
<rh-tile> | ||
<img slot="icon" src="https://fakeimg.pl/24x24" alt=""> | ||
<div slot="title">Title</div> | ||
<h2 slot="headline"><a href="#top">Link</a></h2> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
<div slot="footer">Suspendisse eu turpis elementum</div> | ||
</rh-tile> | ||
|
||
<!-- PFE icon --> | ||
<rh-tile icon="check-circle"> | ||
<div slot="title">Title</div> | ||
<h2 slot="headline"><a href="#top">Link</a></h2> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
<div slot="footer">Suspendisse eu turpis elementum</div> | ||
</rh-tile> | ||
|
||
<!-- No icon --> | ||
<rh-tile> | ||
<div slot="title">Title</div> | ||
<h2 slot="headline"><a href="#top">Link</a></h2> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
<div slot="footer">Suspendisse eu turpis elementum</div> | ||
</rh-tile> | ||
|
||
<script type="module"> | ||
import '@rhds/elements/rh-tile/rh-tile.js'; | ||
</script> | ||
|
||
<link rel="stylesheet" href="../rh-tile-lightdom.css"> | ||
|
||
<style> | ||
rh-tile { | ||
margin-inline-end: var(--rh-space-md, 8px); | ||
} | ||
</style> |
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