]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/common/Spoiler.js
generic spoiler component
[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.node,
17 };
18
19 export default Spoiler;