6.0.1 • Published 11 months ago

@nice-digital/icons v6.0.1

Weekly downloads
166
License
MIT
Repository
github
Last release
11 months ago

NICE Icons

Icons for use in NICE Digital Services

npm GitHub release License Dependencies Dev dependencies

Intro

NICE Icons is a set of SVG icons for use in NICE Digital Services using the NICE Design System. It provides source SVGs, React/TypeScript versions and an icon font.

Some background

NICE Icons is a replacement for NICE.Glyphs, which in turn was part of the old 'NICE.Bootstrap'.

Guidance

Avoid unnecessary decoration - only use icons if there's a real user need:

  • if icons are needed ensure they are clear, simple and accompanied by relevant text
  • don't hide functionality under icons
  • icons should be easily recognizable
  • keep icon designs simple and schematic.

Upgrading from 1.x to 2.9

The following are breaking changes from v1 to v2:

  • the generated SASS file is at a new path - now at /scss rather than dist/ to be consistent with other packages
  • the SASS base path variable $nice-font-base-path is now $nice-icons-base-path
  • the SASS mixin icon-base is now nice-icons-base
  • there are no nested folders within src
  • dropped speak: none CSS property
  • dropped support for usage via Bower
  • use Node 10, and npm 6.8+.

What's new in v2.0?

As well as the breaking changes listed above, we've made the following updates:

  • upgrade to Babel 7
  • upgrade other outdated packages
  • add Figma source file containing all the SVG icons
  • add React components, with ES5 transpiled version.

What's new in v2.3?

Version 2.3 is an internal refactor, mostly to use fantasticon instead of grunt-webfont for the icon font generation. This release drops support for IE8, which we no longer support but that should be the only 'breaking' change.

We have removed generation of EOT, SVG and TTF font files because we know longer support older browsers like IE8 that needed these types. We now just generate WOFF and WOFF2 which covers all modern browsers.

Installation

Install NICE Icons from npm:

npm i @nice-digital/icons --save

The node_modules/@nice-digital/icons package folder will include:

  • source SVG files in the src folder
  • React components:
    • ES5 in the lib folder (with associated d.ts files)
    • ES6 in the es folder (with associated d.ts files)
    • TypeScript in the ts folder
  • generated icon font (WOFF and WOFF 2) in the dist folder
  • generated SCSS in the scss folder
  • JSON file in the dist folder with font metadata information.

Include sass

Import NICE Icons in SASS with:

@use '@nice-digital/icons/scss/nice-icons';

Usage

There are 2 main ways to use NICE Icons in your project:

React

There are React component versions of each icon within the lib folder (transpiled to ES5) or the es folder (ES6 compatible). This allows you to easily include inline SVGs when rendering via React. Each icon file is named with PascalCase, for example src/email-closed.svg is available in React as lib/EmailClosed.js.

To use, first import the SASS file into your project as above. Then import and use React components from the lib folder, for example:

import Search from "@nice-digital/icons/lib/Search";

const something = (props) => {
	return <div>
		<Search />
	</div>;
};

The React component icons have the following default props:

  • className=icon - the associated class has a height and width of 1em to match the surrounding text
  • aria-hidden={true} as they're designed to be a visual to textual labels. In the rare case you need icons on their own without text, then pass a prop of aria-hidden={false} and make sure there's an associated aria label, title etc.

The svg path also has a default fill=currentColor to match surrounding text colour, but this can also be overridden via CSS.

Note: these React files in the lib folder are ES5 compatible. However, we also include ES6 versions in the es folder if you prefer. This means you'll need to transpile these with babel (or similar) as part of your build. For example, by using the include option pointing to node_modules/@nice-digital/icons with babel-loader in webpack.

Browser support

This method is subject to the same browser support as inline SVGs - essentially IE9+.

Webfont

We provide a custom icon web font because:

  • it's easy to render custom icons with content managed markup
  • there's no JavaScript required
  • icon color, size, shadow etc can be styled with CSS
  • any custom icons can be used
  • icon fonts support IE8+
  • vector icons are infinitely scalable
  • vector icons look perfect on retina displays.

Serving font files

Note: Add the corrrect MIME type to your web.config if you get a 404 error for .woff files in IIS.

Express

Use express.static to serve font files in Express directly from the dist folder:

const express = require("express"),
	path = require("path");

const app = express();

app.use("/fonts", express.static(path.join(__dirname, "./node_modules/@nice-digital/icons/dist")))

See the simple-express folder for a complete example of this.

Visual Studio Copy Task

Use a Visual Studio Copy Task to copy the font files into your application. Or use a post build event.

Webpack

Install Copy Webpack Plugin into your application, then at the top of your webpack config file add the following:

const CopyWebpackPlugin = require('copy-webpack-plugin');

then in the plugins section add the following:

new CopyWebpackPlugin([{ from: "node_modules/@nice-digital/icons/dist/*", to: "fonts", ignore: ["*.html"], flatten: true }]),

