Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main>
	
	<section id="front">
		<div class="content">
			<h1>worry worry worry</h1>
			<p>This Worry Tree app is based on a mindfulness technique originally developed by Butler and Hope in their <a href="https://amzn.to/2PRpK0W" target="_blank">Managing Your Mind book</a>. </p>

			<p>The purpose is to help you identify, address, and act on worries or concerns.</p>
			
			<p>If you are currently feeling suicidal, please reach out to a friend or resource. The <a href="https://suicidepreventionlifeline.org/">National Suicide Prevention Hotline</a> can help.</p>  
 
			<button onclick="toggleContent()" class="showButton">To get started, click here.</button>
		</div>
	</section>

	<section id="identify" class="content hide">
		<div class="content">
			<h1>What am I worrying about?</h1>
			<p>Is it a hypothetical situation, or a current problem? Can I do something about this?
			</p>
		</div>
		<div class="question-container visibility -is-hidden">
			<button onclick="answerYes()" class="showButton">Yes, I can do something</button>
			<button onclick="answerNo()" class="showButton">No, it's hypothetical</button>
		</div>
	</section>

	<section id="action" class="content hide">
		<div class="content">
			<h1>Make an action plan</h1>
			<p>What can you do? How can you do it? When can you do it?</p>
		</div>
		<button onclick="answerNow()" class="showButton">I can do something now</button>
		<button onclick="later()" class="showButton">I'll schedule it for later</button>
		</div>
	</section>

	<section id="now" class="content hide">
		<div class="content">
			<h1>Get up and do it...</h1> 
			<p>Then come back and check in.</p>
		</div>
		<button onclick="done()" class="showButton">It's done</button>
		</div>
	</section> 

	<section id="later" class="content hide">
		<div class="content">
			<h1>Let the worry go...</h1>

			<button onclick="shift()" class="showButton">Let it go</button>
		</div>
	</section>

	<section id="shift" class="content hide">
		<div class="content">
			<h1>Let the worry go....</h1>
			<p> Shift your focus...</p>

			<button onclick="resources()" class="showButton">Need help shifting your focus? Click here for some resources.</button>
		</div>
	</section>

	<section id="resources" class="content hide">

		<div class="content">
			
			<h2>Need some ideas on what to do?</h2>
			<p>These are some great resources to help you get out of the thought loop, redirect your energy, or find help.</p>
			<ul>
			<li><a href="https://www.crisistextline.org/anxiety">Crisis Text Line</a></li>
			<li><a href="https://amzn.to/2PRpK0W"><i>Managing Your Mind</i>, Baker & Hope</a></li>
			<li><a href="https://www.getselfhelp.co.uk/worrytree.htm" target="_blank">Printable Worry Tree</a></li>
			<li><a href="https://maps.anxietycanada.com/">Anxiety Canada Anxiety Plan</a></li>
			<li><a href="https://www.nami.org/find-support/nami-helpline/top-25-helpline-resources">NAMI Helpline Resources</a></li>
			<li><a href="https://twloha.com/">To Write Love On Her Arms</a></li>
			<li><a href="https://www.wikihow.com/Change-Your-Focus">How to Change Your Focus</a></li>
			<li><a href="https://www.tenpercent.com/">Ten Percent Happier</a></li>
			<li><a href="https://www.reddit.com/r/aww/">r/aww</a></li>
			</ul>


			<p>Built by <a href="https://twitter.com/desilove">Desi💞</a></p>
	</section>
		
</main>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Work+Sans:400,700|Poppins:400,500|Roboto:400,700');

:root {
    --light: #ffffff;
    --dark: #000000;
    --grey: #B7B7B7;
    --accent: darkblue;
}

::selection {
  background: var(--accent);
  color: var(--light);
}


* {
	top: 0;
	left: 0;
}

body {
	font-family: 'Work Sans';
	padding: 200px;
}

h1 {
	font-family: Roboto;
	font-size: 36px;
	font-style: italic;
	font-weight: 700;
}
  
p, li {
	font-family: 'Work Sans';
	font-size: 18px;
	line-height: 1.5;
}

a {
	  text-decoration: none;
	  color: var(--accent);
}

a:hover {
	  font-weight: 700;
}
  
button {
	  width: 95%;
    margin-bottom: 20px;
    border: 2px solid var(--dark);
		border-radius: 5px;
    background-color: var(--light);
    color: var(--dark);
    box-shadow: 8px 8px var(--dark);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 16px;
    justify-self: center;
    transition: 0.2s;
}

button:hover {
    transform: scale(1.15);
		font-style: italic;
}

button:active {
    background-color: var(--dark);
    color: var(--light);
}

.hide {
    display: none; 
}

/*     .fade-out {
	transition: all 2s;
	opacity: 0;
  }
  
  .fade-in {
	transition: all 2s;
	opacity: 1;
  } */
/* 
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
		transition-duration: 2s;
  }
} */

/* https://cssreference.io/property/animation-name/ */


@media (max-width: 600px) {
	body {
	padding: 100px;
  }
}
              
            
!

JS

              
                function toggleContent() {
	const front = document.getElementById("front");
	const identify = document.getElementById("identify");
	front.classList.toggle("hide");
	identify.classList.toggle("hide");
}

function answerYes() {
	const identify = document.getElementById("identify");
	const action = document.getElementById("action");
	identify.classList.toggle("hide");
	action.classList.toggle("hide");
}

function answerNo() {
	const later = document.getElementById("later");
	const identify = document.getElementById("identify");
	later.classList.toggle("hide");
	identify.classList.toggle("hide");
}

function shift() {
	const shift = document.getElementById("shift");
	const later = document.getElementById("later");
	shift.classList.toggle("hide");
	later.classList.toggle("hide");
}

function resources() {
	const shift = document.getElementById("shift");
	const resources = document.getElementById("resources");
	shift.classList.toggle("hide");
	resources.classList.toggle("hide");
}

function answerNow() {
	const now = document.getElementById("now");
	const action = document.getElementById("action");
	now.classList.toggle("hide");
	action.classList.toggle("hide");
}

function later() {

	const action = document.getElementById("action");
	const later = document.getElementById("later");
	action.classList.toggle("hide");
	later.classList.toggle("hide");
}

function done() {
	const now = document.getElementById("now");
	const shift = document.getElementById("shift");
	now.classList.toggle("hide");
	shift.classList.toggle("hide");
}


// fadeIn fadeOut stuff

const toggleButton = document.getElementById('toggle');
const text = document.getElementsByClassName('front');

// can i make const text `getElementsbyClass('section');`?

text.addEventListener('transitionend', () => {
  if (text.style.opacity === 0) {
    text.style.display = 'none';
  }
});


toggleButton.addEventListener('click', () => {
  if (getComputedStyle(text).opacity == 0) {
    text.style.display = 'block';
    requestAnimationFrame(() => {
      text.style.opacity = 1;
    });
  } else {
    text.style.opacity = 0;
  }
});
              
            
!
999px

Console