css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
                <button type="button" onclick="openMenu();">Open</button>
  <button type="button" onclick="closeMenu();">Close</button>
  <button type="button" onclick="focusMenu();">Focus</button>
  <button type="button" onclick="blurMenu();">Blur</button>
  <div>
    <menu-group id="test-target" rotate>
      <smart-button type="simple-text">Text 1</smart-button>
      <smart-button type="simple-text">Text 2</smart-button>
      <smart-button type="simple-text">Text 3</smart-button>
      <smart-button type="simple-text">Text 4</smart-button>
      <smart-button type="simple-text">Text 5</smart-button>
    </menu-group>
  </div>
            
          
!
            
              /**
 * Start of Simple Text Button
**/

smart-button[type="simple-text"] {
  display: inline-block;

  font-family: "Fira Sans";
  font-style: italic;
  font-size: 2.4rem;
  line-height: 8rem;
 
  transition-property: all;
  transition-timing-function: cubic-bezier(0.25, 0, 0, 1.0);
  transition-duration: 0.42s;
 
  color: #dddddd;
  background: none;
  border: none;
  border-radius: 0;

  width: auto;
  height: 8rem;

  padding-left: 2.6rem;
  padding-right: 2.6rem;

  -moz-user-select: none;
}

smart-button[type="simple-text"].focused {
  outline: 0;
  transform: scale(1.2);
  transition-duration: 0.42s;

  color: #ffffff;
  background: none;
}

smart-button[type="simple-text"].released {
  transition-duration: 0.16s;
}

smart-button[type="simple-text"].pressed {
  color: #00caf2;
  background: none;
  transform: scale(0.8);
  transition-duration: 0.06s;
}

/**
 * End of Simple Text Button
**/

/**
 * Button state:
 *    1. normal (class name: [none])
 *    2. enlarging (class name: enlarging)
 *    3. shrinking (class name: shrinking)
 *    4. opening (class name: opening)
 *    5. closing (class name: closing)
 *    6. closed (class name: closed)
**/

/**
 * focus: closed -> closed + enlarging -> closed + shrinking -> opening -> ''
 * close: '' -> closing -> closed;
**/

menu-group {
  outline: 0;
  display: inline-block;
  height: 8rem;
  padding-left: 8rem;
  padding-right: 4rem;
  opacity: 1;
  /* we need to set border to none to remove the button border */
  border: none;
  /* the radius is still make button as round even if we don't have border */
  border-radius: 4rem;
  background-color: rgba(0, 0, 0, 0.5);

  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  position: relative;

  transition-property: all;
  transition-timing-function: cubic-bezier(0.25, 0, 0, 1.0);
  transition-duration: 0.42s;
}

menu-group:before {
  content: " ";
  background-repeat: no-repeat;
  background-size: 5.4rem auto;
  background-position: 1.3rem center;
  width: 8rem;
  height: 8rem;
  display: inline-block;
  position: absolute;
  left: 0;

  transition-property: all;
  transition-timing-function: cubic-bezier(0.25, 0, 0, 1.0);
  transition-duration: 0.42s;
}

menu-group[rotate]:before {
  transform: rotate(360deg);
  transition-property: all;
  transition-timing-function: cubic-bezier(0.25, 0, 0, 1.0);
  transition-duration: 0.42s;
}

menu-group[data-icon]:before {
  width: 5.4rem;
  left: 1.3rem;
  font-size: 5.4rem;
  line-height: 8rem;
  text-align: center;
  color: #ffffff;
  white-space: normal;
  top: 0;
}

menu-group[data-icon].switching-icon:before {
  font-size: 5.4rem;
  line-height: 8rem;
  text-align: center;
  color: #ffffff;
  /**
   * According to visual spec, we have falling down transition while icon
   * change.
   *
   * The trick is:
   *   1. to put the next icon at the top of current and slide icons down.
   *   2. to set transition duration to 0 here to elimiate the slide up
   *      transition.
  **/
  top: -8rem;
  transition: none;
}

menu-group.closed {
  padding-right: 0;

  transition-duration: 0.5s;
  background-color: rgba(0, 0, 0, 0.5);
}

menu-group.closed > * {
  display: none;
}

menu-group[rotate].closed:before {
  transform: rotate(0deg);
}

menu-group.opening {
  transition-duration: 0.72s;
  /* add the same padding-right of normal to make it run transition */
  padding-right: 4rem;
}

menu-group.opening:before {
  transition-duration: 0.72s;
}

menu-group.closing {
  transition-duration: 0.5s;
  padding-right: 0;
  background-color: rgba(0, 0, 0, 0.5);
}

menu-group[rotate].closing:before {
  transform: rotate(0deg);
  transition-duration: 0.5s;
}

menu-group.enlarging {
  opacity: 1;
  background-color: #ffffff;
  transform: scale(1.2);
  transition-duration: 0.2s;
}

menu-group.shrinking {
  transition-duration: 0.23s;
}

/* example */
html,
body {
  margin: 0;
  padding: 0;
  font-size: 10px;
  background-color: gray;
}
menu-group:before {
  background-image: url('https://raw.githubusercontent.com/mozilla-b2g/gaia/master/tv_apps/smart-home/style/images/ic_setting%402x.png');
}
menu-group.enlarging:before {
  background-image: url('https://raw.githubusercontent.com/mozilla-b2g/gaia/master/tv_apps/smart-home/style/images/ic_setting.png');
}
            
          
!
            
              function openMenu() {
  document.getElementById('test-target').open();
}
function closeMenu() {
  document.getElementById('test-target').close();
}
function focusMenu() {
  document.getElementById('test-target').focus();
}
function blurMenu() {
  document.getElementById('test-target').blur();
}
window.onload = function() {
  ['opened', 'closed', 'will-open', 'will-close'].forEach(function(evt) {
    document.getElementById('test-target').addEventListener(evt,
      function() {
        console.log(evt + ' received!');
      });
  });
};
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console