npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trucks-example-skate-component

v1.0.5

Published

Skate compiler transform example

Downloads

18

Readme

Skate Example

This document demonstrates using the skate compiler transform.

Install

npm i trucks-example-skate-component

To build this example install the command line interface npm i -g trucks and dependencies npm i then run:

trucks

Open index.html to see the rendered component or serve over HTTP with node server.js and visit http://localhost:3000.



Compiler Options

module.exports = {
  files: [__dirname + '/components.html'],
  transforms: ['trim', 'csp', 'skate', 'bundle', 'copy'],
  out: 'build',
  force: true,
  css: false,
  html: false,
  copy: {
    files: {
      'index.html': 'index.html'
    } 
  },
  conf: {
    transforms: {
      csp: {
        sha: 'sha256',
        statics: true 
      },
      bundle: {
        js: [require.resolve('skatejs/dist/index-with-deps.js')]
      }
    }
  }
}

Source Files

Component definition file components.html:

<dom-module id="x-panel">

  <template>
    <style>
      /*
        Inline styles for the shadow DOM.
      */
      * {
        font-family: sans-serif;
        color: white;
      }

      p, ::content p {
        margin: 0; 
        padding: 1em;
      }

      .title {
        background: black;
        cursor: pointer;
      }

      .content {
        min-height: 10em;
        background: gray;
      }
    </style>

    <div class="container">
      <p onclick="this.titleClick" class="title">${this.title}</p>
      <div class="content">
        <slot name="content"></slot>
        <ul class="items">
          <script>
            this.values.forEach((item) => {
              html(`<li>${item}</li>`); 
            })
          </script>
        </ul>
        <script>
          if(this.lang) {
            partial('current');
          }
        </script>
      </div>
    </div>
  </template>

  <template id="current">
    <p>Current language: <em>${this.lang.toLowerCase()}</em></p> 
  </template>

  <script>
    skate.define('{{id}}', {
      props: {
        lang: {
          attribute: true 
        },
        values: {
          attribute: true,
          deserialize (val) {
            return val.split(/\s*,\s*/);
          },
          serialize (val) {
            return val.join(',');
          }
        }
      },
      prototype: {
        titleClick(e) {
          console.log('click: ' + e.currentTarget.tagName.toLowerCase());
          console.log(this);
        }
      },
      render: template
    });
  </script>
</dom-module>

Markup

Example component usage in index.html:

<!doctype html>
<html>
  <head>
    <script src="components.js"></script>
  </head>
  <body>
    <x-panel title="Languages" lang="English" values="English, French, Spanish">
      <p slot="content">Choose your language preference</p> 
    </x-panel>
  </body>
</html>

Created by mkdoc on August 2, 2016