Skip to content

Commit 1fd791f

Browse files
authored
Merge pull request #50 from fortanix/mkrause/241208-update-icons
Update icons
2 parents bc5a6ac + 97fe78d commit 1fd791f

File tree

321 files changed

+593
-1166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+593
-1166
lines changed

scripts/import.ts

Lines changed: 89 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import * as fs from 'node:fs/promises';
1515
import { AsyncLocalStorage } from 'node:async_hooks';
1616

1717

18+
//
19+
// Setup
20+
//
21+
1822
type Logger = Pick<Console, 'info' | 'error' | 'log'>;
1923
type Services = { logger: Logger };
2024
const servicesStorage = new AsyncLocalStorage<Services>();
@@ -26,13 +30,28 @@ const getServices = () => {
2630

2731
type ScriptArgs = {
2832
values: {
29-
help?: undefined | boolean,
30-
silent?: undefined | boolean,
33+
'help'?: undefined | boolean,
34+
'silent'?: undefined | boolean,
35+
'dry-run'?: undefined | boolean,
3136
},
3237
positionals: Array<string>,
3338
};
3439

3540

41+
//
42+
// Common
43+
//
44+
45+
// Return a relative path to the given absolute path, relative to the current CWD
46+
const rel = (absolutePath: string): string => {
47+
return path.relative(process.cwd(), absolutePath);
48+
};
49+
50+
51+
//
52+
// Commands
53+
//
54+
3655
/*
3756
Takes CSS variables of the form `--<var-name>: <expr>;` (as exported from Figma) and converts it to Sass variables. We
3857
expect the same variable to be in the input exactly twice, the first is assumed to be the light mode variant, the
@@ -101,9 +120,9 @@ const runParseTokens = async (args: ScriptArgs) => {
101120
const runCreateIconsManifest = async (args: ScriptArgs) => {
102121
const { logger } = getServices();
103122

104-
const pathIcons = path.join(process.cwd(), './src/assets/icons');
123+
const pathIconsSource = path.join(process.cwd(), './src/assets/icons');
105124

106-
const files = await fs.readdir(pathIcons);
125+
const files = await fs.readdir(pathIconsSource);
107126
const icons = [];
108127
for (const fileName of files) {
109128
const iconName = fileName.replace(/\.svg$/, '');
@@ -117,67 +136,106 @@ const runCreateIconsManifest = async (args: ScriptArgs) => {
117136
} as const satisfies Record<string, IconDef>;
118137
`;
119138

120-
const manifestPath = path.join(pathIcons, '_icons.ts');
121-
logger.info(`Writing file: ${manifestPath}`)
139+
const manifestPath = path.join(pathIconsSource, '_icons.ts');
140+
logger.info(`Writing file: ${manifestPath}`);
122141
await fs.writeFile(manifestPath, manifest, { encoding: 'utf-8' });
123142
};
124143

125144
const runImportIcons = async (args: ScriptArgs) => {
126145
const { logger } = getServices();
127146

147+
const isDryRun = args.values['dry-run'] ?? false;
148+
128149
const kebabCase = (string: string) => string
129150
.replace(/([a-z])([A-Z])/g, "$1-$2")
130151
.replace(/[\s_]+/g, '-')
131152
.toLowerCase();
132153

133-
const remove: Array<string> = [
134-
// Remove other company/project icons
135-
'apache',
154+
const skippedIcons: Array<string> = [
155+
'apache', // Skip other company/project icons
156+
'ai-guardrails', // Same as "send"?
157+
'complete', // Same as "success"?
158+
'table-settings', // Same as "edit-params"?
136159
];
137-
const rename: Record<string, string> = {
160+
const renamedIcons: Record<string, string> = {
138161
'ki': 'fortanix-ki',
139-
'security-objects': 'security-object',
140-
'carrot-down': 'caret-down', // Typo
141-
'page-fwd': 'page-forward',
162+
'security-objects': 'security-object', // Should be singular
163+
'users': 'user', // Should be singular
164+
'apps': 'app', // Should be singular
165+
'groups': 'group', // Should be singular
166+
'workflows': 'workflow', // Should be singular
167+
'integrations': 'integration', // Should be singular
168+
'scripts': 'script', // Should be singular
169+
'plugins': 'plugin', // Should be singular
170+
'page-fwd': 'page-forward', // Do not abbreviate
142171
'user-account': 'user-profile', // "User account" is a misleading term considering our information architecture
143-
'users': 'user',
144-
// NOTE: missing `account` icon
172+
'alert-01': 'bell',
173+
'alert-02': 'warning',
174+
'assessment': 'badge-assessment', // Depicts a security badge specifically
175+
'gen-ai': 'badge-dashboard', // Does not specifically depict anything to do with GenAI
176+
'authentication': 'user-authentication', // Depicts a user specifically (as opposed to e.g. app automation)
177+
'cancel': 'status-cancelled', // Visually related
178+
'success': 'status-success', // Visually related
179+
'failed': 'status-failed', // Visually related
180+
'ellipsis': 'ellipsis-vertical',
181+
'filter': 'filter-closed', // Make consistent with `filter-open`
182+
'eye': 'eye-open', // Visually related
183+
'hide': 'eye-closed', // Visually related
184+
'infrastructure': 'compute-node',
185+
'log-out': 'logout', // Make consistent with `login`
186+
'new-tab': 'link-external',
187+
'new-query': 'conversation-new', // Note: 'query' is already used for a different concept/icon
145188
};
146189

147-
const pathIcons = path.join(process.cwd(), './src/assets/icons_new');
148-
const pathIconsOut = path.join(process.cwd(), './src/assets/icons');
190+
const pathIconsSource = path.join(process.cwd(), './src/assets/icons_source');
191+
const pathIconsTarget = path.join(process.cwd(), './src/assets/icons');
149192

150193
// Delete existing icons
151-
for (const file of await fs.readdir(pathIconsOut)) {
152-
await fs.unlink(path.join(pathIconsOut, file));
194+
logger.log(`Deleting existing icons in ${rel(pathIconsTarget)}`);
195+
if (!isDryRun) {
196+
for (const fileName of await fs.readdir(pathIconsTarget)) {
197+
await fs.unlink(path.join(pathIconsTarget, fileName));
198+
}
153199
}
154200

155-
const files = await fs.readdir(pathIcons);
201+
const files = await fs.readdir(pathIconsSource);
156202
for (const fileName of files) {
203+
if (!fileName.includes('.svg')) { continue; }
204+
157205
const fileNameKebab = kebabCase(fileName.replace(/\.svg$/, ''));
158206
const iconName = ((): string => {
159-
if (Object.hasOwn(rename, fileNameKebab) && rename[fileNameKebab]) {
160-
return rename[fileNameKebab];
207+
if (Object.hasOwn(renamedIcons, fileNameKebab) && renamedIcons[fileNameKebab]) {
208+
return renamedIcons[fileNameKebab];
161209
} else {
162210
return fileNameKebab;
163211
}
164212
})();
165213

166-
if (iconName in remove) {
214+
if (skippedIcons.includes(iconName)) {
215+
logger.log(`Skipping icon: ${iconName}`);
167216
continue;
168217
}
169218

170-
const pathSource = path.join(pathIcons, fileName);
171-
const pathTarget = path.join(pathIconsOut, `${iconName}.svg`)
172-
logger.log(`Copying '${pathSource}' to '${pathTarget}'`);
173-
await fs.copyFile(pathSource, pathTarget);
219+
const pathSource = path.join(pathIconsSource, fileName);
220+
const pathTarget = path.join(pathIconsTarget, `${iconName}.svg`)
221+
logger.log(`Copying '${rel(pathSource)}' to '${rel(pathTarget)}'`);
222+
if (!isDryRun) {
223+
await fs.copyFile(pathSource, pathTarget);
224+
}
174225
}
175226

176227
// Create `_icons.ts` manifest file
177-
await runCreateIconsManifest(args);
228+
logger.log(`Creating '_icons.ts' manifest file.`);
229+
if (!isDryRun) {
230+
await runCreateIconsManifest(args);
231+
}
178232
};
179233

180234

235+
//
236+
// Run
237+
//
238+
181239
const printUsage = () => {
182240
const { logger } = getServices();
183241

@@ -197,8 +255,9 @@ export const run = async (argsRaw: Array<string>): Promise<void> => {
197255
args: argsRaw,
198256
allowPositionals: true,
199257
options: {
200-
help: { type: 'boolean', short: 'h' },
201-
silent: { type: 'boolean' },
258+
'help': { type: 'boolean', short: 'h' },
259+
'silent': { type: 'boolean' },
260+
'dry-run': { type: 'boolean' },
202261
},
203262
});
204263

src/assets/icons/_icons.ts

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,78 @@
1-
/* Copyright (c) Fortanix, Inc.
2-
|* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
3-
|* the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */
41
type IconDef = {};
52
export const icons = {
3+
'account': {},
64
'accounts': {},
7-
'alert': {},
8-
'apps': {},
9-
'assessment': {},
5+
'activity': {},
6+
'app': {},
107
'audit-log': {},
11-
'authentication': {},
8+
'badge-assessment': {},
9+
'badge-dashboard': {},
10+
'bell': {},
1211
'calendar': {},
1312
'caret-down': {},
13+
'caret-left': {},
14+
'caret-right': {},
15+
'caret-up': {},
1416
'check': {},
1517
'cloud-accounts': {},
18+
'cloud-connection': {},
19+
'compute-node': {},
20+
'conversation-new': {},
1621
'copy': {},
1722
'cross': {},
1823
'dashboard': {},
1924
'dataverse': {},
2025
'delete': {},
26+
'demo': {},
2127
'docs': {},
28+
'documentation': {},
2229
'download': {},
2330
'edit-params': {},
2431
'edit': {},
32+
'ellipsis-vertical': {},
2533
'email': {},
26-
'eye': {},
34+
'eye-closed': {},
35+
'eye-open': {},
2736
'file': {},
28-
'file-error': {},
29-
'fortanix-ki': {},
30-
'folder': {},
37+
'filter-closed': {},
38+
'filter-open': {},
3139
'graph': {},
32-
'groups': {},
33-
'hide': {},
40+
'group': {},
41+
'help': {},
3442
'home': {},
35-
'iam': {},
3643
'info': {},
37-
'infrastructure': {},
38-
'integrations': {},
44+
'install': {},
45+
'integration': {},
3946
'key-link': {},
4047
'key': {},
41-
'no-login': {},
48+
'knowledge-base': {},
49+
'link-external': {},
50+
'login': {},
51+
'logout': {},
52+
'on-premises': {},
53+
'page-backward': {},
4254
'page-forward': {},
43-
'plugins': {},
55+
'plugin': {},
4456
'policy': {},
4557
'print': {},
58+
'projects': {},
59+
'query': {},
4660
'refresh': {},
47-
'scripts': {},
61+
'script': {},
4862
'search': {},
63+
'security-dashboard': {},
4964
'security-object': {},
65+
'send': {},
5066
'services': {},
5167
'settings': {},
5268
'solutions': {},
53-
'success': {},
69+
'status-cancelled': {},
70+
'status-failed': {},
71+
'status-success': {},
5472
'tasks': {},
73+
'user-authentication': {},
5574
'user-profile': {},
5675
'user': {},
5776
'warning': {},
58-
'workflows': {},
59-
} as const satisfies Record<string, IconDef>;
77+
'workflow': {},
78+
} as const satisfies Record<string, IconDef>;

src/assets/icons/account.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/activity.svg

Lines changed: 11 additions & 0 deletions
Loading

src/assets/icons/apache.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

src/assets/icons/badge-dashboard.svg

Lines changed: 6 additions & 0 deletions
Loading

src/assets/icons/bell.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/icons/caret-down.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)