note that the 'to' destination is relative to the output path, which for a .NET core app would probably have been configured for wwwroot.

Markup

Use custom icons in markup (rather than SASS) wherever possible:

  • hide from screenreaders with [aria-hidden="true"]
  • use BEM style CSS classes (icon--NAME modifier)
  • prefer <span> over <i>.

Basics of usage are: <span class="icon icon--[NAME]" aria-hidden="true"></span> where name is one of the source icons e.g.:

<span class="icon icon--logo" aria-hidden="true"></span>

SASS

There are SASS constructs for advanced usage:

  • @mixin nice-icons-base for the base styles required for an icon
  • @mixin nice-icon($icon)n e.g. @include nice-icon(logo);
  • @function nice-icon($icon) e.g. content: nice-icon(logo); - gets the unicode codepoint value
  • $nice-icons - a map of icon name to unicode codepoint. Override this when generating a custom webfont in your application
  • $nice-icons-base-path - the URL from which to download the font files. Override this in your application if you serve font files from a different path.
.logo {
	&__btn {
		@include nice-icon(logo);
	}

	// or
	&__btn {
		@include nice-icons-base;

		&:before {
			content: nice-icon(logo);
			display: block;
		}
	}
}

Development

Dependencies

TL;DR:
	1. `npm i`
	2. `npm start`

To build the icon font on your local machine, first install:

Then before you can run any tasks, run the following from the command line to install dependencies npm i

Commands

Run npm start from the command line for development. This uses fantasticon under the hood to:

Updating the readme

Run the following command to update the readme:

npm run readme

This will generate the table of icons from the readme and to update the ToC.

Creating icons

We provide a Figma file(NICE Icons.fig) with the source of all icons. Upload this into Figma and add a new Page for each icon.

Note: Figma is an online (and desktop) design and wireframing-type application. We're using it here in the context of a vector drawing tool, like Adobe Illustrator. The steps below will essentially take you through opening the existing project file with all the icons in, adding a new one in the "right" way (so it's a standard format with all of the other icons), exporting your new icon as an SVG to add to the repo, and re-saving the project file ready for the next person.

Follow the following steps to create a new SVG in Figma:

  1. Add page with the correct name eg "Address book"
  2. If you have an existing SVG, drag it into the page pane. If creating a custom SVG, ensure you have a single compound path vector.
  3. Set X and Y to 0 and 0
  4. Add a 32px layout grid to the frame
  5. Rename the frame (with the hash symbol) to "Address book frame" and the vector within it to "Address book vector"
  6. On the vector, change the constraints to Centre and Centre.
  7. On the frame change the width and height to 512px.
  8. On the vector, SHIFT+Click the corner resize tool and give it 1 square padding
  9. Centre the vector using the icons at the top of the design tool panel or use ALT+V and ALT+H when the vector is inside the frame.
  10. On the Address book page, add an export setting with type of SVG, then export the SVG changing the filename to kebab case eg "address-book.svg" and save in the src folder. (Alternatively, right-click the frame and Copy As SVG)
  11. Ensure the SVG file has the XML declaration at the top, the same as all the other SVG files in the repository.
  12. In Figma menu, File > Save as .fig and save a new copy of NICE Icons.fig, in the root of the repository.

Afterwards,

  1. Re-run npm start to rebuild the icon font and React components
  2. Re-run npm run readme to rebuild the icons in this readme file.

Icons

