From 9a9b74665f26dc7ca813b443f224c0134d97ad27 Mon Sep 17 00:00:00 2001 From: Oswaldo Acauan Date: Wed, 31 Aug 2016 19:52:17 +0000 Subject: [PATCH] Add new modal component --- .../ui/components/modal/base/component.jsx | 61 ++++++++++ .../ui/components/modal/base/styles.scss | 37 ++++++ .../imports/ui/components/modal/component.jsx | 110 ++++++++++++++++++ .../imports/ui/components/modal/styles.scss | 50 ++++++++ 4 files changed, 258 insertions(+) create mode 100644 bigbluebutton-html5/imports/ui/components/modal/base/component.jsx create mode 100644 bigbluebutton-html5/imports/ui/components/modal/base/styles.scss create mode 100644 bigbluebutton-html5/imports/ui/components/modal/component.jsx create mode 100644 bigbluebutton-html5/imports/ui/components/modal/styles.scss diff --git a/bigbluebutton-html5/imports/ui/components/modal/base/component.jsx b/bigbluebutton-html5/imports/ui/components/modal/base/component.jsx new file mode 100644 index 0000000000..ed6e2c57f4 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/modal/base/component.jsx @@ -0,0 +1,61 @@ +import React, { Component, PropTypes } from 'react'; +import ReactModal from 'react-modal'; +import styles from './styles.scss'; +import cx from 'classnames'; + +const propTypes = { + isOpen: PropTypes.bool.isRequired, + onShow: PropTypes.func, + onHide: PropTypes.func, +}; + +const defaultProps = { + isOpen: false, +}; + +export default class ModalBase extends Component { + constructor(props) { + super(props); + + this.handleAfterOpen = this.handleAfterOpen.bind(this); + this.handleRequestClose = this.handleRequestClose.bind(this); + } + + handleAfterOpen() { + const { onShow } = this.props; + if (onShow) { + onShow.call(this, ...arguments); + } + } + + handleRequestClose() { + const { onHide } = this.props; + if (onHide) { + onHide.call(this, ...arguments); + } + } + + render() { + const { + isOpen, + onShow, + onHide, + className, + } = this.props; + + return ( + + {this.props.children} + + ); + } +}; + +ModalBase.propTypes = propTypes; +ModalBase.defaultProps = defaultProps; diff --git a/bigbluebutton-html5/imports/ui/components/modal/base/styles.scss b/bigbluebutton-html5/imports/ui/components/modal/base/styles.scss new file mode 100644 index 0000000000..01366df6d1 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/modal/base/styles.scss @@ -0,0 +1,37 @@ +@import "../../../stylesheets/variables/_all"; +@import "../../../stylesheets/mixins/_scrollable"; + +.modal { + @include scrollbox-vertical(); + + max-width: 60vw; + max-height: 100%; + border-radius: $border-radius; + background: #fff; + overflow: auto; + outline: none; + + @include mq($small-only) { + max-width: 95vw; + } + + @include mq($medium-up) { + max-width: 80vw; + } +} + +.overlay { + z-index: 1000; + //background: transparentize($color-white, .35); + background: #fff; + display: flex; + align-items: center; + justify-content: center; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.portal {} diff --git a/bigbluebutton-html5/imports/ui/components/modal/component.jsx b/bigbluebutton-html5/imports/ui/components/modal/component.jsx new file mode 100644 index 0000000000..b656ee81eb --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/modal/component.jsx @@ -0,0 +1,110 @@ +import React, { Component, PropTypes } from 'react'; +import ModalBase from './base/component'; +import Button from '../button/component'; +import styles from './styles.scss'; +import cx from 'classnames'; + +const propTypes = { + isOpen: PropTypes.bool.isRequired, + title: PropTypes.string.isRequired, + confirm: PropTypes.shape({ + callback: PropTypes.func.isRequired, + label: PropTypes.string.isRequired, + description: PropTypes.string, + }), + dismiss: PropTypes.shape({ + callback: PropTypes.func, + label: PropTypes.string.isRequired, + description: PropTypes.string, + }), +}; + +const defaultProps = { + isOpen: true, + title: 'LUL LUL', + confirm: { + label: 'Done', + description: 'Saves changes and closes the modal', + }, + dismiss: { + label: 'Cancel', + description: 'Disregards changes and closes the modal', + }, +}; + +export default class Modal extends Component { + constructor(props) { + super(props); + + this.state = { + isOpen: this.props.isOpen, + }; + + this.handleDismiss = this.handleDismiss.bind(this); + this.handleConfirm = this.handleConfirm.bind(this); + } + + handleDismiss() { + this.setState({ isOpen: false }); + } + + handleConfirm() { + const { confirm } = this.props; + confirm.callback(...arguments); + } + + componentDidUpdate(prevProps, prevState) { + if (prevState.isOpen !== this.props.isOpen + && this.state.isOpen !== this.props.isOpen) { + this.setState({ isOpen: this.props.isOpen }); + } + } + + render() { + const { + title, + dismiss, + confirm, + } = this.props; + + const { isOpen } = this.state; + + console.log('oi', confirm); + + return ( + +
+

{title}

+
+
+
+
+ {this.props.children} +
+ + +
+ ); + } +}; + +Modal.propTypes = propTypes; +Modal.defaultProps = defaultProps; diff --git a/bigbluebutton-html5/imports/ui/components/modal/styles.scss b/bigbluebutton-html5/imports/ui/components/modal/styles.scss new file mode 100644 index 0000000000..99ccb6a762 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/components/modal/styles.scss @@ -0,0 +1,50 @@ +@import "../../stylesheets/variables/_all"; + +.modal { + display: flex; + flex-direction: column; + align-self: flex-start; +} + +.content { + overflow: auto; + color: $color-text; + font-weight: normal; + padding: $line-height-computed 0; +} + +.header { + display: flex; + padding: $line-height-computed 0; + border-bottom: $border-size solid $color-gray-lighter; + flex-shrink: 0; +} + +.actions { + flex: 0 1 35%; + display: flex; + align-items: center; + justify-content: space-between; +} + +.title { + @extend %text-elipsis; + flex: 1; + margin: 0; + font-weight: 400; +} + +%btn { + flex: 0 1 48%; +} + +.dismiss, +.confirm { + @extend %btn; +} + +.dismiss { +} + +.confirm { +}