]> git.localhorst.tv Git - alttp.git/commitdiff
generic spoiler component
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 20 Mar 2022 18:12:54 +0000 (19:12 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 20 Mar 2022 18:12:54 +0000 (19:12 +0100)
resources/js/components/common/Spoiler.js [new file with mode: 0644]
resources/sass/common.scss

diff --git a/resources/js/components/common/Spoiler.js b/resources/js/components/common/Spoiler.js
new file mode 100644 (file)
index 0000000..c4995dc
--- /dev/null
@@ -0,0 +1,19 @@
+import PropTypes from 'prop-types';
+import React, { useState } from 'react';
+
+const Spoiler = ({ children }) => {
+       const [show, setShow] = useState(false);
+
+       return <span
+               className={`spoiler ${show ? 'shown' : 'hidden'}`}
+               onClick={() => setShow(true)}
+       >
+               <span className="content">{children}</span>
+       </span>;
+};
+
+Spoiler.propTypes = {
+       children: PropTypes.node,
+};
+
+export default Spoiler;
index 80b8b2a62e83293435f9d35a3b48437c210364e3..6a4be9fcbc2df9f5aab09e5f0a8761435916fb34 100644 (file)
@@ -11,6 +11,21 @@ h1 {
        margin-bottom: 2rem;
 }
 
+.spoiler {
+       border-radius: 0.5ex;
+       padding: 0 0.5ex;
+       background: $dark;
+       color: $light;
+
+       &.hidden {
+               cursor: pointer;
+
+               > .content {
+                       visibility: hidden;
+               }
+       }
+}
+
 .text-discord {
        color: $discord;
 }