Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subway Nav Component: Added ability to set individual nodes to any Fluent UI icon and color based on user input #350

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
56bca12
feat: Add Custom state to SubwayNavNodeState enum and ItemColumns enum
PK-Microsoft Jun 7, 2024
ba5b456
Update ControlManifest.Input.xml
PK-Microsoft Jun 7, 2024
c7b9773
Update index.ts
PK-Microsoft Jun 7, 2024
d6e6ea4
Update mock-datasets.ts
PK-Microsoft Oct 4, 2024
4de77a9
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 4, 2024
f042430
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 4, 2024
19295b9
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 4, 2024
1a93e60
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 4, 2024
13b5ecd
Update datasetmapping.test.ts
PK-Microsoft Oct 4, 2024
5e8b9af
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 4, 2024
c747530
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 4, 2024
490930a
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 4, 2024
4824b44
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 4, 2024
40bd645
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 4, 2024
9c5f2c2
Update datasetmapping.test.ts
PK-Microsoft Oct 4, 2024
fa15a25
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 4, 2024
caac120
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 4, 2024
3d7958f
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 4, 2024
90d1faf
Update datasetmapping.test.ts
PK-Microsoft Oct 4, 2024
a09809a
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 4, 2024
b2f1f06
Update CanvasSubwayNav.tsx
PK-Microsoft Oct 5, 2024
c48100f
Update CanvasSubwayNav.tsx
PK-Microsoft Oct 5, 2024
6c995bf
Update subway-node.types.ts
PK-Microsoft Oct 5, 2024
be50f16
Update subway-node.types.ts
PK-Microsoft Oct 5, 2024
883270a
Update CanvasSubwayNav.tsx
PK-Microsoft Oct 5, 2024
ddd4960
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 5, 2024
d3d1490
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 5, 2024
94b9a6c
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
178c4a1
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 5, 2024
0f47b77
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
febe164
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 5, 2024
4290db2
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 5, 2024
39634db
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 5, 2024
5670815
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
720041d
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
e1058e0
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
53c22f8
Update datasetmapping.test.ts.snap
PK-Microsoft Oct 5, 2024
9a05838
Update subwaynav-lifecycle.test.ts.snap
PK-Microsoft Oct 5, 2024
7bae286
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 5, 2024
1cf9e28
Update datasetmapping.test.ts
PK-Microsoft Oct 5, 2024
26d8663
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 5, 2024
439b2d0
Update subwaynav-lifecycle.test.ts
PK-Microsoft Oct 5, 2024
4a8d3ae
Merge pull request #10 from PK-Microsoft/MainCopy
PK-Microsoft Oct 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions SubwayNav/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ The control accepts the following properties:
- **Items** - The action items to render
- **ItemKey** - The key to use to indicate which item/step is selected. The keys must be unique.
- **ItemLabel** - Label for the step
- **ItemState** - Specifying the state of the step. Here is the list of State available. Current|NotStarted|Completed|Unsaved|ViewedNotCompleted|Error|CurrentWithSubSteps|Skipped|WizardComplete

- **ItemState** - Specifying the state of the step. Here is the list of State available. Current|NotStarted|Completed|Unsaved|ViewedNotCompleted|Error|CurrentWithSubSteps|Skipped|WizardComplete|Custom
- **ItemIcon** - Will not do anything if ItemState isn't set to Custom. If ItemState is set to Custom, you can input the string value of any FluentUI Icon and it will show up. If the ItemIcon name is invalid, blank or doesn't match any FluentUI Icon's, then it will be set to same Icon as when ItemState is equal to Current.
- **ItemColor** - Will not do anything if ItemState isn't set to Custom. If ItemState is set to Custom, you can input most hexadecimal color codes and that will change the color of the Icon. If the input to this column is invalid, it will default to black. If the input to this column is blank, it will be set to the same color as when ItemState is equal to Current.
- **SubwayNav state** - To mark the overall state of SubwayNav to Complete or Error.

