Skip to content

Commit efb0d8e

Browse files
authored
feat(icons-tnt): add new TNT icon collection (#2414)
based on SAP-icons-TNT
1 parent 7bf44b5 commit efb0d8e

File tree

14 files changed

+615
-23
lines changed

14 files changed

+615
-23
lines changed

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@
99
"ui5"
1010
],
1111
"scripts": {
12-
"build": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:main build:fiori",
12+
"build": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt build:main build:fiori",
1313
"build:localization": "cd packages/localization && yarn build",
1414
"build:base": "cd packages/base && yarn build",
1515
"build:theme-base": "cd packages/theme-base && yarn build",
1616
"build:icons": "cd packages/icons && yarn build",
17+
"build:icons-tnt": "cd packages/icons-tnt && yarn build",
1718
"build:main": "cd packages/main && yarn build",
1819
"build:fiori": "cd packages/fiori && yarn build",
1920
"build:playground": "yarn build:main && yarn build:fiori && cd packages/playground && yarn build",
2021
"build:playground:master": "yarn build:main && yarn build:fiori && cd packages/playground && yarn build:master",
21-
"clean": "npm-run-all --sequential clean:base clean:localization clean:theme-base clean:icons clean:main clean:fiori",
22+
"clean": "npm-run-all --sequential clean:base clean:localization clean:theme-base clean:icons clean:icons-tnt clean:main clean:fiori",
2223
"clean:localization": "cd packages/localization && yarn clean",
2324
"clean:base": "cd packages/base && yarn clean",
2425
"clean:theme-base": "cd packages/theme-base && yarn clean",
2526
"clean:icons": "cd packages/icons && yarn clean",
27+
"clean:icons-tnt": "cd packages/icons-tnt && yarn clean",
2628
"clean:main": "cd packages/main && yarn clean",
2729
"clean:fiori": "cd packages/fiori && yarn clean",
2830
"prepare:main": "cd packages/main && nps prepare",
@@ -35,8 +37,8 @@
3537
"dev:fiori": "cd packages/fiori && nps dev",
3638
"scopeDev:main": "cd packages/main && nps scope.dev",
3739
"scopeDev:fiori": "cd packages/fiori && nps scope.dev",
38-
"start": "npm-run-all --sequential build:base build:localization build:theme-base build:icons prepare:main prepare:fiori start:all",
39-
"startWithScope": "npm-run-all --sequential build:base build:localization build:theme-base build:icons scopePrepare:main scopePrepare:fiori scopeStart:all",
40+
"start": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt prepare:main prepare:fiori start:all",
41+
"startWithScope": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt scopePrepare:main scopePrepare:fiori scopeStart:all",
4042
"start:all": "npm-run-all --parallel dev:base dev:localization dev:main dev:fiori",
4143
"scopeStart:all": "npm-run-all --parallel dev:base dev:localization scopeDev:main scopeDev:fiori",
4244
"start:base": "cd packages/base && yarn start",
@@ -68,6 +70,7 @@
6870
"packages/main",
6971
"packages/fiori",
7072
"packages/icons",
73+
"packages/icons-tnt",
7174
"packages/tools",
7275
"packages/playground"
7376
]

packages/base/src/SVGIconRegistry.js

+25-14
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,41 @@ const iconCollectionPromises = getSharedResource("SVGIcons.promises", new Map())
66
const ICON_NOT_FOUND = "ICON_NOT_FOUND";
77
const DEFAULT_COLLECTION = "SAP-icons";
88

