From 7bdbeab4b2e354a6eaf2f319e56cdd92805dc1a0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 19 Apr 2021 23:32:54 +0200 Subject: adding a flash, adding a bunch of german.. --- frontend/site/projects/museum/views/flash.js | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 frontend/site/projects/museum/views/flash.js (limited to 'frontend/site/projects/museum/views/flash.js') 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 ( +
+ ) + } +} + -- cgit v1.2.3-70-g09d2