mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add Modal component
This commit is contained in:
parent
44d4b5b5db
commit
d0d0103bb5
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
@import './menu-bar/index';
|
@import './menu-bar/index';
|
||||||
|
|
||||||
|
@import './modal/index';
|
||||||
|
|
||||||
@import './modals/index';
|
@import './modals/index';
|
||||||
|
|
||||||
@import './network-display/index';
|
@import './network-display/index';
|
||||||
|
2
ui/app/components/modal/index.js
Normal file
2
ui/app/components/modal/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { default } from './modal.component'
|
||||||
|
export { default as ModalContent } from './modal-content'
|
60
ui/app/components/modal/index.scss
Normal file
60
ui/app/components/modal/index.scss
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
@import './modal-content/index';
|
||||||
|
|
||||||
|
.modal-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
overflow-y: auto;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 16px 32px;
|
||||||
|
|
||||||
|
@media screen and (max-width: 575px) {
|
||||||
|
justify-content: center;
|
||||||
|
padding: 28px 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__header {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
padding: 12px;
|
||||||
|
justify-content: center;
|
||||||
|
border-bottom: 1px solid #d2d8dd;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__header-close::after {
|
||||||
|
content: '\00D7';
|
||||||
|
font-size: 40px;
|
||||||
|
color: $dusty-gray;
|
||||||
|
position: absolute;
|
||||||
|
top: -5px;
|
||||||
|
right: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__footer {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row;
|
||||||
|
justify-content: center;
|
||||||
|
border-top: 1px solid #d2d8dd;
|
||||||
|
padding: 16px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
|
||||||
|
&-button {
|
||||||
|
min-width: 0;
|
||||||
|
margin-right: 16px;
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
ui/app/components/modal/modal-content/index.js
Normal file
1
ui/app/components/modal/modal-content/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from './modal-content.component'
|
19
ui/app/components/modal/modal-content/index.scss
Normal file
19
ui/app/components/modal/modal-content/index.scss
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.modal-content {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 16px 0;
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 16px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__description {
|
||||||
|
text-align: center;
|
||||||
|
font-size: .875rem;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
import React, { PureComponent } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
|
export default class ModalContent extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
title: PropTypes.string,
|
||||||
|
description: PropTypes.string,
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { title, description } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-content__title">
|
||||||
|
{ title }
|
||||||
|
</div>
|
||||||
|
<div className="modal-content__description">
|
||||||
|
{ description }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
78
ui/app/components/modal/modal.component.js
Normal file
78
ui/app/components/modal/modal.component.js
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import React, { PureComponent } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
import Button from '../button'
|
||||||
|
|
||||||
|
export default class Modal extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
// Header text
|
||||||
|
headerText: PropTypes.string,
|
||||||
|
// Submit button (right button)
|
||||||
|
onSubmit: PropTypes.func,
|
||||||
|
submitType: PropTypes.string,
|
||||||
|
submitText: PropTypes.string,
|
||||||
|
// Cancel button (left button)
|
||||||
|
onCancel: PropTypes.func,
|
||||||
|
cancelType: PropTypes.string,
|
||||||
|
cancelText: PropTypes.string,
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
submitType: 'primary',
|
||||||
|
cancelType: 'default',
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const {
|
||||||
|
children,
|
||||||
|
headerText,
|
||||||
|
onSubmit,
|
||||||
|
submitType,
|
||||||
|
submitText,
|
||||||
|
onCancel,
|
||||||
|
cancelType,
|
||||||
|
cancelText,
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="modal-container">
|
||||||
|
{
|
||||||
|
headerText && (
|
||||||
|
<div className="modal-container__header">
|
||||||
|
<div className="modal-container__header-text">
|
||||||
|
{ headerText }
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="modal-container__header-close"
|
||||||
|
onClick={() => onCancel()}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<div className="modal-container__content">
|
||||||
|
{ children }
|
||||||
|
</div>
|
||||||
|
<div className="modal-container__footer">
|
||||||
|
{
|
||||||
|
onCancel && (
|
||||||
|
<Button
|
||||||
|
type={cancelType}
|
||||||
|
onClick={onCancel}
|
||||||
|
className="modal-container__footer-button"
|
||||||
|
>
|
||||||
|
{ cancelText }
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<Button
|
||||||
|
type={submitType}
|
||||||
|
onClick={onSubmit}
|
||||||
|
className="modal-container__footer-button"
|
||||||
|
>
|
||||||
|
{ submitText }
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user