1.7.6 • Published 1 year ago

@justeattakeaway/pie-modal v1.7.6

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@justeattakeaway/pie-modal

Source Code | Design Documentation | NPM

@justeattakeaway/pie-modal is a Web Component built using the Lit library. It offers a simple and accessible modal component for web applications.

Table of Contents

Installation

To install any of our web components in your application, we would suggest following the getting started guide to set up your project.

Ideally, you should install the component using the @justeattakeaway/pie-webc package, which includes all of the components. Or you can install the individual component package.

Documentation

Properties

PropOptionsDescriptionDefault
ariaAn object representing the aria labels for the close and back buttons within the modal as well as the isLoading state labels (aria-label & aria-busy).
hasBackButtontrue, falseIf true, the modal includes a back button which closes the modal when clicked.false
hasStackedActionstrue, falseIf true, the action buttons will be stacked (full width) at narrow breakpoints.false
headingThe heading text of the modal.
headingLevelh1, h2, h3, h4, h5, h6The HTML tag to use for the modal's heading.h2
isDismissibletrue, falseIf true, the modal includes a close button and can be dismissed by clicking on the backdrop or pressing the Esc key.false
isFooterPinnedtrue, falseWhen false, the modal footer will scroll with the content inside the modal body.true
isFullWidthBelowMidtrue, falseIf true and the page is narrower than the mid breakpoint, a medium-sized modal will take up the full width of the screen.false
isLoadingtrue, falseWhen true, displays a loading spinner in the modal.false
isOpentrue, falseControls if the modal element is open or closed.false
leadingAction.textThe text to display inside the leading action button. The button won't render without this.
leadingAction.variantSee pie-button's variantsThe variant of the leading action button."primary"
supportingAction.textThe text to display inside the supporting action button. The button won't render without this.
supportingAction.variantSee pie-button's variantsThe variant of the supporting action button."ghost"
position"center", "top"The position of the modal; this controls where it will appear on the page."center"
returnFocusAfterCloseSelectorIf provided, focus will be sent to the first element that matches this selector when the modal is closed. If not provided, the dialog element will return focus to the element that opened the modal.
size"small", "medium", "large"Determines the maximum width of the modal. Large modals will expand to fill the entire page at narrow viewports."medium"

Slots

SlotDescription
defaultThe default slot is used to pass content into the modal component.
footerUsed to pass optional content to the modal component footer area.

CSS Variables

This component does not expose any CSS variables for style overrides.

Events

EventTypeDescription
pie-modal-openCustomEventTriggered when the modal is opened.
pie-modal-closeCustomEventTriggered when the modal is closed.
pie-modal-backCustomEventTriggered when the modal back button is clicked.
pie-modal-leading-action-clickCustomEventTriggered when the modal leading action is clicked.
pie-modal-supporting-action-clickCustomEventTriggered when the modal supporting action is clicked.

Legacy browser support

pie-modal uses the Dialog element which might not be supported by legacy browsers.

To support them, pie-modal uses the dialog-polyfill package. It works automatically and doesn't need any setup.

The polyfill comes with a few limitations, as noted on its documentation page:

Dialogs should not be contained by parents that create a stacking context

  • The browser's chrome may not always be accessible via the tab key
  • Changes to the CSS top/bottom values while open aren't retained
  • For more details, check the package documentation mentioned above.

Usage Examples

For HTML:

// import as module into a js file e.g. main.js
import '@justeattakeaway/pie-webc/components/modal.js'
<!-- pass js file into <script> tag -->
<pie-modal heading='My Awesome Heading' headingLevel='h3'>Click me!</pie-modal>
<script type="module" src="/main.js"></script>

With a custom footer slot:

<pie-modal heading='My Awesome Heading' headingLevel='h3'>
  <p>Click me!</p>
  <div slot="footer">
    <p>Custom footer content!</p>
  </div>
</pie-modal>

For Native JS Applications, Vue, Angular, Svelte etc.:

// Vue templates (using Nuxt 3)
import '@justeattakeaway/pie-webc/components/modal.js';

<pie-modal heading="My Awesome Heading" headingLevel="h3">Click me!</pie-modal>

For React Applications:

import { PieModal } from '@justeattakeaway/pie-webc/react/modal.js';

<PieModal heading='My Awesome Heading' headingLevel='h3'>Click me!</PieModal>

Questions and Support

If you work at Just Eat Takeaway.com, please contact us on #help-designsystem. Otherwise, please raise an issue on Github.

Contributing

Check out our contributing guide for more information on local development and how to run specific component tests.

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.7.6

1 year ago

1.7.5

1 year ago

1.7.4

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

0.49.3

2 years ago

0.49.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

0.49.2

2 years ago

0.48.0

2 years ago

0.48.1

2 years ago

0.49.1

2 years ago

0.49.0

2 years ago

0.47.1

2 years ago

0.46.2

2 years ago

0.46.1

2 years ago

0.47.0

2 years ago

0.43.0

2 years ago

0.44.0

2 years ago

0.45.0

2 years ago

0.42.8

2 years ago

0.42.6

2 years ago

0.42.7

2 years ago

0.43.5

2 years ago

0.43.3

2 years ago

0.43.4

2 years ago

0.43.1

2 years ago

0.43.2

2 years ago

0.46.0

2 years ago

0.42.5

2 years ago

0.42.4

2 years ago

0.42.3

2 years ago

0.42.2

2 years ago

0.42.1

2 years ago

0.42.0

2 years ago

0.42.0-alpha.0

2 years ago

0.41.0

2 years ago

0.40.0

2 years ago

0.39.0

2 years ago

0.38.8

2 years ago

0.38.7

2 years ago

0.38.6

2 years ago

0.38.5

2 years ago

0.38.4

2 years ago

0.38.3

2 years ago

0.38.2

2 years ago

0.38.1

2 years ago

0.38.0

2 years ago

0.37.0

2 years ago

0.36.2

2 years ago

0.36.1

2 years ago

0.36.0

2 years ago

0.35.6

2 years ago

0.35.5

3 years ago

0.35.4

3 years ago

0.20.0

3 years ago

0.19.0

3 years ago

0.19.1

3 years ago

0.34.1

3 years ago

0.32.3

3 years ago

0.34.0

3 years ago

0.32.2

3 years ago

0.32.1

3 years ago

0.11.0

3 years ago

0.13.0

3 years ago

0.17.0

3 years ago

0.32.0

3 years ago

0.30.0

3 years ago

0.29.0

3 years ago

0.27.0

3 years ago

0.25.0

3 years ago

0.23.0

3 years ago

0.9.0

3 years ago

0.32.3-next.0

3 years ago

0.21.0

3 years ago

0.35.3

3 years ago

0.35.2

3 years ago

0.35.1

3 years ago

0.35.0

3 years ago

0.33.1

3 years ago

0.33.1-next.0

3 years ago

0.33.0

3 years ago

0.12.0

3 years ago

0.14.0

3 years ago

0.16.0

3 years ago

0.18.0

3 years ago

0.10.0

3 years ago

0.31.0

3 years ago

0.28.0

3 years ago

0.26.0

3 years ago

0.24.0

3 years ago

0.22.0

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago