mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Added QrCode modal window to short URLs
This commit is contained in:
parent
a78d0b9b20
commit
131099b2a6
4 changed files with 31 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.dropdown-item.active {
|
.dropdown-item.active {
|
||||||
background-color: $mainColor !important;
|
background-color: $mainColor !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import copyIcon from '@fortawesome/fontawesome-free-regular/faCopy';
|
||||||
import menuIcon from '@fortawesome/fontawesome-free-solid/faEllipsisV';
|
import menuIcon from '@fortawesome/fontawesome-free-solid/faEllipsisV';
|
||||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||||
import Tag from '../utils/Tag';
|
import Tag from '../utils/Tag';
|
||||||
|
import QrCodeModal from './helpers/QrCodeModal';
|
||||||
import { listShortUrls } from './reducers/shortUrlsList';
|
import { listShortUrls } from './reducers/shortUrlsList';
|
||||||
import './ShortUrlsList.scss';
|
import './ShortUrlsList.scss';
|
||||||
|
|
||||||
|
@ -174,13 +175,14 @@ class Row extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RowMenu extends React.Component {
|
class RowMenu extends React.Component {
|
||||||
state = { isOpen: false };
|
state = { isOpen: false, isQrModalOpen: false };
|
||||||
toggle = () => this.setState({ isOpen: ! this.state.isOpen });
|
toggle = () => this.setState({ isOpen: ! this.state.isOpen });
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { display, shortUrl, onCopyToClipboard } = this.props;
|
const { display, shortUrl, onCopyToClipboard } = this.props;
|
||||||
const baseClass = 'short-urls-list__dropdown-toggle';
|
const baseClass = 'short-urls-list__dropdown-toggle';
|
||||||
const toggleClass = ! display ? `${baseClass} short-urls-list__dropdown-toggle--hidden` : baseClass;
|
const toggleClass = ! display ? `${baseClass} short-urls-list__dropdown-toggle--hidden` : baseClass;
|
||||||
|
const toggleQrCode = () => this.setState({ isQrModalOpen: !this.state.isQrModalOpen });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ButtonDropdown toggle={this.toggle} isOpen={this.state.isOpen} direction="left">
|
<ButtonDropdown toggle={this.toggle} isOpen={this.state.isOpen} direction="left">
|
||||||
|
@ -195,9 +197,14 @@ class RowMenu extends React.Component {
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<FontAwesomeIcon icon={pictureIcon} /> Preview
|
<FontAwesomeIcon icon={pictureIcon} /> Preview
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem onClick={toggleQrCode}>
|
||||||
<FontAwesomeIcon icon={qrIcon} /> QR code
|
<FontAwesomeIcon icon={qrIcon} /> QR code
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
<QrCodeModal
|
||||||
|
url={shortUrl}
|
||||||
|
isOpen={this.state.isQrModalOpen}
|
||||||
|
toggle={toggleQrCode}
|
||||||
|
/>
|
||||||
<DropdownItem divider />
|
<DropdownItem divider />
|
||||||
<CopyToClipboard text={shortUrl} onCopy={onCopyToClipboard}>
|
<CopyToClipboard text={shortUrl} onCopy={onCopyToClipboard}>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
|
|
16
src/short-urls/helpers/QrCodeModal.js
Normal file
16
src/short-urls/helpers/QrCodeModal.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
|
||||||
|
import './QrCodeModal.scss';
|
||||||
|
|
||||||
|
export default function QrCodeModal ({ url, toggle, isOpen }) {
|
||||||
|
return (
|
||||||
|
<Modal isOpen={isOpen} toggle={toggle} centered={true}>
|
||||||
|
<ModalHeader toggle={toggle}>QR code for <a target="_blank" href={url}>{url}</a></ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<div className="text-center">
|
||||||
|
<img src={`${url}/qr-code`} className="qr-code-modal__img" />
|
||||||
|
</div>
|
||||||
|
</ModalBody>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
3
src/short-urls/helpers/QrCodeModal.scss
Normal file
3
src/short-urls/helpers/QrCodeModal.scss
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.qr-code-modal__img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
Loading…
Reference in a new issue