-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc09ab
commit 450b5ea
Showing
6 changed files
with
490 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
import { Meta, Story } from "@storybook/addon-docs"; | ||
import { | ||
Modal, | ||
ModalWithButtons, | ||
ModalScrolling, | ||
ModalTinymce, | ||
ModalFullscreen, | ||
ModalLarge, | ||
} from "./modal.stories.js"; | ||
|
||
<Meta title="Patterns/Modal" /> | ||
|
||
# Modal | ||
|
||
Show content in a modal. | ||
|
||
## Configuration | ||
|
||
```md | ||
| Option | Type | Default | Description | | ||
| :---------------------------: | :-----------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| height | string | '' | Set the height of the modal, for example: 250px | | ||
| width | string | '' | Set the width of the modal, for example: 80% or 500px. | | ||
| modalSizeClass | string | '' | Set the modal size class, for example: modal-sm, modal-lg, modal-xl or modal-fullscreen. | | ||
| margin | function or integer | 20 | A function, Integer or String which will be used to set the margin of the modal in pixels. If a function is passed it must return an Integer. | | ||
| position | string | 'center middle' | Position the modal relative to the window with the format: "<horizontal> <vertical>" -- allowed values: top, bottom, left, right, center, middle. | | ||
| triggers | array | [] | Add event listeners to elements on the page which will open the modal when triggered. Pass an Array of strings with the format `["EVENT SELECTOR"]` or `["EVENT"]`. For example, `["click .someButton"]`. If you pass in only an event such as, `["change"]`, the event listener will be added to the element on which the modal was initiated, usually a link or button. | | ||
| title | string | null | A string to place in the modal header. If title is provided, titleSelector is not used. | | ||
| titleSelector | string | 'h1:first' | Selector for an element to extract from the content provided to the modal and place in the modal header. | | ||
| content | string | '#content' | Selector for an element within the content provided to the modal to use as the modal body. | | ||
| prependContent | string | '.portalMessage' | Selector for elements within the content provided to the modal which will be collected and inserted, by default above, the modal content. This is useful for extracting things like alerts or status messages on forms and displaying them to the user after an AJAX response. | | ||
| backdrop | string | 'body' | Selector for the element upon which the Backdrop pattern should be initiated. The Backdrop is a full width mask that will be apply above the content behind the modal which is useful for highlighting the modal dialog to the user. | | ||
| backdropOptions | object | { zIndex: "1040", opacity: "0.8", className: "backdrop", classActiveName: "backdrop-active", closeOnEsc: true, closeOnClick: true } | Look at options at backdrop pattern. | | ||
| buttons | string | '.formControls > input[type="submit"]' | Selector for matching elements, usually buttons, inputs or links, from the modal content to place in the modal footer. The original elements in the content will be hidden. | | ||
| automaticallyAddButtonActions | boolean | true | Automatically create actions for elements matched with the buttons selector. They will use the options provided in actionOptions. | | ||
| loadLinksWithinModal | boolean | true | Automatically load links inside of the modal using AJAX. | | ||
| actionOptions | object | {} | A hash of selector to options. Where options can include any of the defaults from actionOptions. Allows for the binding of events to elements in the content and provides options for handling ajax requests and displaying them in the modal. | | ||
| onSuccess | Function | string | | function which is called with parameters (modal, response, state, xhr, form) when form has been successfully submitted. if value is a string, this is the name of a function at window level | | ||
| onFormError | Function | string | | function which is called with parameters (modal, response, state, xhr, form) when backend has sent an error after form submission. if value is a string, this is the name of a function at window level | | ||
| onError | Function | string | | function which is called with parameters (xhr, textStatus, errorStatus) when form submission has failed. if value is a string, this is the name of a function at window level | | ||
``` | ||
|
||
## Examples | ||
|
||
### Basic Modal | ||
|
||
<br /> | ||
<Story name="Modal" of={Modal} /> | ||
|
||
```html | ||
<a | ||
href="#modal1" | ||
class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal" | ||
data-pat-plone-modal="width: 400" | ||
>Modal basic</a | ||
> | ||
<div id="modal1" style="display: none"> | ||
<h1>Basic modal!</h1> | ||
<p>Indeed. Whoa whoa whoa whoa. Wait.</p> | ||
</div> | ||
``` | ||
|
||
### Modal with Buttons | ||
|
||
<br /> | ||
<Story name="Modal With Buttons" of={ModalWithButtons} /> | ||
|
||
```html | ||
<a | ||
href="#modal2" | ||
class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal" | ||
data-pat-plone-modal="{'width': '400', 'buttons': ['.plone-btn']}" | ||
>Modal basic</a | ||
> | ||
<div id="modal2" style="display: none"> | ||
<h1>Basic modal!</h1> | ||
<p>Indeed. Whoa whoa whoa whoa. Wait.</p> | ||
</div> | ||
``` | ||
|
||
### Modal scrolling | ||
|
||
<br /> | ||
<Story name="Modal Scrolling" of={ModalScrolling} /> | ||
|
||
```html | ||
<a | ||
href="#modal3" | ||
class="plone-btn plone-btn-lg plone-btn-primary pat-plone-modal" | ||
data-pat-plone-modal="width: 500" | ||
>Modal long scrolling</a | ||
> | ||
<div id="modal3" style="display: none"> | ||
<h1>Basic with scrolling</h1> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor | ||
incididunt ut labore et dolore magna aliqua | ||
</p> | ||
</div> | ||
``` | ||
|
||
### Modal with TinyMCE | ||
|
||
<br /> | ||
<Story name="Modal Tinymce" of={ModalTinymce} /> | ||
|
||
```html | ||
<a | ||
href="#modaltinymce" | ||
class="btn btn-lg btn-primary pat-plone-modal" | ||
data-pat-plone-modal="height: 600px; width: 80%" | ||
> | ||
Modal with TinyMCE</a | ||
> | ||
<div id="modaltinymce" style="display: none"> | ||
<textarea class="pat-tinymce"></textarea> | ||
</div> | ||
``` | ||
|
||
### Modal Fullscreen | ||
|
||
<br /> | ||
<Story name="Modal Fullscreen" of={ModalFullscreen} /> | ||
|
||
```html | ||
<a | ||
href="#modal4" | ||
class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal" | ||
data-pat-plone-modal="modalSizeClass: modal-fullscreen; margin: 0;" | ||
>Modal fullscreen!</a | ||
> | ||
<div id="modal4" style="display: none"> | ||
<h1>Basic screen modal!</h1> | ||
<p>Indeed. Whoa whoa whoa whoa. Wait.</p> | ||
</div> | ||
``` | ||
|
||
### Modal Large | ||
|
||
<br /> | ||
<Story name="Modal Large" of={ModalLarge} /> | ||
|
||
```html | ||
<a | ||
href="#modal5" | ||
class="plone-btn plone-btn-large plone-btn-primary pat-plone-modal" | ||
data-pat-plone-modal="modalSizeClass: modal-lg;" | ||
>Modal large!</a | ||
> | ||
<div id="modal5" style="display: none"> | ||
<h1>Basic screen modal!</h1> | ||
<p>Indeed. Whoa whoa whoa whoa. Wait.</p> | ||
</div> | ||
``` |
Oops, something went wrong.