-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icons): support "icons" contribution point #2594
## Problem This PR re-organizes how we do icons within the Toolkit, mostly by leveraging the VS Code icons contribution point. The old structure had the following problems: * No clear guidance for how to add and use icons within the Toolkit * Difficult to keep track of what icons are actually being used * Have to maintain separate light/dark icons for everything * Impossible to use our current icons with ThemeIcon * Using SVGs in Webviews in-lines them ## Solution * Put all icons in resources/icons * There's a single, top-level "namespace" to help a bit for organization * Everything within a namespace is flattened out at build time * Use the new icons contribution point * This section is generated (otherwise it'd be really tedious....) * Generate CSS classes from an icon font * Add function getIcon that handles all the legacy/Cloud9 compatibility logic. * Contributors no longer need to touch a bunch of files just to add a single icon.
- Loading branch information
1 parent
c8c92b8
commit a762271
Showing
206 changed files
with
2,710 additions
and
2,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
out | ||
resources/endpoints.json | ||
third-party/** | ||
CHANGELOG.md | ||
src/shared/telemetry/service-2.json | ||
.changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Icons | ||
|
||
All icons that are used in the Toolkit can be found in `resources/icons`. | ||
|
||
A [build script](../../scripts/build/generateIcons.ts) generates Toolkit artifacts: | ||
|
||
- `resources/icons/cloud9/generated` | ||
- `resources/fonts/aws-toolkit-icons.woff` | ||
- `resources/css/icons.css` | ||
- `contributes.icons` in [package.json](../../package.json) | ||
|
||
This script should be ran using `npm run generatePackage` after making updates. Any changes made to `package.json` should be committed with the relevant icons. | ||
|
||
## Fonts | ||
|
||
Icons to be used in fonts should ideally be: | ||
|
||
- Monochromatic (`currentColor` fill or stroke) | ||
- Equal in size and width | ||
- Defined by a single path | ||
|
||
The benefits of doing this include: | ||
|
||
- `ThemeIcon` support | ||
- Automatic generation of CSS classes for webviews | ||
- Static validation of icon identifiers | ||
|
||
If your desired icon does not work well as a font, see [Theme Overrides](#theme-overrides) for adding icons as standalone images. | ||
|
||
## Identifiers | ||
|
||
Icons (except those in `cloud9`) can be referenced within the Toolkit by concatenating the icon path with hyphens, omitting the 'theme' if applicable. | ||
|
||
Examples: | ||
|
||
- `resources/icons/aws/apprunner/service.svg` -> `aws-apprunner-service` | ||
- `resources/icons/vscode/dark/help.svg` -> `vscode-help` | ||
- `resources/icons/vscode/codicons/close.svg` -> `vscode-close` | ||
|
||
This specific format is used to keep things consistent with CSS classes while still supporting some semblance of namespacing. In Webviews, font-based icons can be used through the combination two CSS classes: `icon icon-${IDENTIFIER}`. | ||
|
||
## Theme Overrides | ||
|
||
By default, icons are assumed to be monochromatic and suitable for use as a font. If this is not the case, then icons specific to each theme (i.e. `dark` and `light`) must be added separately. | ||
|
||
For example, if I wanted to use a special App Runner service icon, then I need to add the icons like so: | ||
|
||
- `resources/icons/aws/dark/apprunner-service.svg` | ||
- `resources/icons/aws/light/apprunner-service.svg` | ||
|
||
A similar format is used for overriding icons only on Cloud9: | ||
|
||
- `resources/icons/cloud9/dark/aws-apprunner-service.svg` | ||
- `resources/icons/cloud9/light/aws-apprunner-service.svg` | ||
|
||
These icons will **not** be usuable as Codicons or as font icons. | ||
|
||
## Third Party | ||
|
||
Icons sourced from third-party repositories need a corresponding entry placed within this section. Any added icons need to be placed in their own directory named after the source. Repositories that belong to the same organization may be placed in the same location. | ||
|
||
### VS Code | ||
|
||
[Visual Studio Code Icons](https://github.com/microsoft/vscode-icons) were moved to their own repository in August 2019. These files are located within [resources/icons/vscode](resources/icons/vscode). | ||
|
||
[Visual Studio Code Codicons](https://github.com/microsoft/vscode-codicons). Codicons are VS Code's font-based icon set. These files are located within [resources/icons/vscode/codicons](resources/icons/vscode/codicons). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.