Skip to content

Commit 0c12c7b

Browse files
author
Dane Pilcher
authored
fix: convert built-in iconset names to pascal case (#253)
1 parent 7f83530 commit 0c12c7b

File tree

17 files changed

+34313
-111
lines changed

17 files changed

+34313
-111
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ There are 3 keys steps, first you need to create a new tagged release version of
8989
### Icons
9090

9191
The built-in iconset is genereted with `packages/scripts/generateBuiltInIconset.js`.
92-
When icons are added or removed from `@aws-amplify/ui-react` run the script to update the icons supported in codegen.
92+
When icons are added or removed from `@aws-amplify/ui-react` run `npm run iconset` from the root of the repo to update the icons supported in codegen.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"integ:templates": "./scripts/integ-templates.sh",
2525
"integ:templates:watch": "nodemon --watch packages/test-generator/integration-test-templates/ --watch packages/test-generator/lib -e tsx,ts,js,json --exec 'npm run integ:templates'",
2626
"integ:test": "./scripts/integ-test.sh",
27-
"integ:clean": "npx rimraf packages/integration-test"
27+
"integ:clean": "npx rimraf packages/integration-test",
28+
"iconset": "lerna run iconset"
2829
},
2930
"files": [],
3031
"devDependencies": {

packages/codegen-ui-react/lib/__tests__/__snapshots__/studio-ui-codegen-react.test.ts.snap

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,24 +2372,32 @@ exports[`amplify render tests primitives Built-in Iconset 1`] = `
23722372
"/* eslint-disable */
23732373
import React from \\"react\\";
23742374
import { getOverrideProps } from \\"@aws-amplify/ui-react/internal\\";
2375-
import { EscapeHatchProps, IconCloud, IconProps } from \\"@aws-amplify/ui-react\\";
2375+
import {
2376+
EscapeHatchProps,
2377+
IconBrightness_1,
2378+
IconCloud,
2379+
View,
2380+
ViewProps,
2381+
} from \\"@aws-amplify/ui-react\\";
23762382
2377-
export type MyIconCloudProps = React.PropsWithChildren<
2378-
Partial<IconProps> & {
2383+
export type MyIconsProps = React.PropsWithChildren<
2384+
Partial<ViewProps> & {
23792385
overrides?: EscapeHatchProps | undefined | null;
23802386
}
23812387
>;
2382-
export default function MyIconCloud(
2383-
props: MyIconCloudProps
2384-
): React.ReactElement {
2388+
export default function MyIcons(props: MyIconsProps): React.ReactElement {
23852389
const { overrides: overridesProp, ...rest } = props;
23862390
const overrides = { ...overridesProp };
23872391
return (
23882392
/* @ts-ignore: TS2322 */
2389-
<IconCloud
2390-
{...rest}
2391-
{...getOverrideProps(overrides, \\"IconCloud\\")}
2392-
></IconCloud>
2393+
<View {...rest} {...getOverrideProps(overrides, \\"View\\")}>
2394+
<IconCloud
2395+
{...getOverrideProps(overrides, \\"View.IconCloud[-1]\\")}
2396+
></IconCloud>
2397+
<IconBrightness_1
2398+
{...getOverrideProps(overrides, \\"View.IconBrightness_1[-1]\\")}
2399+
></IconBrightness_1>
2400+
</View>
23932401
);
23942402
}
23952403
"
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
2-
"componentType": "IconCloud",
3-
"name": "MyIconCloud",
4-
"properties": {}
2+
"componentType": "View",
3+
"name": "MyIcons",
4+
"properties": {},
5+
"children": [{
6+
"componentType": "IconCloud",
7+
"properties": {}
8+
}, {
9+
"componentType": "IconBrightness1",
10+
"properties": {}
11+
}]
512
}

packages/codegen-ui-react/lib/amplify-ui-renderers/amplify-renderer.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
TextProps,
5555
} from '@aws-amplify/ui-react';
5656
import Primitive, { isBuiltInIcon } from '../primitive';
57+
import { iconsetPascalNameMapping } from '../iconset';
5758
import { ReactStudioTemplateRenderer } from '../react-studio-template-renderer';
5859
import CustomComponentRenderer from './customComponent';
5960
import CollectionRenderer from './collection';
@@ -69,9 +70,14 @@ export class AmplifyRenderer extends ReactStudioTemplateRenderer {
6970
const renderChildren = (children: StudioComponentChild[]) => children.map((child) => this.renderJsx(child, node));
7071

7172
if (isBuiltInIcon(component.componentType)) {
72-
return new ReactComponentWithChildrenRenderer<IconProps>(component, this.importCollection, parent).renderElement(
73-
renderChildren,
74-
);
73+
return new ReactComponentWithChildrenRenderer<IconProps>(
74+
{
75+
...component,
76+
componentType: iconsetPascalNameMapping.get(component.componentType) || component.componentType,
77+
},
78+
this.importCollection,
79+
parent,
80+
).renderElement(renderChildren);
7581
}
7682

7783
// add Primitive in alphabetical order

packages/codegen-ui-react/lib/iconset.ts

Lines changed: 93 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ export default new Set([
166166
'IconBrightnessHigh',
167167
'IconBrightnessLow',
168168
'IconBrightnessMedium',
169-
'IconBrightness_1',
170-
'IconBrightness_2',
171-
'IconBrightness_3',
172-
'IconBrightness_4',
173-
'IconBrightness_5',
174-
'IconBrightness_6',
175-
'IconBrightness_7',
169+
'IconBrightness1',
170+
'IconBrightness2',
171+
'IconBrightness3',
172+
'IconBrightness4',
173+
'IconBrightness5',
174+
'IconBrightness6',
175+
'IconBrightness7',
176176
'IconBrokenImage',
177177
'IconBrowserNotSupported',
178178
'IconBrush',
@@ -292,10 +292,10 @@ export default new Set([
292292
'IconCropPortrait',
293293
'IconCropRotate',
294294
'IconCropSquare',
295-
'IconCrop_16_9',
296-
'IconCrop_3_2',
297-
'IconCrop_5_4',
298-
'IconCrop_7_5',
295+
'IconCrop169',
296+
'IconCrop32',
297+
'IconCrop54',
298+
'IconCrop75',
299299
'IconDashboard',
300300
'IconDataUsage',
301301
'IconDateRange',
@@ -407,10 +407,10 @@ export default new Set([
407407
'IconExplore',
408408
'IconExploreOff',
409409
'IconExposure',
410-
'IconExposureNeg_1',
411-
'IconExposureNeg_2',
412-
'IconExposurePlus_1',
413-
'IconExposurePlus_2',
410+
'IconExposureNeg1',
411+
'IconExposureNeg2',
412+
'IconExposurePlus1',
413+
'IconExposurePlus2',
414414
'IconExposureZero',
415415
'IconExtension',
416416
'IconFace',
@@ -444,16 +444,16 @@ export default new Set([
444444
'IconFilterNone',
445445
'IconFilterTiltShift',
446446
'IconFilterVintage',
447-
'IconFilter_1',
448-
'IconFilter_2',
449-
'IconFilter_3',
450-
'IconFilter_4',
451-
'IconFilter_5',
452-
'IconFilter_6',
453-
'IconFilter_7',
454-
'IconFilter_8',
455-
'IconFilter_9',
456-
'IconFilter_9Plus',
447+
'IconFilter1',
448+
'IconFilter2',
449+
'IconFilter3',
450+
'IconFilter4',
451+
'IconFilter5',
452+
'IconFilter6',
453+
'IconFilter7',
454+
'IconFilter8',
455+
'IconFilter9',
456+
'IconFilter9Plus',
457457
'IconFindInPage',
458458
'IconFindReplace',
459459
'IconFingerprint',
@@ -507,9 +507,9 @@ export default new Set([
507507
'IconForum',
508508
'IconForward',
509509
'IconForwardToInbox',
510-
'IconForward_10',
511-
'IconForward_30',
512-
'IconForward_5',
510+
'IconForward10',
511+
'IconForward30',
512+
'IconForward5',
513513
'IconFoundation',
514514
'IconFreeBreakfast',
515515
'IconFullscreen',
@@ -691,10 +691,10 @@ export default new Set([
691691
'IconLooks',
692692
'IconLooksOne',
693693
'IconLooksTwo',
694-
'IconLooks_3',
695-
'IconLooks_4',
696-
'IconLooks_5',
697-
'IconLooks_6',
694+
'IconLooks3',
695+
'IconLooks4',
696+
'IconLooks5',
697+
'IconLooks6',
698698
'IconLoop',
699699
'IconLoupe',
700700
'IconLowPriority',
@@ -854,13 +854,13 @@ export default new Set([
854854
'IconPermScanWifi',
855855
'IconPerson',
856856
'IconPersonAdd',
857-
'IconPersonAddAlt_1',
857+
'IconPersonAddAlt1',
858858
'IconPersonAddDisabled',
859859
'IconPersonOutline',
860860
'IconPersonPin',
861861
'IconPersonPinCircle',
862862
'IconPersonRemove',
863-
'IconPersonRemoveAlt_1',
863+
'IconPersonRemoveAlt1',
864864
'IconPersonSearch',
865865
'IconPersonalVideo',
866866
'IconPestControl',
@@ -966,9 +966,9 @@ export default new Set([
966966
'IconRepeat',
967967
'IconRepeatOne',
968968
'IconReplay',
969-
'IconReplay_10',
970-
'IconReplay_30',
971-
'IconReplay_5',
969+
'IconReplay10',
970+
'IconReplay30',
971+
'IconReplay5',
972972
'IconReply',
973973
'IconReplyAll',
974974
'IconReport',
@@ -989,7 +989,7 @@ export default new Set([
989989
'IconRoomService',
990990
'IconRotateLeft',
991991
'IconRotateRight',
992-
'IconRotate_90DegreesCcw',
992+
'IconRotate90DegreesCcw',
993993
'IconRoundedCorner',
994994
'IconRouter',
995995
'IconRowing',
@@ -1061,14 +1061,14 @@ export default new Set([
10611061
'IconShutterSpeed',
10621062
'IconSick',
10631063
'IconSignalCellularAlt',
1064-
'IconSignalCellularConnectedNoInternet_4Bar',
1064+
'IconSignalCellularConnectedNoInternet4Bar',
10651065
'IconSignalCellularNoSim',
10661066
'IconSignalCellularNull',
10671067
'IconSignalCellularOff',
1068-
'IconSignalCellular_4Bar',
1068+
'IconSignalCellular4Bar',
10691069
'IconSignalWifiOff',
1070-
'IconSignalWifi_4Bar',
1071-
'IconSignalWifi_4BarLock',
1070+
'IconSignalWifi4Bar',
1071+
'IconSignalWifi4BarLock',
10721072
'IconSimCard',
10731073
'IconSingleBed',
10741074
'IconSkipNext',
@@ -1131,7 +1131,7 @@ export default new Set([
11311131
'IconStayCurrentPortrait',
11321132
'IconStayPrimaryLandscape',
11331133
'IconStayPrimaryPortrait',
1134-
'IconStickyNote_2',
1134+
'IconStickyNote2',
11351135
'IconStop',
11361136
'IconStopCircle',
11371137
'IconStopScreenShare',
@@ -1208,8 +1208,8 @@ export default new Set([
12081208
'IconTimeline',
12091209
'IconTimer',
12101210
'IconTimerOff',
1211-
'IconTimer_10',
1212-
'IconTimer_3',
1211+
'IconTimer10',
1212+
'IconTimer3',
12131213
'IconTitle',
12141214
'IconToc',
12151215
'IconToday',
@@ -1331,3 +1331,51 @@ export default new Set([
13311331
'IconZoomOut',
13321332
'IconZoomOutMap',
13331333
]);
1334+
1335+
export const iconsetPascalNameMapping = new Map([
1336+
['IconBrightness1', 'IconBrightness_1'],
1337+
['IconBrightness2', 'IconBrightness_2'],
1338+
['IconBrightness3', 'IconBrightness_3'],
1339+
['IconBrightness4', 'IconBrightness_4'],
1340+
['IconBrightness5', 'IconBrightness_5'],
1341+
['IconBrightness6', 'IconBrightness_6'],
1342+
['IconBrightness7', 'IconBrightness_7'],
1343+
['IconCrop169', 'IconCrop_16_9'],
1344+
['IconCrop32', 'IconCrop_3_2'],
1345+
['IconCrop54', 'IconCrop_5_4'],
1346+
['IconCrop75', 'IconCrop_7_5'],
1347+
['IconExposureNeg1', 'IconExposureNeg_1'],
1348+
['IconExposureNeg2', 'IconExposureNeg_2'],
1349+
['IconExposurePlus1', 'IconExposurePlus_1'],
1350+
['IconExposurePlus2', 'IconExposurePlus_2'],
1351+
['IconFilter1', 'IconFilter_1'],
1352+
['IconFilter2', 'IconFilter_2'],
1353+
['IconFilter3', 'IconFilter_3'],
1354+
['IconFilter4', 'IconFilter_4'],
1355+
['IconFilter5', 'IconFilter_5'],
1356+
['IconFilter6', 'IconFilter_6'],
1357+
['IconFilter7', 'IconFilter_7'],
1358+
['IconFilter8', 'IconFilter_8'],
1359+
['IconFilter9', 'IconFilter_9'],
1360+
['IconFilter9Plus', 'IconFilter_9Plus'],
1361+
['IconForward10', 'IconForward_10'],
1362+
['IconForward30', 'IconForward_30'],
1363+
['IconForward5', 'IconForward_5'],
1364+
['IconLooks3', 'IconLooks_3'],
1365+
['IconLooks4', 'IconLooks_4'],
1366+
['IconLooks5', 'IconLooks_5'],
1367+
['IconLooks6', 'IconLooks_6'],
1368+
['IconPersonAddAlt1', 'IconPersonAddAlt_1'],
1369+
['IconPersonRemoveAlt1', 'IconPersonRemoveAlt_1'],
1370+
['IconReplay10', 'IconReplay_10'],
1371+
['IconReplay30', 'IconReplay_30'],
1372+
['IconReplay5', 'IconReplay_5'],
1373+
['IconRotate90DegreesCcw', 'IconRotate_90DegreesCcw'],
1374+
['IconSignalCellularConnectedNoInternet4Bar', 'IconSignalCellularConnectedNoInternet_4Bar'],
1375+
['IconSignalCellular4Bar', 'IconSignalCellular_4Bar'],
1376+
['IconSignalWifi4Bar', 'IconSignalWifi_4Bar'],
1377+
['IconSignalWifi4BarLock', 'IconSignalWifi_4BarLock'],
1378+
['IconStickyNote2', 'IconStickyNote_2'],
1379+
['IconTimer10', 'IconTimer_10'],
1380+
['IconTimer3', 'IconTimer_3'],
1381+
]);

0 commit comments

Comments
 (0)