9-
const calcKey = (name, collection) => {
9+
const parseName = name => {
1010
// silently support ui5-compatible URIs
1111
if (name.startsWith("sap-icon://")) {
1212
name = name.replace("sap-icon://", "");
13-
[name, collection] = name.split("/").reverse();
1413
}
14+
15+
let collection;
16+
[name, collection] = name.split("/").reverse();
1517
collection = collection || DEFAULT_COLLECTION;
16-
return `${collection}:${name}`;
18+
// hardcoded alias in case icon explorer is used, resolve `SAP-icons-TNT` to `tnt`
19+
// aliases can be made a feature in the future if more collections need it or more aliases are needed.
20+
if (collection === "SAP-icons-TNT") {
21+
collection = "tnt";
22+
}
23+
const registryKey = `${collection}/${name}`;
24+
return { name, collection, registryKey };
1725
};
1826

27+
1928
const registerIcon = (name, { pathData, ltr, accData, collection } = {}) => { // eslint-disable-line
20-
const key = calcKey(name, collection);
29+
if (!collection) {
30+
collection = DEFAULT_COLLECTION;
31+
}
32+
33+
const key = `${collection}/${name}`;
2134
registry.set(key, { pathData, ltr, accData });
2235
};
2336

24-
const getIconDataSync = (name, collection = DEFAULT_COLLECTION) => {
25-
const key = calcKey(name, collection);
26-
return registry.get(key);
37+
const getIconDataSync = nameProp => {
38+
const { registryKey } = parseName(nameProp);
39+
return registry.get(registryKey);
2740
};
2841

29-
const getIconData = async (name, collection = DEFAULT_COLLECTION) => {
30-
const key = calcKey(name, collection);
42+
const getIconData = async nameProp => {
43+
const { collection, registryKey } = parseName(nameProp);
3144

3245
if (!iconCollectionPromises.has(collection)) {
3346
iconCollectionPromises.set(collection, Promise.resolve(ICON_NOT_FOUND));
@@ -39,14 +52,12 @@ const getIconData = async (name, collection = DEFAULT_COLLECTION) => {
3952
return iconData;
4053
}
4154

42-
return registry.get(key);
55+
return registry.get(registryKey);
4356
};
4457

4558
const getRegisteredNames = async () => {
46-
if (iconCollectionPromises.has(DEFAULT_COLLECTION)) {
47-
await iconCollectionPromises.get(DEFAULT_COLLECTION);
48-
}
49-
return Array.from(registry.keys()).map(k => k.split(":")[1]);
59+
await Promise.all(Array.from(iconCollectionPromises.values()));
60+
return Array.from(registry.keys());
5061
};
5162

5263
const registerCollectionPromise = (collection, promise) => {

packages/icons-tnt/.npmignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.css
2+
dist/resources
3+
dist/test-resources
4+
lib/
5+
node_modules/
6+
src/
7+
test/
8+
bundle.*.js
9+
.eslintrc.js
10+
.eslintignore
11+
main.*js
12+
rollup*
13+
serve.json
14+
wdio.conf.js
15+
!core

packages/icons-tnt/.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Enforce public npm registry
2+
registry = https://registry.npmjs.org/

packages/icons-tnt/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

packages/icons-tnt/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/master/docs/images/UI5_logo_wide.png)
2+
3+
# UI5 Web Components - SAP Fiori Tools Icons
4+
5+
[![Travis CI Build Status](https://travis-ci.org/SAP/ui5-webcomponents.svg?branch=master)](https://travis-ci.org/SAP/ui5-webcomponents)
6+
[![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
7+
8+
Provides assets for the rich `tnt` icon collection.
9+
10+
| Icon asset | Module import |
11+
| ------------------------ | ------------------------------------------------------------------ |
12+
| All icons (~33KB zipped) | `import "@ui5/webcomponents-icons-tnt/dist/Assets.js";` |
13+
| Actor icon | `import "@ui5/webcomponents-icons-tnt/dist/actor.js";` |
14+
| Ad hoc actor icon | `import "@ui5/webcomponents-icons-tnt/dist/ad-hoc-actor.js";` |
15+
| ... | ... |
16+
| Workflow editor icon | `import "@ui5/webcomponents-icons-tnt/dist/workflow-editor.js";` |
17+
18+
*Note:* The `@ui5/webcomponents-icons-tnt` package does not provide any web components per se, but rather icon assets,
19+
usable by other web components such as `ui5-icon`. You could import all icons, but it's recommended to import
20+
just the ones that your app will actually use.
21+
22+
## Usage
23+
24+
Since this is a non-default icon collection, all names have to be prefixed with the collection name and a `/` separator when used by web components.
25+
26+
Example usage with `<ui5-icon>` web component:
27+
28+
```html
29+
<ui5-icon name="tnt/actor"></ui5-icon>
30+
```
31+
32+
For a full list of the icons in the `tnt` collection, click [here](https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/iconExplorer/webapp/index.html#/overview/SAP-icons-TNT).
33+
34+
For a complete list of all public module imports from the `icons` package, click [here](../../docs/Public%20Module%20Imports.md#icons):
35+
36+
## Resources
37+
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/master/README.md)
38+
- [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
39+
- [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
40+
41+
## Support
42+
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
43+
44+
## Contribute
45+
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/master/CONTRIBUTING.md).
46+
47+
## License
48+
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
49+
This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/master/LICENSE.txt) file.

packages/icons-tnt/package-scripts.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const getScripts = require("@ui5/webcomponents-tools/icons-collection/nps.js");
2+
3+
const options = {
4+
collectionName: "SAP-icons-TNT",
5+
};
6+
7+
const scripts = getScripts(options);
8+
9+
// no i18n in this package
10+
scripts.build.i18n = "";
11+
12+
module.exports = {
13+
scripts
14+
};

packages/icons-tnt/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@ui5/webcomponents-icons-tnt",
3+
"version": "1.0.0-rc.9",
4+
"description": "UI5 Web Components: SAP Fiori Tools icon set",
5+
"author": "SAP SE (https://www.sap.com)",
6+
"license": "Apache-2.0",
7+
"private": false,
8+
"keywords": [
9+
"openui5",
10+
"sapui5",
11+
"ui5"
12+
],
13+
"scripts": {
14+
"clean": "wc-dev clean",
15+
"build": "wc-dev build",
16+
"prepublishOnly": "npm run clean && npm run build"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "https://github.com/SAP/ui5-webcomponents.git",
21+
"directory": "packages/icons-tnt"
22+
},
23+
"dependencies": {
24+
"@ui5/webcomponents-base": "0.24.0"
25+
},
26+
"devDependencies": {
27+
"@ui5/webcomponents-tools": "1.0.0-rc.9",
28+
"chromedriver": "latest"
29+
}
30+
}

packages/icons-tnt/src/Assets.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./json-imports/Icons.js";

0 commit comments

Comments
 (0)