UNPKG

@kano/web-components

Version:

Shared web-components for the Kano ecosystem.

89 lines (82 loc) 3.88 kB
<!doctype html> <html> <head> <title>kano-modal demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> <meta name="mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes"> <script src="../../../../@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script> <script type="module" src="../../../../@polymer/iron-demo-helpers/demo-snippet.js"></script> <script type="module" src="../../../../@polymer/iron-demo-helpers/demo-pages-shared-styles.js"></script> <script type="module" src="../../kano-style/typography.js"></script> <script type="module" src="../kano-modal.js"></script> <!-- FIXME(polymer-modulizer): These imperative modules that innerHTML your HTML are a hacky way to be sure that any mixins in included style modules are ready before any elements that reference them are instantiated, otherwise the CSS @apply mixin polyfill won't be able to expand the underlying CSS custom properties. See: https://github.com/Polymer/polymer-modulizer/issues/154 --> <script type="module"> const $_documentContainer = document.createElement('template'); $_documentContainer.innerHTML = `<custom-style> <style is="custom-style" include="demo-pages-shared-styles"> html { width: 100%; height: 100%; } button { border-radius: 3px; width: 100px; height: 80px; background-color: #fff; font-family: 'Bariol', sans-serif; font-size: 16px; font-weight: bold; } .content { padding: 0 20px; padding: 50px 0 40px; margin-top: 85px; } </style> </custom-style>`; document.body.appendChild($_documentContainer.content); </script> </head> <body unresolved> <script type="module"> const $_documentContainer = document.createElement('template'); $_documentContainer.innerHTML = `<div class="vertical-section-container centered"> <h3>Kano modal demo</h3> <demo-snippet> <template> <button id="open-button" type="button">Open modal</button> <kano-modal id="dialog" assets-path="../../demo-assets" motif="../../demo-assets/avatar/judoka-face.svg"> <div class="content"> <h2>Example content for Kano Modal</h2> <p>It will display anything you like</p> <hr> <strong>mega win!</strong> </div> </kano-modal> <script type="text/javascript"> document.addEventListener('WebComponentsReady', () => { var modal = document.getElementById('dialog'); var openButton = document.getElementById('open-button'); modal.open(); openButton.addEventListener('click', function() { modal.open(); }) modal.addEventListener('dismiss', function() { console.log('dismiss event fired'); }); }); &lt;/script> </template> </demo-snippet> </div>`; document.body.appendChild($_documentContainer.content); </script>