Skip to content

Commit 5203e83

Browse files
committed
Goals: add spoiler for notation (how to read this list)
1 parent d5e0e4c commit 5203e83

File tree

2 files changed

+69
-13
lines changed

2 files changed

+69
-13
lines changed

src/global.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,6 +2642,23 @@ h6 {
26422642
vertical-align: -14%;
26432643
}
26442644

2645+
.spoilerContentGoals {
2646+
padding: 0em 1.5em;
2647+
font-size: 26px;
2648+
margin-top: 40px;
2649+
margin-bottom: 35px;
2650+
line-height: 34px;
2651+
}
2652+
2653+
.spoilerContentGoals li {
2654+
margin: 12px 0px;
2655+
}
2656+
2657+
.spoilerContentGoals img {
2658+
width: 26px;
2659+
vertical-align: -14%;
2660+
}
2661+
26452662
#anchorArrow {
26462663
opacity: 0.46 !important;
26472664
transition: 130ms ease-in;

src/pages/main/goals.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState, useRef } from 'react';
22
import { Helmet } from 'react-helmet'
33
import { motion } from 'framer-motion';
44
import { TelegramComments } from 'react-telegram-comments';
@@ -62,6 +62,34 @@ const textImg = {
6262

6363
const Goals = () => {
6464

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+
6593
const data = useStaticQuery(graphql`
6694
query {
6795
allGoalsYaml {
@@ -138,21 +166,32 @@ const Goals = () => {
138166
<div class="goalsTextContent">
139167
<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."/>
140168
<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+
&nbsp;&nbsp;
172+
<span className="spoilerText"></span>
173+
Spoiler: How to read this list
174+
&nbsp;&nbsp;
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/>
152192
<button onClick={toggleOpacity}>{isOpaque ? 'Hide tags' : 'Show tags'}</button>
153193
<button style={hideUncheckedButtonStyle} onClick={removeUnchecked}>{hideUnchecked ? 'Show unachieved goals' : 'Hide unachieved goals' + ' (' + goalsConcat.reduce((acc, cur) => cur.status === 'u' ? ++acc : acc, 0) + ')'}</button>
154194
<button style={hideCheckedButtonStyle} onClick={removeChecked}>{hideChecked ? 'Show achieved goals' : 'Hide achieved goals' + ' (' + goalsConcat.reduce((acc, cur) => cur.status === 'c' ? ++acc : acc, 0) + ')'}</button>
155-
156195
<p></p>
157196
</div>
158197
<p style={placeholderTop}> </p>

0 commit comments

Comments
 (0)