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

wc-fontawesome

v0.4.0

Published

Web component integration with Font Awesome (v5)

Downloads

14

Readme

wc-fontawesome

Web component integration with Font Awesome (v5)

Installation

Libraries

yarn add wc-fontawesome @fortawesome/fontawesome-svg-core

Icons

yarn add @fortawesome/free-regular-svg-icons @fortawesome/free-brands-svg-icons

Usage

import 'wc-fontawesome'
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas, faSpinner } from '@fortawesome/free-solid-svg-icons'

// add all solid icons...
library.add(fas)
// ... or individually
library.add(faSpinner)
<fa-icon icon="spinner"></fa-icon>

Examples

Look at the provided example: clone repository, install dependencies and run npm start script or check the live example.

With shadow Dom

Font Awesome is implemented using global styles which do not work in web components that renders in shadow Dom.

To use wc-fontawesome along side shadow Dom is necessary to add the Font Awesome css in the component. See example below or check how can be done using LitElement styling system.

import { dom } from '@fortawesome/fontawesome-svg-core'

class ElementWithIcons extends HTMLElement {
  constructor() {
    super()
    const shadow = this.attachShadow({ mode: 'open' })
    shadow.innerHTML = `
      <style>
        ${dom.css()}
      </style>
      <fa-icon name="spinner"></fa-icon>
    `
  }
}

Alternatively, enable the usage of shadow Dom in fa-icon component. This will allow to use it in any web component with the drawback of breaking layers functionality:

import { configure } from 'wc-fontawesome'

configure({ shadowDom: true })

Components

  • fa-icon: show icon defined by icon or name property
  • fa-text: show text in layers
  • fa-counter: show counter in layers
  • fa-layers: container for layers (experimental - use div with fa-layers class instead)

Features

The following features are implemented

Basic

Size:

<fa-icon icon="spinner" size="xs"></fa-icon>
<fa-icon icon="spinner" size="lg"></fa-icon>
<fa-icon icon="spinner" size="6x"></fa-icon>

Note that icon size can be controlled with the CSS font-size attribute, and fa-icon's size prop determines icon size relative to the current font-size.

Fixed width:

<fa-icon icon="spinner" fixed-width></fa-icon>

Inverse:

<fa-icon icon="spinner" inverse></fa-icon>

List Items:

<fa-icon icon="spinner" list-item></fa-icon>

Rotate:

<fa-icon icon="spinner" rotation="90"></fa-icon>
<fa-icon icon="spinner" rotation="180"></fa-icon>
<fa-icon icon="spinner" rotation="270"></fa-icon>

Flip horizontally, vertically, or both:

<fa-icon icon="spinner" flip="horizontal"></fa-icon>
<fa-icon icon="spinner" flip="vertical"></fa-icon>
<fa-icon icon="spinner" flip="both"></fa-icon>

Spin and pulse animation:

<fa-icon icon="spinner" spin></fa-icon> <fa-icon icon="spinner" pulse></fa-icon>

Border:

<fa-icon icon="spinner" border></fa-icon>

Pull left or right:

<fa-icon icon="spinner" pull="left"></fa-icon>
<fa-icon icon="spinner" pull="right"></fa-icon>

Swap opacity (duotone icons only):

<fa-icon icon="stroopwafel"></fa-icon>
<fa-icon icon="stroopwafel" swap-opacity></fa-icon>

Advanced

Power Transforms:

<fa-icon icon="spinner" transform="shrink-6 left-4"></fa-icon>

Masking:

<fa-icon icon="coffee" mask="circle"></fa-icon>

Symbols:

<fa-icon icon="edit" symbol></fa-icon>
<fa-icon icon="edit" symbol="edit-icon"></fa-icon>

Layers:

Simple

<span class="fa-layers fa-fw">
  <fa-icon icon="square"></fa-icon>
  <fa-icon icon="check" inverse transform="shrink-6"></fa-icon>
</span>

With text

<span class="fa-layers fa-fw" style="background:MistyRose">
  <fa-icon icon="certificate"></fa-icon>
  <fa-text inverse transform="shrink-11.5 rotate--30" style="font-weight:900"
    >NEW</fa-text
  >
</span>

With counter

<span class="fa-layers fa-fw" style="background:MistyRose">
  <fa-icon icon="envelope"></fa-icon>
  <fa-counter style="background:Tomato">1,419</fa-counter>
</span>

Copyright

2019 - Luiz Américo Pereira Câmara

Ported from react-fontawesome