Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <a href="https://codepen.io/joosts/pen/bGoewoa" target="_top">Cast Spell</a>

<a href="https://codepen.io/joosts/pen/rNGLMwR" target="_top">Mock User Action</a>
              
            
!

CSS

              
                body, html {height: 100%; padding: 0; margin: 0;}
body {
  display: flex; 
  justify-content: center;
  align-items: center;
}
a {
  display: inline-block;
  margin: 0.5rem;
  background: #e9e9ed;
  color: black;
  padding: 0.5rem;
  text-decoration: none;
  border: 1px solid black;
  border-radius: 0.3rem;
}
              
            
!

JS

              
                /* 

Hi Adam,

When a user fires an action, he or she wants feedback on a few things:

1. that something is happening
2. when this something is done
3. what the result of this something was

The dull but effective way to do this is to trigger a page load on every action (as illustrated here) and show the result on the screen. 

The fancy but experimental way to do this is to use a javascript toast. In this case you need a spinner (loading animation) during the 'event' for 1 and 2. This loading animation should stop when the action is finished. For 3 you need a link between the event and the toast, as clicking the button and the appearence of the toast can be seconds apart on bad connections. 

Consider this (very realistic) scenario: Change text, press 'save' button, change text, toast appears saying 'Changes saved'. Is the second change also saved? Can you safely navigate away? Should you click the 'save' button again? This causes user stress and is a really bad experience. 

My advice would be: always try to avoid toasts, as they are not designed with resillience in mind.

This GUI Challenge is based on:
https://web.dev/building-a-toast-component/

I am looking forward to your next challenge.

Kind regards,
Joost van der Schee

*/
              
            
!
999px

Console