Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modal-box): added modal description element #2646

Merged
merged 1 commit into from Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/patternfly/components/ModalBox/examples/ModalBox.md
Expand Up @@ -76,6 +76,26 @@ cssPrefix: pf-c-modal-box
{{/modal-box}}
```

```hbs title=With-description
{{#> modal-box modal-box--attribute='aria-labelledby="modal-with-description-title" aria-describedby="modal-with-description-description"'}}
{{#> button button--modifier="pf-m-plain" button--attribute='aria-label="Close"'}}
<i class="fas fa-times" aria-hidden="true"></i>
{{/button}}
{{#> title titleType="h1" title--modifier="pf-m-2xl" title--attribute='id="modal-with-description-title"'}}
Modal header
{{/title}}
{{#> modal-box-description modal-box-description--attribute='id="modal-with-description-description"'}}
A description is used when you want to provide more info about the modal than the title is able to describe. The content in the description is static and will not scroll with the rest of the modal body.
{{/modal-box-description}}
{{#> modal-box-body}}
To support screen reader user awareness of the dialog text, the dialog text is wrapped in a div that is referenced by aria-describedby.
{{/modal-box-body}}
{{#> modal-box-footer modal-box-footer--modifier="pf-m-align-left"}}
Modal footer
{{/modal-box-footer}}
{{/modal-box}}
```

## Documentation
### Overview
A modal box is a generic rectangular container that can be used to build modals. A modal box can have three sections: header, body, and footer. Header or body is required. If no `.pf-c-title` is used, `aria-label="[title of modal]"` must be provided for `.pf-c-modal-box`.
Expand All @@ -98,7 +118,8 @@ A modal box is a generic rectangular container that can be used to build modals.
| `.pf-c-modal-box` | `<div>` | Initiates a modal box. **Required** |
| `.pf-c-button.pf-m-plain` | `<button>` | Initiates a modal box close button. **Required** |
| `.pf-c-title` | `<h1>`,`<h2>`,`<h3>`,`<h4>`,`<h5>`,`<h6>` | Initiates a title. Always use it with a modifier class. |
| `.pf-c-modal-box__body` | `<div>` | Initiates a modal box body. A modal box body is **required** if there is no modal box header. |
| `.pf-c-modal-box__description` | `<div>` | Initiates a modal box description. A modal title and modal body are **required** if using a modal description. |
| `.pf-c-modal-box__body` | `<div>` | Initiates a modal box body. A modal box body is **required** if there is no modal box title. |
| `.pf-c-modal-box__footer` | `<footer>` | Initiates a modal box footer. |
| `.pf-m-sm` | `.pf-c-modal-box` | Modifies for a small modal box width. |
| `.pf-m-lg` | `.pf-c-modal-box` | Modifies for a large modal box width. |
Expand Down
6 changes: 6 additions & 0 deletions src/patternfly/components/ModalBox/modal-box-description.hbs
@@ -0,0 +1,6 @@
<div class="pf-c-modal-box__description{{#if modal-box-description--modifier}} {{modal-box-description--modifier}}{{/if}}"
{{#if modal-box-description--attribute}}
{{{modal-box-description--attribute}}}
{{/if}}>
{{> @partial-block}}
</div>
16 changes: 15 additions & 1 deletion src/patternfly/components/ModalBox/modal-box.scss
Expand Up @@ -14,8 +14,12 @@
--pf-c-modal-box--m-lg--lg--MaxWidth: #{pf-size-prem(1120px)};
--pf-c-modal-box--MaxHeight: calc(100vh - var(--pf-global--spacer--2xl)); // MaxHeight ensures that the modal will not go off the screen and instead the body will scroll

// Description
--pf-c-modal-box__c-title--description--MarginTop: var(--pf-global--spacer--sm);

// Body
--pf-c-modal-box--body--MinHeight: calc(var(--pf-global--FontSize--md) * var(--pf-global--LineHeight--md)); // Allow for at least 1 line of content in the body
--pf-c-modal-box__description--body--MarginTop: var(--pf-global--spacer--lg);
--pf-c-modal-box--c-title--body--MarginTop: var(--pf-global--spacer--lg);

// Close
Expand Down Expand Up @@ -70,17 +74,27 @@
}
}

.pf-c-title {
> .pf-c-title {
@include pf-text-overflow;

flex: 0 0 auto;

+ .pf-c-modal-box__description {
margin-top: var(--pf-c-modal-box__c-title--description--MarginTop);
}

+ .pf-c-modal-box__body {
margin-top: var(--pf-c-modal-box--c-title--body--MarginTop);
}
}
}

.pf-c-modal-box__description {
+ .pf-c-modal-box__body {
margin-top: var(--pf-c-modal-box__description--body--MarginTop);
}
}

// Body
.pf-c-modal-box__body {
flex: 1 1 auto;
Expand Down
8 changes: 6 additions & 2 deletions src/patternfly/demos/Modal/examples/Modal.md
Expand Up @@ -42,8 +42,12 @@ section: demos
<i class="fas fa-times" aria-hidden="true"></i>
{{/button}}
{{#> title titleType="h1" title--modifier="pf-m-2xl" title--attribute='id="modal-scroll-title"'}}
This is a long header title that will truncate because modal titles should be very short. Use the modal body to provide more info. {{/title}}
{{#> modal-box-body modal-box-body--attribute='id="modal-scroll-description"'}}
This is a long header title that will truncate because modal titles should be very short. Use the modal body to provide more info.
{{/title}}
{{#> modal-box-description modal-box-description--attribute='id="modal-scroll-description"'}}
This is a modal description. The description will not scroll with the body contents.
{{/modal-box-description}}
{{#> modal-box-body}}
<p>general_modal_final_finalfinal_v9_actualfinal.sketch</p>
<p>A file with this name already exists, would you like to overwrite the existing file or save a new copy?</p>
<p>Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Integer tincidunt. Integer tincidunt. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
Expand Down
26 changes: 0 additions & 26 deletions src/patternfly/demos/Modal/examples/modal-example.hbs

This file was deleted.

26 changes: 0 additions & 26 deletions src/patternfly/demos/Modal/examples/modal-lg-example.hbs

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions src/patternfly/demos/Modal/examples/modal-scroll-example.hbs

This file was deleted.