blob: 74cb9ec7d879eab079f46c247cc921aa7e2718a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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" />
)
}
}
|