mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
Expand image button (#570)
added full-screen image modal when clicking on img's Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
553cd3577d
commit
cac9b7ea37
8 changed files with 55 additions and 7 deletions
|
@ -0,0 +1,31 @@
|
|||
import React, { Fragment, useState } from 'react'
|
||||
import { Modal } from 'react-bootstrap'
|
||||
import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
||||
|
||||
export const Frame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ alt, ...props }) => {
|
||||
const [showFullscreenImage, setShowFullscreenImage] = useState(false)
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<img alt={alt} {...props} className={'cursor-zoom-in'} onClick={() => setShowFullscreenImage(true)}/>
|
||||
<Modal
|
||||
animation={true}
|
||||
centered={true}
|
||||
dialogClassName={'text-dark'}
|
||||
show={showFullscreenImage}
|
||||
onHide={() => setShowFullscreenImage(false)}
|
||||
closeButton={true}
|
||||
size={'xl'}
|
||||
>
|
||||
<Modal.Header closeButton={true}>
|
||||
<Modal.Title className={'h6'}>
|
||||
<ForkAwesomeIcon icon={'picture-o'}/>
|
||||
|
||||
<span>{alt ?? ''}</span>
|
||||
</Modal.Title>
|
||||
</Modal.Header>
|
||||
<img alt={alt} {...props} className={'w-100 cursor-zoom-out'} onClick={() => setShowFullscreenImage(false)}/>
|
||||
</Modal>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue