mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
* files: left-align the preview toolbar, Open joins the button row The modal actions row packs its children to the right, which suits a confirming button but stranded the preview's toolbar. The toolbar now fills the row so its buttons read from the left, with Open first in the same row as Download. On phones the tags selector always takes its own line instead of squeezing in beside the buttons. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * tags: the add-tag button is violet like every other tag button Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * share: a real button everywhere but the navbar corner The share trigger was a bare anchor-wrapped glyph, which matched the navbar's other corner icons but looked out of place beside real buttons in the file preview toolbar. It is an IconButton by default now; the navbar keeps the bare glyph via asIcon. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
import React from "react";
|
|
import {Button, Header, Icon, IconButton, Modal} from "./ui";
|
|
import QRCode from "react-qr-code";
|
|
import {sendNotification} from "../api";
|
|
|
|
export const ShareEveryoneButton = ({url, size, onClick}) => {
|
|
const handleShare = async () => {
|
|
await sendNotification('A user shared this', url);
|
|
if (onClick) {
|
|
await onClick();
|
|
}
|
|
}
|
|
|
|
return <Button
|
|
color='violet'
|
|
size={size}
|
|
onClick={handleShare}
|
|
>
|
|
Share with everyone
|
|
</Button>
|
|
}
|
|
|
|
/*
|
|
* `asIcon` is for the navbar corner, where the trigger sits beside other bare glyphs and a
|
|
* boxed button would not match; everywhere else it is a real button, matching its siblings.
|
|
*/
|
|
export const ShareButton = ({asIcon = false}) => {
|
|
const [open, setOpen] = React.useState(false);
|
|
|
|
const handleOpen = (e) => {
|
|
if (e) {
|
|
e.preventDefault();
|
|
}
|
|
setOpen(true);
|
|
}
|
|
|
|
const handleClose = (e) => {
|
|
if (e) {
|
|
e.preventDefault();
|
|
}
|
|
setOpen(false);
|
|
}
|
|
|
|
return <>
|
|
<Modal size='small' closeIcon
|
|
open={open}
|
|
onClose={handleClose}
|
|
>
|
|
<Modal.Header>Share this page</Modal.Header>
|
|
<Modal.Content>
|
|
<Header as='h4'>Another user can scan this QR code to view this page</Header>
|
|
{/* `media`: filtered as a unit by night mode; see DonatePage. */}
|
|
<div className='media'
|
|
style={{padding: '1em', backgroundColor: '#ffffff', display: "inline-block"}}>
|
|
<QRCode value={window.location.href}/>
|
|
</div>
|
|
</Modal.Content>
|
|
<Modal.Actions>
|
|
<ShareEveryoneButton url={window.location.href} onClick={handleClose}/>
|
|
<Button role='cancel' onClick={handleClose}>Close</Button>
|
|
</Modal.Actions>
|
|
</Modal>
|
|
{asIcon
|
|
? <a href='#' onClick={handleOpen}>
|
|
<Icon name='share' size='large'/>
|
|
</a>
|
|
: <IconButton icon='share' label='Share' size='small' onClick={handleOpen}/>}
|
|
</>
|
|
}
|