-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into gaugup/AddValidationHetrogenityTests
- Loading branch information
Showing
13 changed files
with
677 additions
and
92 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
apps/dashboard/src/interpret-vision/__mock_data__/explanation.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
79 changes: 79 additions & 0 deletions
79
libs/interpret-vision/src/lib/VisionExplanationDashboard/Controls/Flyout.styles.ts
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,79 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { | ||
IStyle, | ||
mergeStyleSets, | ||
IProcessedStyleSet, | ||
getTheme | ||
} from "@fluentui/react"; | ||
|
||
export interface IFlyoutStyles { | ||
cell: IStyle; | ||
errorIcon: IStyle; | ||
explanation: IStyle; | ||
featureListContainer: IStyle; | ||
iconContainer: IStyle; | ||
image: IStyle; | ||
imageContainer: IStyle; | ||
label: IStyle; | ||
mainContainer: IStyle; | ||
separator: IStyle; | ||
successIcon: IStyle; | ||
title: IStyle; | ||
} | ||
|
||
export const flyoutStyles: () => IProcessedStyleSet<IFlyoutStyles> = () => { | ||
const theme = getTheme(); | ||
return mergeStyleSets<IFlyoutStyles>({ | ||
cell: { | ||
marginBottom: "20px" | ||
}, | ||
errorIcon: { | ||
color: theme.semanticColors.errorIcon, | ||
fontSize: "large", | ||
fontWeight: "600" | ||
}, | ||
explanation: { | ||
position: "relative", | ||
right: 85 | ||
}, | ||
featureListContainer: { | ||
height: 300, | ||
overflow: "auto" | ||
}, | ||
iconContainer: { | ||
position: "relative", | ||
top: "2px" | ||
}, | ||
image: { | ||
marginBottom: "20px" | ||
}, | ||
imageContainer: { | ||
maxHeight: "250px", | ||
maxWidth: "250px" | ||
}, | ||
label: { | ||
bottom: 20, | ||
position: "relative", | ||
textAlign: "start" | ||
}, | ||
mainContainer: { | ||
height: "100%", | ||
overflow: "hidden" | ||
}, | ||
separator: { | ||
root: { | ||
width: "100&" | ||
} | ||
}, | ||
successIcon: { | ||
color: theme.semanticColors.successIcon, | ||
fontSize: "large", | ||
fontWeight: "600" | ||
}, | ||
title: { | ||
fontWeight: "600" | ||
} | ||
}); | ||
}; |
168 changes: 168 additions & 0 deletions
168
libs/interpret-vision/src/lib/VisionExplanationDashboard/Controls/Flyout.tsx
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,168 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { | ||
Icon, | ||
Image, | ||
ImageFit, | ||
List, | ||
Panel, | ||
PanelType, | ||
FocusZone, | ||
Stack, | ||
Text, | ||
Separator | ||
} from "@fluentui/react"; | ||
import { localization } from "@responsible-ai/localization"; | ||
import React from "react"; | ||
|
||
import { IDatasetSummary } from "../Interfaces/IExplanationDashboardProps"; | ||
|
||
import { flyoutStyles } from "./Flyout.styles"; | ||
import { IListItem } from "./ImageList"; | ||
|
||
export interface IFlyoutProps { | ||
data: IDatasetSummary; | ||
isOpen: boolean; | ||
item: IListItem | undefined; | ||
callback: () => void; | ||
} | ||
|
||
const stackTokens = { | ||
childrenGap: "l1" | ||
}; | ||
|
||
export class Flyout extends React.Component<IFlyoutProps> { | ||
public render(): React.ReactNode { | ||
const { data, isOpen, item, callback } = this.props; | ||
|
||
const classNames = flyoutStyles(); | ||
|
||
const list = []; | ||
|
||
for (let i = 0; i < 30; i++) { | ||
list.push({ title: "Feature 1", value: "value" }); | ||
} | ||
|
||
return ( | ||
<FocusZone> | ||
<Panel | ||
headerText={localization.InterpretVision.Dashboard.panelTitle} | ||
isOpen={isOpen} | ||
closeButtonAriaLabel="Close" | ||
onDismiss={callback} | ||
isLightDismiss | ||
type={PanelType.custom} | ||
customWidth="700px" | ||
className={classNames.mainContainer} | ||
> | ||
<Stack tokens={stackTokens}> | ||
<Stack.Item> | ||
<Separator styles={{ root: { width: "100%" } }} /> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Stack | ||
horizontal | ||
tokens={stackTokens} | ||
horizontalAlign="space-around" | ||
verticalAlign="center" | ||
> | ||
<Stack.Item> | ||
<Stack | ||
horizontal | ||
tokens={{ childrenGap: "s1" }} | ||
horizontalAlign="center" | ||
verticalAlign="center" | ||
> | ||
<Stack.Item className={classNames.iconContainer}> | ||
<Icon | ||
iconName={ | ||
item?.predictedY !== item?.trueY | ||
? "Cancel" | ||
: "Checkmark" | ||
} | ||
className={ | ||
item?.predictedY !== item?.trueY | ||
? classNames.errorIcon | ||
: classNames.successIcon | ||
} | ||
/> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Text variant="large" className={classNames.title}> | ||
{item?.predictedY !== item?.trueY | ||
? localization.InterpretVision.Dashboard.titleBarError | ||
: localization.InterpretVision.Dashboard | ||
.titleBarSuccess} | ||
</Text> | ||
</Stack.Item> | ||
</Stack> | ||
</Stack.Item> | ||
<Stack.Item className={classNames.imageContainer}> | ||
<Image | ||
src={item?.image} | ||
className={classNames.image} | ||
imageFit={ImageFit.contain} | ||
/> | ||
<Text variant="large" className={classNames.label}> | ||
{item?.title} | ||
</Text> | ||
</Stack.Item> | ||
</Stack> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Separator className={classNames.separator} /> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Text variant="large" className={classNames.title}> | ||
{localization.InterpretVision.Dashboard.panelExplanation} | ||
</Text> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Image | ||
src={`data:image/jpg;base64,${data.localExplanations[0]}`} | ||
width="800px" | ||
className={classNames.explanation} | ||
/> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Separator className={classNames.separator} /> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Text variant="large" className={classNames.title}> | ||
{localization.InterpretVision.Dashboard.panelInformation} | ||
</Text> | ||
</Stack.Item> | ||
<Stack.Item className={classNames.featureListContainer}> | ||
<List items={list} onRenderCell={this.onRenderCell} /> | ||
</Stack.Item> | ||
</Stack> | ||
</Panel> | ||
</FocusZone> | ||
); | ||
} | ||
|
||
private onRenderCell = ( | ||
item?: { title: string; value: string } | undefined | ||
) => { | ||
const classNames = flyoutStyles(); | ||
|
||
return ( | ||
<Stack.Item> | ||
<Stack | ||
horizontal | ||
tokens={{ childrenGap: "l2" }} | ||
verticalAlign="center" | ||
className={classNames.cell} | ||
> | ||
<Stack.Item> | ||
<Text variant="large">{item?.title}</Text> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Text variant="large">{item?.value}</Text> | ||
</Stack.Item> | ||
</Stack> | ||
</Stack.Item> | ||
); | ||
}; | ||
} |
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
Oops, something went wrong.