Add image viewing in blog entries

This commit is contained in:
Corentin 2021-10-07 14:03:02 +09:00
commit a0f93ae9c3
5 changed files with 55 additions and 5 deletions

View file

@ -29,12 +29,30 @@ class BlogEntryComponent extends Component
render()
{
return (
return [
<div className="blog-entry"
dangerouslySetInnerHTML={this.props.blog_entry_name === this.entry_name ?
{__html: this.props.blog_entry} : null}>
</div>
)
</div>,
<div id="image-container" onclick={() => close_image()}>
<img id="image-view"/>
</div>,
<script>
{`const container = document.getElementById("image-container")
const image_view = document.getElementById("image-view")
function open_image(src)
{
image_view.src = src
container.style.display = 'flex'
}
function close_image()
{
container.style.display = 'none'
}`}
</script>
]
}
}