Giter Site home page Giter Site logo

cloewen8 / stacks-icons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stackexchange/stacks-icons

0.0 0.0 0.0 28.18 MB

Authoring tools for Stack Overflow's shared icon set.

Home Page: https://stackoverflow.design/product/resources/icons

JavaScript 0.94% C# 3.45% HTML 95.52% CSS 0.09%

stacks-icons's Introduction

Icons

Icons

Introduction

This repo provides authoring tools for building Stack Overflow’s shared icon library. Here’s our general workflow:

  1. Open the Figma document to modify an existing icon, or add a new one. Pay close attention to the name of the newly-added artboard. This will determine your SVG’s filename.
  2. Export each artboard / component to the src directory. Since the artboards are prefixed with Icon, the final output directory will be src/Icon.
  3. Open this repo’s directory in Terminal, and type npm start. This will churn through the exported SVGs and build optimized SVGs in the build/lib directory. Some manifest files are included in build as well.

Installing dependencies

In order to use this repo, you must first install Node & NPM. Then, open this repo’s directory in your Terminal. Once you’re in this repo’s folder, type npm install. This will download all the dependencies.

Including Stacks Icons in your project

Stacks Icons are delivered via NPM. It can be installed with npm i @stackoverflow/stacks-icons

Using the CSS icons

In certain cases where adding the raw svg markup to your html would cause bloat or if you need your markup to be more portable, consider using CSS icons. Note: Not all icons are available as CSS icons.

<!-- include the required css file -->
<link rel="stylesheet" href="/path/to/cssIcons.css" />

<!-- add the "svg-icon-bg" class in addition the desired "iconNAME" class -->
<span class="svg-icon-bg iconBold"></span>

<!-- the icon's color matches the "currentColor", so changing the "color" property will change the icon color -->
<span class="svg-icon-bg iconFire" style="color: red;"></span>

<!-- add the "native" class to get native styles; these do not respect "currentColor" changes -->
<span class="svg-icon-bg iconFaceMindBlown native"></span>

You can add support for more CSS icons my editing the src/cssIcons.json file. Supported formats:

  • the name of the icon as a string (e.g. "Bold")
  • an object with the following properties:
    • name - the name of the icon (e.g. "Bold")
    • css - arbitrary css to add to the icon class (e.g. "width: 14px; height: 14px;" )

Using the front-end helper for prototyping

Note: This is not intended to be used in production.

If you include the index.js within your prototype’s body element (<script src="https://unpkg.com/@stackoverflow/stacks-icons"></script>) you can render Stacks Icons in the browser using only the following format:

<svg data-icon="FaceMindBlown" class="native"></svg>
<svg data-spot="Search"></svg>

This package looks out for elements that look like svg[data-icon]. If the icon doesn’t exist in Stacks, it will throw you an error in console. Anything in the class="" attribute will be passed to the included SVG e.g., native

Regex for replacing with @Svg helper

This might be useful if you want to convert a large prototype to use the Razor helper.

Find

<svg data-icon="(.+?)" class="(.+?)"></svg>

Replace

@Svg.$1.With("$2")

Use as a JavaScript module

import Icons from "stacks-icons";

console.log(Icons.FaceMindBlown);

// Returns <svg>...</svg>

stacks-icons's People

Contributors

aaronshekey avatar abovedave avatar b-kelly avatar dependabot[bot] avatar hellohynes avatar parklh avatar piperlawson avatar taiwei426 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.