palantir / blueprint

A React-based UI toolkit for the web
https://blueprintjs.com/
Apache License 2.0
20.68k stars 2.17k forks source link

Add icon files directly in icons package #3377

Open weilandia opened 5 years ago

weilandia commented 5 years ago

Feature request

Add icon files directly in icons package.

This is a continuation of https://github.com/palantir/blueprint/issues/2986.

Currently, if you want to create a custom namespace as described in the docs, you have to download the icons files manually from https://github.com/palantir/blueprint/resources/icons. This is because you need to reference these files in the svg-icon sass function and they are not included in the core or icons packages.

Examples

sassLoader.options.functions = {
  'svg-icon': inliner('PATH_TO_ICONS', {
    optimize: true,
    encodingFormat: 'uri'
  })
};

PATH_TO_ICONS would currently have to reference an icon directory that was manually downloaded from palantir/blueprint. It would be nice if it could be included directly in the icons package.

avkonst commented 5 years ago

It would be even better to make it possible to:

@import '~@blueprintjs/core/src/blueprint.scss';

for react-scripts app. Currently it can not be done as react-scripts loader is not aware about svg-icon function.

Another option is to make an icon for breadcrumbs being specified by a client code (by applications code which uses OverflowList with overflowRenderer function)

avkonst commented 5 years ago

And another option is to split blueprint.scss to 2 parts: the first minimal which depends on special functions and the second which does not depend. In this case, I would import as css the first one and as scss the second one.

justinbhopper commented 5 years ago

I am also using react-scripts, and found that using rescripts (https://github.com/harrysolovay/rescripts/) allows me to customize the webpack functionality, so that I can introduce the missing svg-icons function that Blueprint's scss requires.

However, as this PR states, it does me no good since the SVGs are not distributed. I can't find any good way of gaining reliable access to these SVG files without copying them into my own repository by hand, which is difficult because we aren't always on the latest version of Blueprint.

avkonst commented 5 years ago

Here is the workaround available: https://github.com/palantir/blueprint/issues/2976#issuecomment-479231949