forked from liferay/clay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes liferay#1829 - Add Modal.Body, Modal.Footer, Modal.Header and s…
…implifies the use of component
- Loading branch information
1 parent
7653006
commit 992357f
Showing
8 changed files
with
265 additions
and
285 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,27 @@ | ||
/** | ||
* © 2019 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import classNames from 'classnames'; | ||
import React, {FunctionComponent, HTMLAttributes} from 'react'; | ||
|
||
export interface BodyProps extends HTMLAttributes<HTMLDivElement> { | ||
/** | ||
* Url to place an iframe in the body of the modal. | ||
*/ | ||
url?: string; | ||
} | ||
|
||
const Body: FunctionComponent<BodyProps> = ({children, url}) => ( | ||
<div | ||
className={classNames('modal-body', { | ||
'modal-body-iframe': url, | ||
})} | ||
> | ||
{url ? <iframe src={url} title={url} /> : children} | ||
</div> | ||
); | ||
|
||
export default Body; |
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,27 @@ | ||
/** | ||
* © 2019 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import {createContext} from 'react'; | ||
import {Status} from './types'; | ||
|
||
export interface IContext { | ||
/** | ||
* Callback called to close the modal. | ||
*/ | ||
onClose: () => void; | ||
|
||
/** | ||
* The path to the SVG spritemap file containing the icons. | ||
*/ | ||
spritemap?: string; | ||
|
||
/** | ||
* Status messages. | ||
*/ | ||
status?: Status; | ||
} | ||
|
||
export default createContext({} as IContext); |
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,44 @@ | ||
/** | ||
* © 2019 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import Button from '@clayui/button'; | ||
import Context from './Context'; | ||
import Icon from '@clayui/icon'; | ||
import React, {FunctionComponent, HTMLAttributes, useContext} from 'react'; | ||
|
||
export type HeaderProps = HTMLAttributes<HTMLDivElement>; | ||
|
||
const ICON_MAP = { | ||
danger: 'exclamation-full', | ||
info: 'info-circle', | ||
success: 'check-circle', | ||
warning: 'question-circle-full', | ||
}; | ||
|
||
const Header: FunctionComponent<HeaderProps> = ({children}) => { | ||
const {onClose, spritemap, status} = useContext(Context); | ||
|
||
return ( | ||
<div className="modal-header"> | ||
{status && ( | ||
<div className="modal-title-indicator"> | ||
<Icon spritemap={spritemap} symbol={ICON_MAP[status]} /> | ||
</div> | ||
)} | ||
<div className="modal-title">{children}</div> | ||
<Button | ||
aria-label="close" | ||
className="close" | ||
displayType="unstyled" | ||
onClick={onClose} | ||
> | ||
<Icon spritemap={spritemap} symbol="times" /> | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
Oops, something went wrong.