IconNameUnicodeHTMLSCSS
androidf17b<span class="icon icon--android" aria-hidden="true"></span>@include nice-icon(android);
applef179<span class="icon icon--apple" aria-hidden="true"></span>@include nice-icon(apple);
calendare045<span class="icon icon--calendar" aria-hidden="true"></span>@include nice-icon(calendar);
checkf00c<span class="icon icon--check" aria-hidden="true"></span>@include nice-icon(check);
chevron-downe03c<span class="icon icon--chevron-down" aria-hidden="true"></span>@include nice-icon(chevron-down);
chevron-lefte03b<span class="icon icon--chevron-left" aria-hidden="true"></span>@include nice-icon(chevron-left);
chevron-righte03a<span class="icon icon--chevron-right" aria-hidden="true"></span>@include nice-icon(chevron-right);
chevron-upe039<span class="icon icon--chevron-up" aria-hidden="true"></span>@include nice-icon(chevron-up);
commentf101<span class="icon icon--comment" aria-hidden="true"></span>@include nice-icon(comment);
downloade006<span class="icon icon--download" aria-hidden="true"></span>@include nice-icon(download);
email-closede014<span class="icon icon--email-closed" aria-hidden="true"></span>@include nice-icon(email-closed);
evidencee017<span class="icon icon--evidence" aria-hidden="true"></span>@include nice-icon(evidence);
facebooke012<span class="icon icon--facebook" aria-hidden="true"></span>@include nice-icon(facebook);
facebook-squaref082<span class="icon icon--facebook-square" aria-hidden="true"></span>@include nice-icon(facebook-square);
google-plusf0d5<span class="icon icon--google-plus" aria-hidden="true"></span>@include nice-icon(google-plus);
google-plus-squaref0d4<span class="icon icon--google-plus-square" aria-hidden="true"></span>@include nice-icon(google-plus-square);
guidancee011<span class="icon icon--guidance" aria-hidden="true"></span>@include nice-icon(guidance);
hamburgere03d<span class="icon icon--hamburger" aria-hidden="true"></span>@include nice-icon(hamburger);
instagramf16d<span class="icon icon--instagram" aria-hidden="true"></span>@include nice-icon(instagram);
linkedinf0e1<span class="icon icon--linkedin" aria-hidden="true"></span>@include nice-icon(linkedin);
linkedin-signf08c<span class="icon icon--linkedin-sign" aria-hidden="true"></span>@include nice-icon(linkedin-sign);
locationf102<span class="icon icon--location" aria-hidden="true"></span>@include nice-icon(location);
logoe01a<span class="icon icon--logo" aria-hidden="true"></span>@include nice-icon(logo);
logo-fulle01c<span class="icon icon--logo-full" aria-hidden="true"></span>@include nice-icon(logo-full);
logo-namee01b<span class="icon icon--logo-name" aria-hidden="true"></span>@include nice-icon(logo-name);
logo-portraitf103<span class="icon icon--logo-portrait" aria-hidden="true"></span>@include nice-icon(logo-portrait);
minuse02a<span class="icon icon--minus" aria-hidden="true"></span>@include nice-icon(minus);
pathwayse005<span class="icon icon--pathways" aria-hidden="true"></span>@include nice-icon(pathways);
playe028<span class="icon icon--play" aria-hidden="true"></span>@include nice-icon(play);
pluse027<span class="icon icon--plus" aria-hidden="true"></span>@include nice-icon(plus);
podcaste00b<span class="icon icon--podcast" aria-hidden="true"></span>@include nice-icon(podcast);
printe001<span class="icon icon--print" aria-hidden="true"></span>@include nice-icon(print);
question-circlef059<span class="icon icon--question-circle" aria-hidden="true"></span>@include nice-icon(question-circle);
readnewse009<span class="icon icon--readnews" aria-hidden="true"></span>@include nice-icon(readnews);
removee024<span class="icon icon--remove" aria-hidden="true"></span>@include nice-icon(remove);
searche004<span class="icon icon--search" aria-hidden="true"></span>@include nice-icon(search);
sharee008<span class="icon icon--share" aria-hidden="true"></span>@include nice-icon(share);
sortinge021<span class="icon icon--sorting" aria-hidden="true"></span>@include nice-icon(sorting);
sorting-asce022<span class="icon icon--sorting-asc" aria-hidden="true"></span>@include nice-icon(sorting-asc);
sorting-desce023<span class="icon icon--sorting-desc" aria-hidden="true"></span>@include nice-icon(sorting-desc);
standardse002<span class="icon icon--standards" aria-hidden="true"></span>@include nice-icon(standards);
stope043<span class="icon icon--stop" aria-hidden="true"></span>@include nice-icon(stop);
syndicatione013<span class="icon icon--syndication" aria-hidden="true"></span>@include nice-icon(syndication);
trashe020<span class="icon icon--trash" aria-hidden="true"></span>@include nice-icon(trash);
twittere000<span class="icon icon--twitter" aria-hidden="true"></span>@include nice-icon(twitter);
twitter-squaref081<span class="icon icon--twitter-square" aria-hidden="true"></span>@include nice-icon(twitter-square);
usere01f<span class="icon icon--user" aria-hidden="true"></span>@include nice-icon(user);
warninge04b<span class="icon icon--warning" aria-hidden="true"></span>@include nice-icon(warning);
youtube-playf16a<span class="icon icon--youtube-play" aria-hidden="true"></span>@include nice-icon(youtube-play);
youtube-squaref166<span class="icon icon--youtube-square" aria-hidden="true"></span>@include nice-icon(youtube-square);

License

NICE Icons distributed under the MIT license.

We use some icons from the awesome Font Awesome Free, which is licensed under the CC BY 4.0 license.

6.0.1

11 months ago

6.0.0

1 year ago

6.0.0-alpha.0

1 year ago

5.0.2-alpha.0

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

3.0.2-alpha.0

2 years ago

4.0.0-alpha.0

2 years ago

4.0.1-alpha.0

2 years ago

3.0.1-alpha.0

2 years ago

3.0.0

2 years ago

2.2.7

3 years ago

2.1.8

3 years ago

2.2.7-alpha.0

3 years ago

2.2.5

3 years ago

2.2.6-alpha.0

3 years ago

2.2.5-alpha.0

3 years ago

2.2.4-alpha.0

3 years ago

2.2.3

3 years ago

2.2.3-alpha.0

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-beta.5

5 years ago

2.0.0-beta.4

5 years ago

2.0.0-beta.3

5 years ago

1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago