ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Polymer & Web Component Snippets

by robdodson ST2/ST3

Sublime snippets for Polymer and Web Components

Labels snippets

Details

  • 2017.01.24.20.01.54
  • github.​com
  • github.​com
  • 3 months ago
  • Just now
  • 3 years ago

Installs

  • Total 10K
  • Win 4K
  • OS X 4K
  • Linux 2K
Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11
Windows 0 2 1 1 2 1 3 4 3 0 1 0 2 6 3 2 3 0 5 2 2 1 1 3 3 2 1 3 5 2 0 3 4 4 2 0 4 0 1 5 0 3 3 4 2 3
OS X 0 0 0 0 1 2 4 1 1 2 0 0 3 2 2 2 1 0 2 1 2 3 3 0 3 1 1 3 0 1 0 1 1 2 1 3 4 1 0 0 3 3 2 3 1 2
Linux 0 1 0 1 0 2 1 1 2 1 0 1 2 4 0 0 2 0 3 1 3 1 0 0 1 0 0 0 2 3 0 1 1 1 0 0 0 1 4 0 0 2 0 1 1 1

Readme

Source
raw.​githubusercontent.​com

Polymer Snippets for Sublime

Install

To install through Package Control, search for Polymer & Web Component Snippets. If you still don't have Package Control in Sublime Text, go get it. It's pure awesomeness.

If you don't use Package Control, you can download the package and put it manually inside your Packages directory. It should work but will not update automatically.

Elements

Type the name of any iron-* or paper-* element, then hit tab to auto complete. Ex:

Using snippets

OR, start typing the prefix for an element and hit ctrl+space to fuzzy search for a completion. Ex:

Fuzz auto complete

Polymer

[pe] polymer element

<dom-module id="$1">
    <template>
        <style>
            :host {
                display: block;
            }
        </style>
        $2
    </template>
    <script>
        Polymer({
            is: '$1'
        });
    </script>
</dom-module>

[pes] polymer element with external stylesheet

<dom-module id="$1">
    <link rel="import" type="css" href="$1.css">
    <template>
        $2
    </template>
    <script>
        Polymer({
            is: '$1'
        });
    </script>
</dom-module>

[hi] html import (I use this one a lot)

<link rel="import" href="${1:bower_components}/${0}/${0}.html">

[hii] html import iron-* element

<link rel="import" href="${1:bower_components}/iron-${2}/iron-${2}.html">

[hip] html import paper-* element

<link rel="import" href="${1:bower_components}/paper-${2}/paper-${2}.html">

Web Components

[template] template

<template$1>$0</template>

[ce] custom element

var ${4:tmpl} = document.querySelector('${5:template}');

var ${1:WidgetProto} = Object.create(HTMLElement.prototype);

${1:WidgetProto}.createdCallback = function() {
    var root = this.createShadowRoot();
    root.appendChild(document.importNode(${4:tmpl}.content, true));
};

var ${2:Widget} = document.registerElement('${3:my-widget}', {
    prototype: ${1:WidgetProto}
});

HTML

[ph] HTML template with Web Components polyfill

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <title>${1}</title>
    <meta name="description" content="${2}">


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


    <meta name="mobile-web-app-capable" content="yes">
    <meta name="theme-color" content="black">
    <link rel="icon" href="icon.png">


    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png">


    <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
</head>
<body unresolved>
    $0
</body>
</html>

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License © Rob Dodson