<!– @license Copyright © 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at polymer.github.io/LICENSE.txt The complete set of authors may be found at polymer.github.io/AUTHORS.txt The complete set of contributors may be found at polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at polymer.github.io/PATENTS.txt –>

<!doctype html> <html> <head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">

<title>Responsive grid layout using app-grid-style</title>

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../../polymer/polymer.html">
<link rel="import" href="../app-grid-style.html">

<style>

  body {
    margin: 0;
    background-color: #ddd;
  }

</style>

</head> <body>

<dom-module id="x-app">
  <template>
    <style include="app-grid-style">

      :host {
        display: block;
        --app-grid-columns: 3;
        --app-grid-gutter: 10px;
        --app-grid-expandible-item-columns: 2;
        --app-grid-item-height: 20vw;
      }

      ul {
        padding: 0;
        list-style: none;
      }

      h1 {
        font-family: 'Roboto', 'Noto', sans-serif;
        text-align: center;
        font-size: 18px;
        line-height: 30px;
        font-weight: 400;
        margin: 10px 20px;
      }

      .item {
        list-style: none;
        background-color: white;
      }

      @media (min-width: 800px) {
        .item:nth-child(5n+1) {
          @apply(--app-grid-expandible-item);
        }
      }

      @media (max-width: 799px) {
        :host {
          --app-grid-columns: 2;
          --app-grid-gutter: 5px;
          --app-grid-expandible-item-columns: 2;
        }

        .item:nth-child(3n+1) {
          @apply(--app-grid-expandible-item);
        }
      }

    </style>

    <h1>3 columns on large screens and 2 columns on small ones.</h1>

    <ul class="app-grid">
      <template items="[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" is="dom-repeat">
        <li class="item"></li>
      </template>
    </ul>

  </template>

  <script>

    HTMLImports.whenReady(function() {

      Polymer({

        is: 'x-app',

        attached: function() {
          this._updateGridStyles = this._updateGridStyles || function() {
            this.updateStyles();
          }.bind(this);
          window.addEventListener('resize', this._updateGridStyles);
        },

        detached: function() {
          window.removeEventListener('resize', this._updateGridStyles);
        }

      });

    });

  </script>
</dom-module>

<x-app></x-app>

</body> </html>