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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <base href="https://raw-dot-custom-elements.appspot.com/BrightspaceUI/menu/v1.0.3/menu/">
<script src="../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../d2l-demo-template/d2l-demo-template.html">
<link rel="import" href="d2l-menu.html">

<body unresolved>

  <d2l-demo-template title="d2l-menu">

    <div slot="d2l-demo-actions" class="d2l-demo-actions">
      <button onclick="setFocus();">Set Focus</button>
      <button onclick="addItem();">Add Top Item</button>
      <button onclick="showDeepMenu();">Show Deep Menu</button>
    </div>

    <div slot="d2l-demo-fixture" class="d2l-demo-fixture">
      <d2l-menu id="menu" label="Astronomy" style="max-width:400px;">
        <d2l-menu-item text="Introduction"></d2l-menu-item>
        <d2l-menu-item-separator></d2l-menu-item-separator>
        <d2l-menu-item text="Searching the Heavens"></d2l-menu-item>
        <d2l-menu-item text="The Solar System">
          <d2l-menu>
            <d2l-menu-item text="Formation"></d2l-menu-item>
            <d2l-menu-item text="Modern Solar System"></d2l-menu-item>
            <d2l-menu-item text="Future Solar System"></d2l-menu-item>
            <d2l-menu-item text="The Planets">
              <d2l-menu>
                <d2l-menu-item text="Mercury"></d2l-menu-item>
                <d2l-menu-item text="Venus"></d2l-menu-item>
                <d2l-menu-item text="Earth"></d2l-menu-item>
                <d2l-menu-item text="Mars"></d2l-menu-item>
                <d2l-menu-item text="Jupiter"></d2l-menu-item>
                <d2l-menu-item text="Saturn"></d2l-menu-item>
                <d2l-menu-item text="Uranus"></d2l-menu-item>
                <d2l-menu-item text="Neptune"></d2l-menu-item>
                <d2l-menu-item text="Dwarf Planets"></d2l-menu-item>
              </d2l-menu>
            </d2l-menu-item>
            <d2l-menu-item text="The Sun"></d2l-menu-item>
            <d2l-menu-item text="Solar &amp; Lunar Eclipses"></d2l-menu-item>
            <d2l-menu-item text="Meteors &amp; Meteorites"></d2l-menu-item>
            <d2l-menu-item text="Asteroids"></d2l-menu-item>
            <d2l-menu-item text="Comets"></d2l-menu-item>
          </d2l-menu>
        </d2l-menu-item>
        <d2l-menu-item text="Stars &amp; Galaxies">
          <d2l-menu>
            <d2l-menu-item text="What is a Star?"></d2l-menu-item>
            <d2l-menu-item text="Lifecycle of a Star"></d2l-menu-item>
            <d2l-menu-item text="Binaries &amp; Multiples"></d2l-menu-item>
            <d2l-menu-item text="Star Clusters"></d2l-menu-item>
            <d2l-menu-item text="Star Death">
              <d2l-menu id="stardeath">
                <d2l-menu-item text="Supernovae"></d2l-menu-item>
                <d2l-menu-item text="Black Holes"></d2l-menu-item>
              </d2l-menu>
            </d2l-menu-item>
            <d2l-menu-item text="Star Clusters"></d2l-menu-item>
            <d2l-menu-item text="Galaxies">
              <d2l-menu>
                <d2l-menu-item text="Classification"></d2l-menu-item>
                <d2l-menu-item text="Birth &amp; Evolution"></d2l-menu-item>
                <d2l-menu-item text="Spiral"></d2l-menu-item>
                <d2l-menu-item text="Elliptical"></d2l-menu-item>
                <d2l-menu-item text="Lenticular"></d2l-menu-item>
                <d2l-menu-item text="Irregular"></d2l-menu-item>
                <d2l-menu-item text="Active &amp; Radio"></d2l-menu-item>
                <d2l-menu-item text="Quasars"></d2l-menu-item>
                <d2l-menu-item text="Galaxy Clusters"></d2l-menu-item>
              </d2l-menu>
            </d2l-menu-item>
          </d2l-menu>
        </d2l-menu-item>
        <d2l-menu-item text="The Night Sky">
          <d2l-menu id="thenightsky">
            <d2l-menu-item text="Constellations"></d2l-menu-item>
            <d2l-menu-item text="Mapping the Heavens"></d2l-menu-item>
            <d2l-menu-item text="Reading Star Maps"></d2l-menu-item>
            <d2l-menu-item text="Telescopes"></d2l-menu-item>
          </d2l-menu>
        </d2l-menu-item>
        <d2l-menu-item text="The Universe"></d2l-menu-item>
      </d2l-menu>
    </div>

  </d2l-demo-template>

  <script>
    var page_menu;
    window.addEventListener("WebComponentsReady", function(e) {
      page_menu = document.getElementById("menu");
      page_menu.addEventListener("d2l-menu-item-select", function(e) {
        console.log("item selected:", e.target);
      });
    });
    function setFocus() {
      page_menu.focus();
    }
    function addItem() {
      var item = document.createElement("d2l-menu-item");
      item.setAttribute("text", "Exoplanets");
      Polymer.dom(page_menu).insertBefore(item, Polymer.dom(page_menu).children[0]);
    }
    function showDeepMenu() {
      var deepMenu = document.getElementById("stardeath");
      deepMenu.show();
    }
  </script>
</body>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console