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

@wtf.city/font-picker-vue

v1.0.1

Published

Vue component-based font selector component for Google Fonts

Downloads

10

Readme

Font Picker for Vue

A simple, customizable font picker allowing users to preview, select, and use Google Fonts on your website.

Credits to @sameulmeuli for creating the font-picker, original Vue fork created by @rodrigobendia

  • Automatic font download and generation of the required CSS styles
  • Efficient font previews (previews are loaded dynamically and full fonts are only downloaded on selection)

Demo

This is the Vue component for the Font Picker package.

If you use React, see Font Picker for React.

Getting started

1. Setup

Install the package using NPM:

npm install @wtf.city/font-picker-vue

2. Displaying the font picker

Import the <font-picker> component to your Vue code:


import Vue from 'vue';
import FontPicker from 'font-picker-vue';

Vue.use(FontPicker);

Use the component:

<font-picker :api-key="'YOUR-KEY-HERE'" :options="options" :active-font="fontFamily" @change="myFunc"></font-picker

3. Applying the selected font

Add class="apply-font" to all elements you want to apply the selected font to.

When the user selects a font, it will automatically be downloaded and applied to all HTML elements of the "apply-font" class.

Customization

The following props can be passed to the FontPicker component:

  • apiKey (required): Google API key (can be generated here)
  • activeFont: Font that should be selected in the font picker and applied to the text (default: 'Open Sans'). Must be stored in component state, and be updated using an onChange listener
  • options: Object with additional (optional) parameters:
    • name: If you have multiple font pickers on your site, you need to give them unique names (which may only consist of letters and digits). These names must also be appended to the font picker's ID and the .apply-font class name; e.g. if { name: 'main' }, use #font-picker-main and .apply-font-main
    • families: If only specific fonts shall appear in the list, specify their names in an array (default: all font families)
    • categories: Array of font categories – possible values: 'sans-serif', 'serif', 'display', handwriting', 'monospace' (default: all categories)
    • variants: Array of variants which the fonts must include and which will be downloaded; the first variant in the array will become the default variant (and will be used in the font picker and the .apply-font class); e.g. ['regular', 'italic', '700', '700italic'] (default: ['regular'])
    • filter: Function which must evaluate to true for a font to be included in the list. Default: font => true. Example: If font => font.family.toLowerCase().startsWith("m"), only fonts whose names begin with "M" will be in the list
    • limit: Maximum number of fonts to be displayed in the list (the least popular fonts will be omitted; default: 100)
    • sort: Sorting attribute for the font list – possible values: 'alphabetical' (default), 'popularity'
  • onChange: Function which is executed whenever the user changes the active font and its stylesheet finishes downloading

Contributing

To build the project locally, do the following:

  • git clone
  • npm install
  • npm start to generate the library bundle using Rollup and and start the Storybook for testing the component interactively (localhost:3000)