### Style Properties
Expand Down Expand Up @@ -142,3 +143,17 @@ Set(varThemeBlueJSON,"{""palette"":{
```

The Theme JSON string is passed to the component property, whilst the varTheme can be used to style other standard components such as buttons using the individual colors.



### Example using Custom Item State

Example of input collection value for Items property

```PowerFx
Table({ItemKey:"1",ItemLabel:"Step 1",ItemState:"Current"},
{ItemKey:"2",ItemLabel:"Step 2",ItemState:"Custom", ItemIcon:"Admin",ItemColor: "teal"},
{ItemKey:"3",ItemLabel:"Step 3",ItemState:"Custom",ItemIcon:"AddTo",ItemColor: "#EE82EE"})
```

You can use either the names of colors or the colors hexadecimal value. However, color hexadecimal value is recommended. If the color name isn't basic, it most likely won't work.
6 changes: 4 additions & 2 deletions SubwayNav/SubwayNav/ControlManifest.Input.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<control namespace="PowerCAT" constructor="SubwayNav" version="1.0.25" display-name-key="SubwayNav" description-key="SubwayNav_Desc" control-type="virtual">
<control namespace="PowerCAT" constructor="SubwayNav" version="1.0.26" display-name-key="SubwayNav" description-key="SubwayNav_Desc" control-type="virtual">
<!-- Style Properties -->
<property name="Theme" display-name-key="Theme" of-type="Multiple" usage="input" required="false" />
<property name="AccessibilityLabel" display-name-key="AccessibilityLabel" of-type="SingleLine.Text" usage="input" required="false" />
Expand All @@ -24,6 +24,8 @@
<property-set name="ItemState" display-name-key="Item State" of-type="SingleLine.Text" usage="bound" required="true" />
<property-set name="ItemDisabled" display-name-key="Item Disabled" of-type="TwoOptions" usage="bound" required="false" />
<property-set name="ItemVisuallyDisabled" display-name-key="Item Visually Disabled" of-type="TwoOptions" usage="bound" required="false" />
<property-set name="ItemIcon" display-name-key="Item Icon" of-type="SingleLine.Text" usage="bound" required="false" />
<property-set name="ItemColor" display-name-key="Item Color" of-type="SingleLine.Text" usage="bound" required="false" />
</data-set>
<property name="Steps" display-name-key="Steps" of-type="Object" usage="output"/>
<property name="StepsSchema" display-name-key="StepsSchema" of-type="SingleLine.Text" usage="bound" hidden="true"/>
Expand All @@ -37,4 +39,4 @@
<platform-library name="Fluent" version="8.29.0" />
</resources>
</control>
</manifest>
</manifest>
2 changes: 2 additions & 0 deletions SubwayNav/SubwayNav/ManifestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const enum ItemColumns {
State = 'ItemState',
Disabled = 'ItemDisabled',
VisuallyDisabled = 'ItemVisuallyDisabled',
ItemIcon = 'ItemIcon',
ItemColor = 'ItemColor',
ParentKey = 'ParentItemKey',
}

Expand Down
4 changes: 1 addition & 3 deletions SubwayNav/SubwayNav/__mocks__/mock-datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export class MockDataSet implements ComponentFramework.PropertyTypes.DataSet {
linking: ComponentFramework.PropertyHelper.DataSetApi.Linking;
loading: boolean;
paging: ComponentFramework.PropertyHelper.DataSetApi.Paging;
records: {
[id: string]: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord;
};
records: { [id: string]: ComponentFramework.PropertyHelper.DataSetApi.EntityRecord };
sortedRecordIds: string[];
sorting: ComponentFramework.PropertyHelper.DataSetApi.SortStatus[];
clearSelectedRecordIds = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Array [
},
"disabled": undefined,
"id": "1",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 1",
"label": "item1",
"parentId": undefined,
Expand All @@ -32,6 +34,8 @@ Array [
},
"disabled": undefined,
"id": "2",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 2",
"label": "item2",
"parentId": undefined,
Expand All @@ -50,6 +54,8 @@ Array [
},
"disabled": undefined,
"id": "3",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 3",
"label": "item3",
"parentId": undefined,
Expand All @@ -68,6 +74,8 @@ Array [
},
"disabled": undefined,
"id": "4",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 4",
"label": "item4",
"parentId": undefined,
Expand All @@ -79,15 +87,17 @@ Array [
"getNamedReference": [MockFunction],
"id": "5",
"values": Object {
"ItemKey": "Item 4",
"ItemLabel": "item4",
"ItemKey": "Item 5",
"ItemLabel": "item5",
"ItemState": "Error",
},
},
"disabled": undefined,
"id": "5",
"key": "Item 4",
"label": "item4",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 5",
"label": "item5",
"parentId": undefined,
"state": "Error",
"visuallyDisabled": undefined,
Expand All @@ -97,15 +107,17 @@ Array [
"getNamedReference": [MockFunction],
"id": "6",
"values": Object {
"ItemKey": "Item 4",
"ItemLabel": "item4",
"ItemKey": "Item 6",
"ItemLabel": "item6",
"ItemState": "Skipped",
},
},
"disabled": undefined,
"id": "6",
"key": "Item 4",
"label": "item4",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 6",
"label": "item6",
"parentId": undefined,
"state": "Skipped",
"visuallyDisabled": undefined,
Expand All @@ -115,18 +127,64 @@ Array [
"getNamedReference": [MockFunction],
"id": "7",
"values": Object {
"ItemKey": "Item 4",
"ItemLabel": "item4",
"ItemKey": "Item 7",
"ItemLabel": "item7",
"ItemState": "Unsaved",
},
},
"disabled": undefined,
"id": "7",
"key": "Item 4",
"label": "item4",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 7",
"label": "item7",
"parentId": undefined,
"state": "Unsaved",
"visuallyDisabled": undefined,
},
Object {
"data": MockEntityRecord {
"getNamedReference": [MockFunction],
"id": "8",
"values": Object {
"ItemColor": "#C8A2C8",
"ItemIcon": "AddFriend",
"ItemKey": "Item 8",
"ItemLabel": "item8",
"ItemState": "Custom",
},
},
"disabled": undefined,
"id": "8",
"itemColor": "#C8A2C8",
"itemIcon": "AddFriend",
"key": "Item 8",
"label": "item8",
"parentId": undefined,
"state": "Custom",
"visuallyDisabled": undefined,
},
Object {
"data": MockEntityRecord {
"getNamedReference": [MockFunction],
"id": "9",
"values": Object {
"ItemColor": "#EE82EE",
"ItemIcon": "AddTo",
"ItemKey": "Item 9",
"ItemLabel": "item8",
"ItemState": "Custom",
},
},
"disabled": undefined,
"id": "9",
"itemColor": "#EE82EE",
"itemIcon": "AddTo",
"key": "Item 9",
"label": "item8",
"parentId": undefined,
"state": "Custom",
"visuallyDisabled": undefined,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "1",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 1",
"label": "item1",
"parentId": undefined,
Expand All @@ -38,6 +40,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "2",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 2",
"label": "item2",
"parentId": undefined,
Expand All @@ -56,6 +60,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "3",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 3",
"label": "item3",
"parentId": undefined,
Expand All @@ -74,6 +80,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "4",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 4",
"label": "item4",
"parentId": undefined,
Expand All @@ -92,6 +100,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "5",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 4",
"label": "item4",
"parentId": undefined,
Expand All @@ -110,6 +120,8 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "6",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 4",
"label": "item4",
"parentId": undefined,
Expand All @@ -128,12 +140,58 @@ exports[`SubwayNav renders 1`] = `
},
"disabled": undefined,
"id": "7",
"itemColor": undefined,
"itemIcon": undefined,
"key": "Item 4",
"label": "item4",
"parentId": undefined,
"state": "Unsaved",
"visuallyDisabled": undefined,
},
Object {
"data": MockEntityRecord {
"getNamedReference": [MockFunction],
"id": "8",
"values": Object {
"ItemColor": "#C8A2C8",
"ItemIcon": "AddFriend",
"ItemKey": "Item 8",
"ItemLabel": "item8",
"ItemState": "Custom",
},
},
"disabled": undefined,
"id": "8",
"itemColor": "#C8A2C8",
"itemIcon": "AddFriend",
"key": "Item 8",
"label": "item8",
"parentId": undefined,
"state": "Custom",
"visuallyDisabled": undefined,
},
Object {
"data": MockEntityRecord {
"getNamedReference": [MockFunction],
"id": "9",
"values": Object {
"ItemColor": "#EE82EE",
"ItemIcon": "AddTo",
"ItemKey": "Item 9",
"ItemLabel": "item8",
"ItemState": "Custom",
},
},
"disabled": undefined,
"id": "9",
"itemColor": "#EE82EE",
"itemIcon": "AddTo",
"key": "Item 9",
"label": "item8",
"parentId": undefined,
"state": "Custom",
"visuallyDisabled": undefined,
},
]
}
onSelected={[Function]}
Expand All @@ -155,27 +213,35 @@ exports[`SubwayNav renders dummy items when no items configured 1`] = `
Array [
Object {
"id": "1",
"itemColor": "",
"itemIcon": "",
"key": "1",
"label": "Node 1",
"parentId": undefined,
"state": "Current",
},
Object {
"id": "2",
"itemColor": "",
"itemIcon": "",
"key": "2",
"label": "Node 2",
"parentId": undefined,
"state": "Not Started",
},
Object {
"id": "3",
"itemColor": "",
"itemIcon": "",
"key": "3",
"label": "Node 3",
"parentId": undefined,
"state": "Not Started",
},
Object {
"id": "4",
"itemColor": "",
"itemIcon": "",
"key": "4",
"label": "Node 4",
"parentId": undefined,
Expand Down
Loading
Loading