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

electron-sfsymbols

v1.0.0-alpha.4

Published

TypeScript NPM Module Boilerplate

Downloads

21

Readme

Getting started

Use any of the over 5,000 icons provided by  Apple in your macOS application.

Please note: the package is only responsible to give you access to SF symbols on electron on macOS - the package does not handle different platforms and will likely produce errors on any other operating system than macOS.

⚠️ Legal ⚠️: SF Symbols are strictly copyrighted by Apple (read more here). This package is not intented to use the icons on any other platforms or in conflict with the guidelines provided by Apple Inc. This package generates the symbols on the fly, using rougly the same logic as the Electron.NativeImage.fromNamedImage API.

Installation

Install using your go-to package manager:

yarn add electron-sfsymbols

or

npm i -S electron-sfsymbols

Since the package uses a binary to generate the symbols, for it to work correctly the build options have to be updated.

# electron-builder.yaml

extraResources:
  - ./resources/**
  - from: node_modules/electron-sfsymbols/lib/bin/sfsymbol
    to: bin/sfsymbol

The package will look for the binary at resourcesPath/bin/sfsymbol - this path can be manually changed by passing a third argument to any of the methods.

Usage

Basic usage with Electron's NativeImage

Create a 24x24 pixel NativeImage from the specified SF Symbol

import { getSfSymbolAsNativeImage } from 'electron-sfsymbols';

// ...

const image = getSfSymbolAsNativeImage('folder', { mode: 'palette', weight: 'black' });

Usage with custom binary

Specify the path to the binary

import { getSfSymbolAsNativeImage } from 'electron-sfsymbols';

// ...

const image = getSfSymbolAsNativeImage(
  'folder',
  { mode: 'palette', weight: 'black' },
  join(getResourcesDirectory(), 'sfsymbol'),
);

Advance Usage

This package gives you access to all the basic options of SfSymbols:

| Parameter | Description | Type | Default | | :-------- | :------------------------------------------------------------------------------------------------------- | :-------------: | :----------: | | size | Size of the Symbol in pixels | Int | 24 | | scale | Scale of the Symbol, for retina displays. The resulting image will have the dimensions of size * scale | Int | 3 | | weight |  Weight of the Symbol |  SfSymbolWeight | regular | | mode |  Rendering mode of the symbol |  SfSymbolMode | monochrome | | variable | Controls the variable property of the symbol |  Float (0-1) |  1.0 | | primary |  Primary color of the symbol | SfSymbolColor | #0000000 | | secondary | Secondary color of the symbol | SfSymbolColor | #0000000 | | Tertiary | Tertiary color of the symbol | SfSymbolColor | #0000000 |

Colors

The symbols can accept either rgba colors, hex or css colors.

Please note: For unrecognised or malformed colors the package throws an UNRECOGNISED_COLOR error.

| Primary Color |  Secondary Color |  Tertiary Color |  Result | | :------------------------: | :--------------------------------: | :-------------: | :--------------------------------------: | | #EF2D56 | #ED7D3A33 | - | Hex | | { r: 239, g: 45, b: 86 } | { r: 237, g: 125, b:58, a: 0.4 } | - | Rgb | | [239, 45, 86] | [237, 125, 58, 0.4] | - | Rgb | | red | orange | - | Rgb |

Modes

| Mode code |  Description |  Example | | :--------------- | :------------------------------------------------- | :-----------------------------------------------: | | monochrome | The default rendering mode for the symbols  | Monochrome | | palette | Define a range of colors for the symbol  | Palette | | hierarchical | Let the symbol decide the hierarchy of the colors  | Hierarchical | | multicolor | Use the multicolor version of the symbol | Multicolor |

Configurations used for the examples:

Monochrome:

const options: SfSymbolOptions = {
  mode: 'monochrome',
  primary: '00000000',
};

Palette:

const options: SfSymbolOptions = {
  mode: 'palette',
  primary: 'FFFFFFFF',
  secondary: '00FF00FF',
  tertiary: '00FF00FF',
};

Hierarchical:

const options: SfSymbolOptions = {
  mode: 'multicolor',
  primary: '00000000',
};

Multicolor

const options: SfSymbolOptions = {
  mode: 'multicolor',
};

Variable Symbols

Many of the SF Symbols are variable icons - these symbols can be controlled using the variable option; a float between 0 and 1.

Examples:

| Variable |  Example  | | :------- | :-----------------------------------------------: | | 1.0 |   Variable-1 | | 0.5 |   Variable-1 | | 0.0 |   Variable-1 |

Weights

Sf Symbols support 8 weights other than the regular one

| Weight | Example | | :----------- | :--------------------------------------------: | | ultralight |  ultralight | | thin |  thin | | light |  light | | regular |  regular | | medium |  medium | | semibold |  semibold | | bold |  bold | | heavy |  heavy | | black |  black |

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Or buy me a coffee 🙌🏾

📝 License

Copyright © 2022 Balázs Szalay. This project is MIT licensed.