]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/common/Spoiler.js
add myustery circus link
[alttp.git] / resources / js / components / common / Spoiler.js
1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3
4 const Spoiler = ({ children }) => {
5         const [show, setShow] = useState(false);
6
7         return <span
8                 className={`spoiler ${show ? 'shown' : 'hidden'}`}
9                 onClick={() => setShow(true)}
10         >
11                 <span className="content">{children}</span>
12         </span>;
13 };
14
15 Spoiler.propTypes = {
16         children: PropTypes.oneOfType([
17                 PropTypes.node,
18                 PropTypes.object,
19                 PropTypes.string,
20         ]),
21 };
22
23 export default Spoiler;