From f92c7de0e7cf9e1d960ce3850a3ca24a107ca205 Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Thu, 3 Oct 2019 18:20:16 +0300 Subject: [PATCH] sample share modal adapted to common components --- src/routes/Player/ControlBar/ControlBar.js | 5 +- .../ControlBar/ShareButton/ShareButton.js | 59 +++++++------------ .../Player/ControlBar/ShareButton/styles.less | 11 ++-- src/routes/Player/ControlBar/styles.less | 7 +++ 4 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/routes/Player/ControlBar/ControlBar.js b/src/routes/Player/ControlBar/ControlBar.js index dfe6ad82b..aa70ffd70 100644 --- a/src/routes/Player/ControlBar/ControlBar.js +++ b/src/routes/Player/ControlBar/ControlBar.js @@ -36,7 +36,7 @@ const ControlBar = (props) => { dispatch={props.dispatch} />
- { subtitlesOutlineColor={props.subtitlesOutlineColor} dispatch={props.dispatch} /> + */}
diff --git a/src/routes/Player/ControlBar/ShareButton/ShareButton.js b/src/routes/Player/ControlBar/ShareButton/ShareButton.js index 8b9c00352..f0dbd994b 100644 --- a/src/routes/Player/ControlBar/ShareButton/ShareButton.js +++ b/src/routes/Player/ControlBar/ShareButton/ShareButton.js @@ -2,47 +2,28 @@ const React = require('react'); const PropTypes = require('prop-types'); const classnames = require('classnames'); const Icon = require('stremio-icons/dom'); -const { Popup } = require('stremio/common'); +const { Button, Popup, useBinaryState } = require('stremio/common'); const styles = require('./styles'); -class ShareButton extends React.Component { - constructor(props) { - super(props); - - this.state = { - popupOpen: false - }; - } - - shouldComponentUpdate(nextProps, nextState) { - return nextState.popupOpen !== this.state.popupOpen || - nextProps.className !== this.props.className || - nextProps.modalContainerClassName !== this.props.modalContainerClassName; - } - - onPopupOpen = () => { - this.setState({ popupOpen: true }); - } - - onPopupClose = () => { - this.setState({ popupOpen: false }); - } - - render() { - return ( - - -
- -
-
- -
- - - ); - } -} +const ShareButton = ({ className, modalContainerClassName }) => { + const [modalOpen, openModal, closeModal, toggleModal] = useBinaryState(false); + return ( + ( + + )} + renderMenu={() => ( +
+ )} + onCloseRequest={closeModal} + /> + ); +}; ShareButton.propTypes = { className: PropTypes.string, diff --git a/src/routes/Player/ControlBar/ShareButton/styles.less b/src/routes/Player/ControlBar/ShareButton/styles.less index 2de50b10a..024666077 100644 --- a/src/routes/Player/ControlBar/ShareButton/styles.less +++ b/src/routes/Player/ControlBar/ShareButton/styles.less @@ -1,5 +1,8 @@ -.share-dialog-container { - width: calc(var(--control-bar-button-size) * 5); - height: calc(var(--control-bar-button-size) * 3); - background-color: var(--color-backgrounddark); +.share-modal-container { + .share-dialog-container { + flex: none; + width: 10rem; + height: 5rem; + background-color: var(--color-backgroundlighter); + } } \ No newline at end of file diff --git a/src/routes/Player/ControlBar/styles.less b/src/routes/Player/ControlBar/styles.less index ff8277266..50842aca7 100644 --- a/src/routes/Player/ControlBar/styles.less +++ b/src/routes/Player/ControlBar/styles.less @@ -62,4 +62,11 @@ flex: 1; } } +} + +.modal-container { + display: flex; + align-items: flex-end; + justify-content: flex-end; + padding: 8rem 1rem; } \ No newline at end of file