added modal footer

This commit is contained in:
Florian Scholdei
2019-02-07 13:53:15 +01:00
parent b3a3162d34
commit 9fae4c7d46
3 changed files with 40 additions and 32 deletions

View File

@@ -29,25 +29,32 @@ class ConfirmAlert extends React.Component<Props> {
render() { render() {
const { title, message, buttons } = this.props; const { title, message, buttons } = this.props;
const body= ( const body = <>{message}</>;
<>
{message} const footer = (
<div className="buttons is-right"> <div className="field is-grouped">
{buttons.map((button, i) => ( {buttons.map((button, i) => (
<a className="button is-info is-right" <p className="control">
<a
className="button is-info"
key={i} key={i}
onClick={() => this.handleClickButton(button)} onClick={() => this.handleClickButton(button)}
> >
{button.label} {button.label}
</a> </a>
</p>
))} ))}
</div> </div>
</>
); );
return ( return (
<Modal title={title} closeFunction={() => this.close()} body={body} active={true}/> <Modal
title={title}
closeFunction={() => this.close()}
body={body}
active={true}
footer={footer}
/>
); );
} }
} }

View File

@@ -7,6 +7,7 @@ type Props = {
title: string, title: string,
closeFunction: () => void, closeFunction: () => void,
body: any, body: any,
footer?: any,
active: boolean, active: boolean,
classes: any classes: any
}; };
@@ -19,42 +20,35 @@ const styles = {
} }
}; };
class Modal extends React.Component<Props> { class Modal extends React.Component<Props> {
render() { render() {
const { title, closeFunction, body, active, classes } = this.props; const { title, closeFunction, body, footer, active, classes } = this.props;
const isActive = active ? "is-active" : null; const isActive = active ? "is-active" : null;
let showFooter = null;
if (footer) {
showFooter = <footer className="modal-card-foot">{footer}</footer>;
}
return ( return (
<div className={classNames( <div className={classNames("modal", isActive)}>
"modal",
isActive
)}>
<div className="modal-background" /> <div className="modal-background" />
<div className={classNames("modal-card", classes.resize)}> <div className={classNames("modal-card", classes.resize)}>
<header className="modal-card-head"> <header className="modal-card-head">
<p className="modal-card-title"> <p className="modal-card-title">{title}</p>
{title}
</p>
<button <button
className="delete" className="delete"
aria-label="close" aria-label="close"
onClick={closeFunction} onClick={closeFunction}
/> />
</header> </header>
<section className="modal-card-body"> <section className="modal-card-body">{body}</section>
{body} {showFooter}
</section>
</div> </div>
</div> </div>
); );
} }
} }
export default injectSheet(styles)(Modal); export default injectSheet(styles)(Modal);

View File

@@ -314,3 +314,10 @@ $fa-font-path: "webfonts";
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
} }
// modal
.modal {
.modal-card-foot {
justify-content: flex-end; // pulled-right
}
}