|
1 |
| -import React, { useState } from 'react'; |
| 1 | +import React, { useEffect, useState, useRef } from 'react'; |
2 | 2 | import { Helmet } from 'react-helmet'
|
3 | 3 | import { motion } from 'framer-motion';
|
4 | 4 | import { TelegramComments } from 'react-telegram-comments';
|
@@ -62,6 +62,34 @@ const textImg = {
|
62 | 62 |
|
63 | 63 | const Goals = () => {
|
64 | 64 |
|
| 65 | + const collRef = useRef([]); |
| 66 | + |
| 67 | + useEffect(() => { |
| 68 | + const coll = collRef.current; |
| 69 | + coll.forEach((element) => { |
| 70 | + if (element) { |
| 71 | + element.addEventListener("click", toggleContent); |
| 72 | + } |
| 73 | + }); |
| 74 | + return () => { |
| 75 | + coll.forEach((element) => { |
| 76 | + if (element) { |
| 77 | + element.removeEventListener("click", toggleContent); |
| 78 | + } |
| 79 | + }); |
| 80 | + }; |
| 81 | + }, []); |
| 82 | + |
| 83 | + const toggleContent = (event) => { |
| 84 | + const content = event.target.nextElementSibling; |
| 85 | + event.target.classList.toggle("activeSpoiler"); |
| 86 | + if (content.style.maxHeight) { |
| 87 | + content.style.maxHeight = null; |
| 88 | + } else { |
| 89 | + content.style.maxHeight = content.scrollHeight + "px"; |
| 90 | + } |
| 91 | + }; |
| 92 | + |
65 | 93 | const data = useStaticQuery(graphql`
|
66 | 94 | query {
|
67 | 95 | allGoalsYaml {
|
@@ -138,21 +166,32 @@ const Goals = () => {
|
138 | 166 | <div class="goalsTextContent">
|
139 | 167 | <M text="Here you can find the public version of my bucket list, which is actually an organized collection of my life's achievements if it was a RPG (that's exactly how I feel this life). There are boring cliché goals, serious and challenging ones, but also just simple little things for folks who, like me, enjoy goofing around doing stupid and sometimes epic dangerous stuff, because that's what makes life exciting."/>
|
140 | 168 | <M text="Keeping a list of goals constantly reminds me of my passions and motivates me to push forward, and I hope it can give you some inspiration if you're feeling stuck in life."/>
|
141 |
| - <M text="Before you dive deep, here's a little explanation of the notation:"/> |
142 |
| - <ul> |
143 |
| - <li><span class="tooltipGoals"><img id="checkboxStyle" style={textImg} src={info} class=".c" alt='checkbox'/><span class="tooltiptextGoals">Hooray, you've discovered mouse control!</span></span> will prompt additional information about a goal on hover </li> |
144 |
| - <li><img src={refLink} style={textImg} /> can be a reference, inspiration, or extra source to describe a goal</li> |
145 |
| - <li><img src={resultLink} style={textImg} /> is a link to the result or proof of accomplishing a goal</li> |
146 |
| - <li>The right side of the page shows two tags: difficulty/rareness (stars) and the level of risk</li> |
147 |
| - <li>A bunch of icons on the left side represent the category tags for navigation and the statistics at the bottom of the page</li> |
148 |
| - <li>The text after "–" reflects a rough deadline for a goal </li> |
149 |
| - <li>Hovering over the <span class="tooltipGoals"><img id="checkboxStyle" style={textImg} src={checkbox} class=".c" alt='checkbox'/><span class="tooltiptextGoals">Yep, just like that.</span></span> icons displays the dates of completion</li> |
150 |
| - </ul> |
151 |
| - |
| 169 | + <div> |
| 170 | + <button className="spoilerButton noselect" ref={(el) => collRef.current.push(el)}> |
| 171 | + |
| 172 | + <span className="spoilerText"></span> |
| 173 | + Spoiler: How to read this list |
| 174 | + |
| 175 | + </button> |
| 176 | + <div className="spoilerContentWrapper"> |
| 177 | + <div className="spoilerContentGoals"> |
| 178 | + <M text="Before you dive deep, here's a little explanation of the notation:"/> |
| 179 | + <ul> |
| 180 | + <li><span class="tooltipGoals"><img id="checkboxStyle" style={textImg} src={info} class=".c" alt='checkbox'/><span class="tooltiptextGoals">Hooray, you've discovered mouse control!</span></span> will prompt additional information about a goal on hover </li> |
| 181 | + <li><img src={refLink} style={textImg} /> can be a reference, inspiration, or extra source to describe a goal</li> |
| 182 | + <li><img src={resultLink} style={textImg} /> is a link to the result or proof of accomplishing a goal</li> |
| 183 | + <li>The right side of the page shows two tags: difficulty/rareness (stars) and the level of risk</li> |
| 184 | + <li>A bunch of icons on the left side represent the category tags for navigation and the statistics at the bottom of the page</li> |
| 185 | + <li>The text after "–" reflects a rough deadline for a goal </li> |
| 186 | + <li>Hovering over the <span class="tooltipGoals"><img id="checkboxStyle" style={textImg} src={checkbox} class=".c" alt='checkbox'/><span class="tooltiptextGoals">Yep, just like that.</span></span> icons displays the dates of completion</li> |
| 187 | + </ul> |
| 188 | + </div> |
| 189 | + </div> |
| 190 | + </div> |
| 191 | + <br/> |
152 | 192 | <button onClick={toggleOpacity}>{isOpaque ? 'Hide tags' : 'Show tags'}</button>
|
153 | 193 | <button style={hideUncheckedButtonStyle} onClick={removeUnchecked}>{hideUnchecked ? 'Show unachieved goals' : 'Hide unachieved goals' + ' (' + goalsConcat.reduce((acc, cur) => cur.status === 'u' ? ++acc : acc, 0) + ')'}</button>
|
154 | 194 | <button style={hideCheckedButtonStyle} onClick={removeChecked}>{hideChecked ? 'Show achieved goals' : 'Hide achieved goals' + ' (' + goalsConcat.reduce((acc, cur) => cur.status === 'c' ? ++acc : acc, 0) + ')'}</button>
|
155 |
| - |
156 | 195 | <p></p>
|
157 | 196 | </div>
|
158 | 197 | <p style={placeholderTop}> </p>
|
|
0 commit comments