From 842b1a7590a93b5bd162aa631509c45ba64e8014 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 27 Jul 2018 18:21:10 +0200 Subject: [PATCH] Added preview modal component --- src/short-urls/ShortUrlsList.js | 16 ++++++++++++++-- src/short-urls/helpers/PreviewModal.js | 17 +++++++++++++++++ src/short-urls/helpers/PreviewModal.scss | 13 +++++++++++++ src/utils/mixins/horizontal-align.scss | 5 +++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/short-urls/helpers/PreviewModal.js create mode 100644 src/short-urls/helpers/PreviewModal.scss create mode 100644 src/utils/mixins/horizontal-align.scss diff --git a/src/short-urls/ShortUrlsList.js b/src/short-urls/ShortUrlsList.js index 96398251..adfcea48 100644 --- a/src/short-urls/ShortUrlsList.js +++ b/src/short-urls/ShortUrlsList.js @@ -13,6 +13,7 @@ import copyIcon from '@fortawesome/fontawesome-free-regular/faCopy'; import menuIcon from '@fortawesome/fontawesome-free-solid/faEllipsisV'; import FontAwesomeIcon from '@fortawesome/react-fontawesome'; import Tag from '../utils/Tag'; +import PreviewModal from './helpers/PreviewModal'; import QrCodeModal from './helpers/QrCodeModal'; import { listShortUrls } from './reducers/shortUrlsList'; import './ShortUrlsList.scss'; @@ -175,7 +176,7 @@ class Row extends React.Component { } class RowMenu extends React.Component { - state = { isOpen: false, isQrModalOpen: false }; + state = { isOpen: false, isQrModalOpen: false, isPreviewOpen: false }; toggle = () => this.setState({ isOpen: ! this.state.isOpen }); render () { @@ -183,6 +184,7 @@ class RowMenu extends React.Component { const baseClass = 'short-urls-list__dropdown-toggle'; const toggleClass = ! display ? `${baseClass} short-urls-list__dropdown-toggle--hidden` : baseClass; const toggleQrCode = () => this.setState({ isQrModalOpen: !this.state.isQrModalOpen }); + const togglePreview = () => this.setState({ isPreviewOpen: !this.state.isPreviewOpen }); return ( @@ -193,10 +195,18 @@ class RowMenu extends React.Component {  Visit Stats + - + +  Preview + +  QR code @@ -205,7 +215,9 @@ class RowMenu extends React.Component { isOpen={this.state.isQrModalOpen} toggle={toggleQrCode} /> + +  Copy to clipboard diff --git a/src/short-urls/helpers/PreviewModal.js b/src/short-urls/helpers/PreviewModal.js new file mode 100644 index 00000000..aa31755d --- /dev/null +++ b/src/short-urls/helpers/PreviewModal.js @@ -0,0 +1,17 @@ +import React from 'react' +import { Modal, ModalBody, ModalHeader } from 'reactstrap'; +import './PreviewModal.scss'; + +export default function PreviewModal ({ url, toggle, isOpen }) { + return ( + + Preview for {url} + +
+

Loading...

+ +
+
+
+ ); +} diff --git a/src/short-urls/helpers/PreviewModal.scss b/src/short-urls/helpers/PreviewModal.scss new file mode 100644 index 00000000..4ac6c972 --- /dev/null +++ b/src/short-urls/helpers/PreviewModal.scss @@ -0,0 +1,13 @@ +@import "../../utils/mixins/horizontal-align"; + +.preview-modal__img { + max-width: 100%; + position: relative; + z-index: 2; +} + +.preview-modal__loader { + @include horizontal-align(); + z-index: 1; + top: 1rem; +} diff --git a/src/utils/mixins/horizontal-align.scss b/src/utils/mixins/horizontal-align.scss new file mode 100644 index 00000000..4daffffc --- /dev/null +++ b/src/utils/mixins/horizontal-align.scss @@ -0,0 +1,5 @@ +@mixin horizontal-align { + position: absolute; + left: 50%; + transform: translateX(-50%); +}