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

fontawesome-svg-mdi

v1.0.1

Published

A tool to allow you to use Material Design Icons with the Fontawesome SVG javascript library

Downloads

87

Readme

fontawesome-svg-mdi

CircleCI Coverage Status Known Vulnerabilities npm version

This library provides a converter to create FontAwesome icon definitions (for use with FontAwesome javascript libraries) from Material Design Icon's javascript icons (@mdi/js). This allows Material Design Icons to be used with Fontawesome tooling and mixed with the FontAwesome icon sets.

Install

npm: npm install fontawesome-svg-mdi

yarn: yarn add fontawesome-svg-mdi

Basic Usage

Create a converter instance of MDItoFAIcon to allow you to convert icons.

Run the convert method for each icon you need to convert, providing the icon from @mdi/js and a name for usage with FontAwesome. See API Documentation below for additional options and advanced usage.

import MDItoFAIcon from 'fontawesome-svg-mdi';
import { mdiAccount } from '@mdi/js';

const mdiConverter = new MDItoFAIcon();

const faAccount = mdiConverter.convert(mdiAccount, 'account') 

faAccount can then be passed into any FontAwesome javascript method. When using icons Material Design Icons these can be used as part of the mdi set and css class.

<i class="mdi fa-account" aria-hidden="true"></i> 

Webpack

In your Webpack pack definition convert any required icons and pass these into FontAwesome's library.add.

import { library } from '@fortawesome/fontawesome-svg-core';
import faEnvelope from '@fortawesome/fontawesome-free-solid/faEnvelope';
import { mdiAccount } from '@mdi/js';

const mdiConverter = new MDItoFAIcon();
const faAccount = mdiConverter.convert(mdiAccount, 'account')

library.add(faEnvelope, faAccount);

You can then use these as you would other FontAwesome icons using the mdi class.

<i class="mdi fa-account" aria-hidden="true"></i> 

React

Convert any required icons and pass these into FontAwesome's FontAwesomeIcon React component.

import ReactDOM from 'react-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { mdiAccount } from '@mdi/js';

const mdiConverter = new MDItoFAIcon();
const faAccount = mdiConverter.convert(mdiAccount, 'account');

const element = <FontAwesomeIcon icon={faAccount} />;

ReactDOM.render(element, document.body);

API Documentation

Whilst the default options are suitable for most use-cases the API provides options for setting any possible configurations.

MDItoFAIcon Class

.constructor(options)

  • options
    • mdiPrefix - Icon set and prefix string. Default: mdi
    • mdiWidth - Default icon width for all converted icons. Default: 24
    • mdiHeight - Default icon height for all converted icons. Default: 24

.convert(mdiIcon, iconName, options)

  • mdiIcon - An icon from the @mdi/js library.
  • iconName - The name that will be prefixed with fa- and can be used as a class name to reference an icon when using <i> substitution. This should be unique.
  • options
    • width - Default icon width for all converted icons. Default: 24
    • height - Default icon height for all converted icons. Default: 24
    • ligatures - Array of ligature definitions for FontAwesome's rendering. Default: []
    • unicode - String hexadecimal representation of the unicode codepoint FontAwesome will substitute for this icon. It is recommended to only use codepoints in the private use area and avoid reusing codepoints used by other FontAwesome icons which are in use.