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

xtal-pattern

v0.0.2

Published

Create single file html Polymer web components without HTML Import

Downloads

5

Readme

Published on webcomponents.org

<xtal-pattern>

<xtal-pattern> is a dependency free web component, though its mission is intimately tied with Polymer. And what is that mission? To create high level, application specific web components with as little fuss as possible. In particular, webcomponents that are mostly markup, with very little script, compositions consisting of lower level web components glued together declaratively.

<xtal-pattern> weighs 920B minified and gzip'd.

<xtal-pattern>, though it is markup centric, allows the javascript to be defined in the same file.

Although the current implementation is done using Polymer 2, the hope is that when Polymer 3 is released, this helper library will provide a nice counterpoint to the JavaScript-oriented direction Polymer 3 is moving towards.

Defining a xtal-pattern based web component

Step 1:

To create a web component, create an html file, and give it a name matching the name of the component you wish to define, for example: my-component.html

Inside my-component.html, define some markup, for example:

<!-- Contents of my-component.html -->
<div>Hello, {{entity}}</div>

Step 2:

To register this as a web component, use <xtal-pattern> in the containing component markup:

<xtal-pattern href="path/to/my-component.html">

xtal-pattern will autogenerate a Polymer web component with name "my-component." It will look for tokens of the form: {{xyz}} automatically declare a property with that name.

To specify specific settings for the property, use notation as demmonstrated below:

<div>{{entity|type:String, reflectToAttribute: true, observer:'onPropsChange'}}</div>

Note that references to images, etc, within my-component.html will all be relative to the base url of the web site / page open in the browser.

Step 3.

Use the new component:

<my-component entity="world"></my-component>

Step 4.

Wait for the world to say hi back.

Custom JavaScript

In the markup above, we defined an observer, "onPropsChange." Such observers, as well as computed properties and event handlers will need to be defined in a script tag between //{ and //}:

<script>
    //{
    function onPropsChange(){
        this.doStuff();
    }

    function ready(){
        super.ready();
        ...
    }

    function connectedCallback(){
        super.connectedCallback();
        ...
    }
    //}
</script>

Install the Polymer-CLI

First, make sure you have the Polymer CLI installed. Then run polymer serve to serve your element locally.

Viewing Your Element

$ polymer serve

Running Tests

$ polymer test

Your application is already set up to be tested via web-component-tester. Run polymer test to run your application's test suite locally.