Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rei/cdr-icon

Package Overview
Dependencies
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rei/cdr-icon

REI Cedar Style Framework - Vue Component for Icon

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
5
Weekly downloads
 
Created
Source

3 ways to use icons

cdr-icon can support 3 different ways of getting svg icons onto your page.

1. SVG Sprite

Slightly more work, but offers the best performance when lots of icons will be used.

Requires:

  • cdr-icons.svg from @rei/cdr-assets
  • file-loader to get url or raw-loader to inline (if using webpack)
  • svgxuse polyfill (included somewhere on page or in your bundle)
Examples:

Inlining the sprite (recommended)

(needs to be available on any page where icons are used so it's best to do it at the base layout/index)

// Base view template (assuming .vue and vue-router)
<template>
  <div id="main">
    <cdr-icon :raw="icons"/>

    <router-view></router-view>
  </div>
</template>

<script>
import icons from '@rei/cdr-assets/dist/cdr-icons.svg'; // have raw-loader handle this
...
data() {
  return {
    icons
  }
}
...
</script>



// Then in any component template
// NOTE: It's just the id of the icon and doesn't need a full url path since it's already in the page DOM
<cdr-icon url="#caret-right" />

Within an individual component (you can probably come up with a better way to scale this if you need to do it in a lot of places):

//  A .vue file

<template>
  ...
  <cdr-icon :url="`${icons}#caret-right`"/>
  ...
</template>

<script>
// import the sprite so file-loader will do its magic
@import icons from '@rei/cdr-assets/dist/cdr-icons.svg`;

export default {
  ...
  data() {
    return {
      icons
    };
  }
}

</script>

2. Inline from standard REI icons

This method will bloat your HTML if using a lot of icons.

This is the easiest way to get an icon on your page. But use it carefully.

Requirements:

  • Have @rei/cdr-assets installed
Examples:
<cdr-icon name="caret-right"/>

3. Inline from external svg file

This method will bloat your HTML if using a lot of icons.

This is so you can include icons from outside of the standard set but still benefit from our classes/a11y that is built in. You might consider making a symbol sprite for your icons if you have to use a lot and then using method 1 above.

Requirements:

None, but you might find the example below helpful.

Examples:

This example assumes you have raw-loader (or something similar) set up

//  A .vue file

<template>
  ...
  <cdr-icon raw="icon"/>
  ...
</template>

<script>
// import the svg so raw-loader will do its magic
@import icon from 'path/to/your-icon.svg`;

export default {
  ...
  data() {
    return {
      icon
    };
  }
}

</script>

FAQs

Package last updated on 09 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc