-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modal): add modal component - FRONT-3858 (#2776)
- Loading branch information
Showing
45 changed files
with
1,515 additions
and
10 deletions.
There are no files selected for viewing
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,2 @@ | ||
__snapshots__ | ||
*.js |
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,59 @@ | ||
# ECL Modal component | ||
|
||
npm package: `@ecl/twig-component-modal` | ||
|
||
```shell | ||
npm install --save @ecl/twig-component-modal | ||
``` | ||
|
||
### Parameters: | ||
|
||
- **"id"** (string) (default: '') id of the modal | ||
- **"toggle_id"** (string) (default: '') id of the element to toggle the modal | ||
- **"icon_path"** (string) (default: '') Path to the icon sprite | ||
- **"close_label"** (string) (default: '') Label of the close button (for screen reader only) | ||
- **"header_icon"** (associative array) (default: {}): Optional icon in the header, following ECL Icon structure | ||
- **"buttons"** (array) (default: {}) Array of ECL Button, displayed in the modal footer | ||
- **"extra_classes"** (optional) (string) (default: '') Extra classes (space separated) | ||
- **"extra_attributes"** (optional) (array) (default: []) Extra attributes | ||
- "name" (string) Attribute name, eg. 'data-test' | ||
- "value" (string) Attribute value, eg: 'data-test-1' | ||
|
||
### Blocks: | ||
|
||
- **"header"**: free block to put any content in the modal header | ||
- **"body"**: free block to put any content in the modal body | ||
- **"footer"**: free block to put any content in the modal footer | ||
|
||
### Example: | ||
|
||
<!-- prettier-ignore --> | ||
```twig | ||
{% include '@ecl/modal/modal.html.twig' with { | ||
id: 'modal-example', | ||
toggle_id: 'modal-toggle', | ||
icon_path: '/icons.svg', | ||
close_label: 'Close', | ||
header_icon: { | ||
icon: { | ||
name: 'warning', | ||
}, | ||
extra_classes: 'ecl-u-type-color-warning', | ||
}, | ||
header: 'Lorem ipsum dolor sit amet', | ||
body: 'Sed quam augue, volutpat sed dapibus in, accumsan a arcu. Nulla quam enim, porttitor at neque a, egestas porttitor tortor. Nam tortor sem, elementum id augue quis, posuere vestibulum dui. Donec id posuere libero, sit amet egestas lorem. Aliquam finibus ipsum mauris, a molestie tortor laoreet.', | ||
buttons: [ | ||
{ | ||
label: 'Secondary action', | ||
type: 'button', | ||
variant: 'secondary', | ||
extra_attributes: [{name: 'data-ecl-modal-close'}], | ||
}, | ||
{ | ||
label: 'Primary action', | ||
type: 'submit', | ||
variant: 'primary', | ||
}, | ||
], | ||
} %} | ||
``` |
247 changes: 247 additions & 0 deletions
247
src/implementations/twig/components/modal/__snapshots__/modal.test.js.snap
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,247 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Modal Collapsed renders correctly 1`] = ` | ||
<jest> | ||
<dialog | ||
class="ecl-modal" | ||
data-ecl-auto-init="Modal" | ||
data-ecl-modal-toggle="modal-toggle" | ||
id="modal-example" | ||
> | ||
<div | ||
class="ecl-modal__container ecl-container" | ||
> | ||
<div | ||
class="ecl-modal__content ecl-col-12 ecl-col-m-8 ecl-offset-m-2 ecl-col-l-6 ecl-offset-l-3" | ||
> | ||
<header | ||
class="ecl-modal__header" | ||
> | ||
<div | ||
class="ecl-modal__header-content" | ||
> | ||
Lorem ipsum dolor sit amet | ||
</div> | ||
<button | ||
class="ecl-button ecl-button--ghost ecl-modal__close" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
<span | ||
class="ecl-button__container" | ||
> | ||
<span | ||
class="ecl-u-sr-only" | ||
data-ecl-label="true" | ||
> | ||
Close | ||
</span> | ||
<svg | ||
aria-hidden="true" | ||
class="ecl-icon ecl-icon--s ecl-button__icon ecl-button__icon--after" | ||
data-ecl-icon="" | ||
focusable="false" | ||
> | ||
<use | ||
xlink:href="/icons.svg#close-filled" | ||
/> | ||
</svg> | ||
</span> | ||
</button> | ||
</header> | ||
<div | ||
class="ecl-modal__body" | ||
> | ||
Sed quam augue, volutpat sed dapibus in, accumsan a arcu. Nulla quam enim, porttitor at neque a, egestas porttitor tortor. Nam tortor sem, elementum id augue quis, posuere vestibulum dui. Donec id posuere libero, sit amet egestas lorem. Aliquam finibus ipsum mauris, a molestie tortor laoreet. | ||
</div> | ||
<footer | ||
class="ecl-modal__footer" | ||
> | ||
<div | ||
class="ecl-modal__footer-content" | ||
> | ||
<button | ||
class="ecl-button ecl-button--secondary ecl-modal__button" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
Secondary action | ||
</button> | ||
<button | ||
class="ecl-button ecl-button--primary ecl-modal__button" | ||
type="submit" | ||
> | ||
Primary action | ||
</button> | ||
</div> | ||
</footer> | ||
</div> | ||
</div> | ||
</dialog> | ||
</jest> | ||
`; | ||
|
||
exports[`Modal Collapsed renders correctly with extra attributes 1`] = ` | ||
<jest> | ||
<dialog | ||
class="ecl-modal" | ||
data-ecl-auto-init="Modal" | ||
data-ecl-modal-toggle="modal-toggle" | ||
data-test="data-test-value" | ||
data-test-1="data-test-value-1" | ||
id="modal-example" | ||
null="" | ||
> | ||
<div | ||
class="ecl-modal__container ecl-container" | ||
> | ||
<div | ||
class="ecl-modal__content ecl-col-12 ecl-col-m-8 ecl-offset-m-2 ecl-col-l-6 ecl-offset-l-3" | ||
> | ||
<header | ||
class="ecl-modal__header" | ||
> | ||
<div | ||
class="ecl-modal__header-content" | ||
> | ||
Lorem ipsum dolor sit amet | ||
</div> | ||
<button | ||
class="ecl-button ecl-button--ghost ecl-modal__close" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
<span | ||
class="ecl-button__container" | ||
> | ||
<span | ||
class="ecl-u-sr-only" | ||
data-ecl-label="true" | ||
> | ||
Close | ||
</span> | ||
<svg | ||
aria-hidden="true" | ||
class="ecl-icon ecl-icon--s ecl-button__icon ecl-button__icon--after" | ||
data-ecl-icon="" | ||
focusable="false" | ||
> | ||
<use | ||
xlink:href="/icons.svg#close-filled" | ||
/> | ||
</svg> | ||
</span> | ||
</button> | ||
</header> | ||
<div | ||
class="ecl-modal__body" | ||
> | ||
Sed quam augue, volutpat sed dapibus in, accumsan a arcu. Nulla quam enim, porttitor at neque a, egestas porttitor tortor. Nam tortor sem, elementum id augue quis, posuere vestibulum dui. Donec id posuere libero, sit amet egestas lorem. Aliquam finibus ipsum mauris, a molestie tortor laoreet. | ||
</div> | ||
<footer | ||
class="ecl-modal__footer" | ||
> | ||
<div | ||
class="ecl-modal__footer-content" | ||
> | ||
<button | ||
class="ecl-button ecl-button--secondary ecl-modal__button" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
Secondary action | ||
</button> | ||
<button | ||
class="ecl-button ecl-button--primary ecl-modal__button" | ||
type="submit" | ||
> | ||
Primary action | ||
</button> | ||
</div> | ||
</footer> | ||
</div> | ||
</div> | ||
</dialog> | ||
</jest> | ||
`; | ||
|
||
exports[`Modal Collapsed renders correctly with extra class names 1`] = ` | ||
<jest> | ||
<dialog | ||
class="ecl-modal custom-class custom-class--test" | ||
data-ecl-auto-init="Modal" | ||
data-ecl-modal-toggle="modal-toggle" | ||
id="modal-example" | ||
> | ||
<div | ||
class="ecl-modal__container ecl-container" | ||
> | ||
<div | ||
class="ecl-modal__content ecl-col-12 ecl-col-m-8 ecl-offset-m-2 ecl-col-l-6 ecl-offset-l-3" | ||
> | ||
<header | ||
class="ecl-modal__header" | ||
> | ||
<div | ||
class="ecl-modal__header-content" | ||
> | ||
Lorem ipsum dolor sit amet | ||
</div> | ||
<button | ||
class="ecl-button ecl-button--ghost ecl-modal__close" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
<span | ||
class="ecl-button__container" | ||
> | ||
<span | ||
class="ecl-u-sr-only" | ||
data-ecl-label="true" | ||
> | ||
Close | ||
</span> | ||
<svg | ||
aria-hidden="true" | ||
class="ecl-icon ecl-icon--s ecl-button__icon ecl-button__icon--after" | ||
data-ecl-icon="" | ||
focusable="false" | ||
> | ||
<use | ||
xlink:href="/icons.svg#close-filled" | ||
/> | ||
</svg> | ||
</span> | ||
</button> | ||
</header> | ||
<div | ||
class="ecl-modal__body" | ||
> | ||
Sed quam augue, volutpat sed dapibus in, accumsan a arcu. Nulla quam enim, porttitor at neque a, egestas porttitor tortor. Nam tortor sem, elementum id augue quis, posuere vestibulum dui. Donec id posuere libero, sit amet egestas lorem. Aliquam finibus ipsum mauris, a molestie tortor laoreet. | ||
</div> | ||
<footer | ||
class="ecl-modal__footer" | ||
> | ||
<div | ||
class="ecl-modal__footer-content" | ||
> | ||
<button | ||
class="ecl-button ecl-button--secondary ecl-modal__button" | ||
data-ecl-modal-close="" | ||
type="button" | ||
> | ||
Secondary action | ||
</button> | ||
<button | ||
class="ecl-button ecl-button--primary ecl-modal__button" | ||
type="submit" | ||
> | ||
Primary action | ||
</button> | ||
</div> | ||
</footer> | ||
</div> | ||
</div> | ||
</dialog> | ||
</jest> | ||
`; |
Oops, something went wrong.
1055530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed on https://v3-8-0-dev--europa-component-library.netlify.app