diff options
Diffstat (limited to 'frontend/site/projects/museum/views/flash.js')
| -rw-r--r-- | frontend/site/projects/museum/views/flash.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/frontend/site/projects/museum/views/flash.js b/frontend/site/projects/museum/views/flash.js new file mode 100644 index 0000000..74cb9ec --- /dev/null +++ b/frontend/site/projects/museum/views/flash.js @@ -0,0 +1,43 @@ +import React, { Component } from 'react' + +import "./flash.css" + +import { ARTISTS } from "site/projects/museum/constants" + +export default class Flash extends Component { + constructor(props) { + super(props) + this.state = { + flashing: false, + artist_name: "", + } + } + + componentDidUpdate(prevProps) { + if (this.props.location.pathname !== prevProps.location.pathname) { + this.flash() + } + } + + flash() { + const { page_name } = this.props.match.params + const artist_name = page_name.split('-')[0] + if (!(artist_name in ARTISTS)) { + return + } + if (artist_name !== this.state.artist_name) { + this.setState({ flashing: true, artist_name }) + setTimeout(() => { + this.setState({ flashing: false }) + }, 100) + } + } + + render() { + if (!this.state.flashing) return null + return ( + <div className="flash" /> + ) + } +} + |
