3.0.1 • Published 6 years ago

@polymer/iron-iconset-svg v3.0.1

Weekly downloads
28,846
License
BSD-3-Clause
Repository
github
Last release
6 years ago

Published on NPM Build status Published on webcomponents.org

<iron-iconset-svg>

The iron-iconset-svg element allows users to define their own icon sets that contain svg icons.

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/iron-iconset-svg

In an HTML file

<html>
  <head>
    <script type="module">
      import '@polymer/iron-iconset-svg/iron-iconset-svg.js';
      import '@polymer/iron-icon/iron-icon.js';
    </script>
  </head>
  <body>
    <iron-iconset-svg name="inline" size="24">
      <svg>
        <defs>
          <g id="shape">
            <rect x="12" y="0" width="12" height="24"></rect>
            <circle cx="12" cy="12" r="12"></circle>
          </g>
        </defs>
      </svg>
    </iron-iconset-svg>

    <iron-icon icon="inline:shape" role="img" aria-label="A shape"></iron-icon>
  </body>
</html>

In a Polymer 3 element

You can use an <iron-iconset-svg> anywhere you could put a custom element, such as in the shadow root of another component to expose icons to it. However, if you're going to be creating many instances of the containing component, you should move your <iron-iconset-svg> out to a separate module. This prevents a redundant <iron-iconset-svg> from being added to the shadow root of each instance of that component. See the demo (and specifically demo/svg-sample-icons.js) for an example.

import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';

import '@polymer/iron-iconset-svg/iron-iconset-svg.js';
import '@polymer/iron-icon/iron-icon.js';

class ExampleElement extends PolymerElement {
  static get template() {
    return html`
      <iron-iconset-svg name="inline" size="24">
        <svg>
          <defs>
            <g id="shape">
              <rect x="12" y="0" width="12" height="24"></rect>
              <circle cx="12" cy="12" r="12"></circle>
            </g>
          </defs>
        </svg>
      </iron-iconset-svg>

      <iron-icon icon="inline:shape" role="img" aria-label="A shape"></iron-icon>
    `;
  }
}

customElements.define('example-element', ExampleElement);

Contributing

If you want to send a PR to this element, here are the instructions for running the tests and demo locally:

Installation

git clone https://github.com/PolymerElements/iron-iconset-svg
cd iron-iconset-svg
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
zagen-zagensimple-material-table@infinitebrahmanuniverse/nolb-_pol@everything-registry/sub-chunk-731code-sampleexp-paper-input-placef-ua-parserg-elementh2-elementsdelightful-iconsiron-swiper-3polymer-starter-kit-publish-demopolymer-starter-kitpolymer3-font-awesomepaper-input-placeplayer-iconsplastic-map-info@edirect/app-datepickerlive-localizerlit-paginationisuwang-elementsisu-elementsisu-elementskeleton-carouselskyeditoroe-ui-miscunity-core-betavaadin-flow-bomwysiwyg-e-forkwysiwyg-e-nofont@unicef-polymer/etools-date-time@uvalib/uvalib-theme@vaadin/vaadin-core@vaadin/vaadin-core-shrinkwrap@vaadin/vaadin-lumo-styles@vaadin/icons@vaadin-component-factory/vcf-context-item@vaadin-component-factory/vcf-network@vaadin-component-factory/vcf-pwa-install-button@vaadin-component-factory/vcf-share-dialog@vaadin-component-factory/vcf-webshare-button@smyd/app-shared@smyd/asg-icons@smyd/asg-shop-card-shared-elements@ucd-lib/fin-icons@ucd-lib/cork-icons@polymer/iron-elements@silverlinkz/sl-gallery@scoped-vaadin/vaadin-lumo-styles@scoped-vaadin/icons@things-real/shell@polymer/iron-icons@polymer/paper-dropdown-menu@polymer/paper-swatch-picker@polymer/paper-tabs@polymer/polymer-starter-kit@spriteful/app-icons@spriteful/app-media@spriteful/asg-icons@spriteful/meta-waves-elements@spriteful/cms-icons@spriteful/asg-shop-card-shared-elements@spriteful/spriteful-icons@spriteful/spriteful-cms-carousels@spriteful/spriteful-cms-icons@vaadin/vaadin-shrinkwrap@collaborne/paper-chip@kano/kwc-color-picker@kano/kwc-icons@kano/code@kano-computing/kwc-color-picker@kano/web-components@haxtheweb/drawing-icons@haxtheweb/lrn-icons@haxtheweb/md-extra-icons@haxtheweb/mdi-iconset-svg@haxtheweb/social-media-icons@hatiolab/things-shell@whcg/vaadin-lumo-styles@exmg/exmg-paper-combobox@exmg/exmg-paper-token-input@cromwellian/granite-qrcode-scanner@cwmr/paper-chip@cwmr/paper-autocomplete@google-web-components/google-signin@jasoftware/jas-breadcrumbs@heyokaysaturday/test-components@longlost/cms-icons@longlost/ezf-shared@longlost/leaflet-map@longlost/app-camera@longlost/app-carousels@longlost/app-icons@longlost/app-shell@longlost/app-core@longlost/app-file-system@longlost/app-images@longlost/app-inputs@longlost/app-map@lrnwebcomponents/drawing-icons
3.0.1

6 years ago

3.0.0

6 years ago

3.0.0-pre.26

6 years ago

3.0.0-pre.25

6 years ago

3.0.0-pre.24

6 years ago

3.0.0-pre.23

6 years ago

3.0.0-pre.22

6 years ago

3.0.0-pre.21

6 years ago

3.0.0-pre.20

6 years ago

3.0.0-pre.19

6 years ago

3.0.0-pre.18

6 years ago

3.0.0-pre.17

6 years ago

3.0.0-pre.16

6 years ago

3.0.0-pre.15

6 years ago

3.0.0-pre.14

6 years ago

3.0.0-pre.13

6 years ago

3.0.0-pre.12

7 years ago

3.0.0-pre.11

7 years ago

3.0.0-pre.10

7 years ago

3.0.0-pre.8

7 years ago

3.0.0-pre.7

7 years ago

3.0.0-pre.6

7 years ago

3.0.0-pre.4

7 years ago

3.0.0-pre.3

7 years ago

3.0.0-pre.2

7 years ago

3.0.0-pre.1

7 years ago

1.1.0-pre.3

8 years ago

1.1.0-pre.2

8 years ago

1.1.0-pre.1

8 years ago

0.0.4

8 years ago

0.0.3

9 years ago

0.0.1

9 years ago