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

WaferMap component - basic storybook implementation #834

Merged
merged 17 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
"type": "patch",
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
"comment": "Finished first iteration of the wafermap component and its storybook",
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
"packageName": "@ni/nimble-components",
"email": "denis.stavila@ni.com",
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
"dependentChangeType": "patch"
}
14 changes: 14 additions & 0 deletions packages/nimble-components/src/wafer-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ export class WaferMap extends FoundationElement {
colors: [],
values: []
};

@observable public renderReady = false;

public override connectedCallback(): void {
super.connectedCallback();
// The component has been attached to the DOM and the attributes, properties are available
// Use this for initialization/initial render

// Simulate the time required until render is complete, before displaying the wafermap
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
// User this for conditional rendering
setTimeout((): void => {
this.renderReady = true;
}, 2000);
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
}
}

const nimbleWaferMap = WaferMap.compose({
Expand Down
36 changes: 34 additions & 2 deletions packages/nimble-components/src/wafer-map/template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
import { html } from '@microsoft/fast-element';
import { html, repeat } from '@microsoft/fast-element';
import type { WaferMap } from '.';
import type { WaferMapDie } from './types';

export const template = html<WaferMap>``;
const notReadyTemplate = html<WaferMap>` <div>Loading....</div> `;
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved

const waferTemplate = html<WaferMap>`
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
<div>
<ul>
${repeat(
x => x.dies,
html`
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
<li>
${(x: WaferMapDie) => {
return `dieX: ${x.x}, dieY: ${x.y}, value: ${x.value}%`;
}}
</li>
`
)}
<ul>
<div></div>
</ul>
</ul>
</div>
`;

export const template = html<WaferMap>`
<div>
${x => {
if (x.renderReady) {
return waferTemplate;
}
return notReadyTemplate;
}}
</div>
`;
54 changes: 54 additions & 0 deletions packages/nimble-components/src/wafer-map/tests/sets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { WaferMapDie, WaferMapColorsScale } from '../types';

export const HIGHLIGHTEDVALUESETS = [
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
[0, 1, 2, 3],
[4, 5, 6, 7],
[1, 5, 7, 15],
[0, 2, 7, 10]
];

export const WAFERMAPDIESETS: WaferMapDie[][] = [
[
{ x: 0, y: 0, value: 100 },
{ x: 0, y: 1, value: 50 },
{ x: 0, y: 2, value: 12 },
{ x: 0, y: 3, value: 99 },
{ x: 1, y: 0, value: 78 },
{ x: 1, y: 1, value: 88 },
{ x: 1, y: 2, value: 68 },
{ x: 1, y: 3, value: 99 },
{ x: 2, y: 0, value: 99 },
{ x: 2, y: 1, value: 80 },
{ x: 2, y: 2, value: 99 },
{ x: 2, y: 3, value: 100 },
{ x: 3, y: 0, value: 40 },
{ x: 3, y: 1, value: 10 },
{ x: 3, y: 2, value: 15 },
{ x: 3, y: 3, value: 30 }
],
[
{ x: 0, y: 0, value: 16 },
{ x: 0, y: 1, value: 50 },
{ x: 0, y: 2, value: 13 },
{ x: 0, y: 3, value: 65 },
{ x: 1, y: 0, value: 78 },
{ x: 1, y: 1, value: 88 },
{ x: 1, y: 2, value: 99 },
{ x: 1, y: 3, value: 99 },
{ x: 2, y: 0, value: 99 },
{ x: 2, y: 1, value: 80 },
{ x: 2, y: 2, value: 99 },
{ x: 2, y: 3, value: 100 },
{ x: 3, y: 0, value: 70 },
{ x: 3, y: 1, value: 75 },
{ x: 3, y: 2, value: 70 },
{ x: 3, y: 3, value: 72 }
]
];

export const WAFERMAPCOLORSCALESETS: WaferMapColorsScale[] = [
{
colors: ['red', 'orange', 'green'],
values: [1, 50, 100]
}
];
178 changes: 178 additions & 0 deletions packages/nimble-components/src/wafer-map/tests/wafer-map.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import { html } from '@microsoft/fast-element';
import type { Meta, StoryObj } from '@storybook/html';
import { createUserSelectedThemeStory } from '../../utilities/tests/storybook';

import '../../all-components';
import type { WaferMapDie, WaferMapColorsScale } from '../types';
import {
WaferMapQuadrant,
WaferMapOrientation,
WaferMapColorsScaleMode
} from '../types';
import {
HIGHLIGHTEDVALUESETS,
WAFERMAPDIESETS,
WAFERMAPCOLORSCALESETS
} from './sets';

interface WafermapArgs {
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
quadrant: WaferMapQuadrant;
orientation: WaferMapOrientation;
maxCharacters: number;
dieLabelsHidden: boolean;
dieLabelsSuffix: string;
colorsScaleMode: WaferMapColorsScaleMode;
highlightedValues: number[];
dies: WaferMapDie[];
colorScale: WaferMapColorsScale;
}

const metadata: Meta<WafermapArgs> = {
title: 'Wafermap',
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
parameters: {
docs: {
description: {
component: 'A Wafermap description'
}
},
actions: {
handles: ['click', 'mouseover']
}
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
},
render: createUserSelectedThemeStory(html`
<nimble-wafer-map
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
id="wafermapEl"
quadrant="${x => x.quadrant}"
orientation="${x => x.orientation}"
maxCharacters="${x => x.maxCharacters}"
dieLabelsHidden="${x => x.dieLabelsHidden}"
dieLabelsSuffix="${x => x.dieLabelsSuffix}"
colorsScaleMode="${x => x.colorsScaleMode}"
:highlightedValues="${x => x.highlightedValues}"
:colorScale="${x => x.colorScale}"
:dies=${x => x.dies}
>
</nimble-wafer-map>
`),
args: {
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
dies: WAFERMAPDIESETS[0],
quadrant: WaferMapQuadrant.bottomLeft,
orientation: WaferMapOrientation.left,
colorScale: WAFERMAPCOLORSCALESETS[0],
maxCharacters: 4,
dieLabelsHidden: false,
dieLabelsSuffix: '',
colorsScaleMode: WaferMapColorsScaleMode.linear,
highlightedValues: HIGHLIGHTEDVALUESETS[0]
},
argTypes: {
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
dies: {
description:
'Represents the input data, an array of WaferMapDie, which will be renedered by the Wafermap',
options: ['set1', 'set2'],
control: {
type: 'select',
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
labels: {
set1: 'Dies Set 1',
set2: 'Dies Set 2'
}
},
mapping: {
set1: WAFERMAPDIESETS[0],
set2: WAFERMAPDIESETS[1]
}
},
quadrant: {
description:
'Represents the orientation of the dies on the wafer map',
options: Object.values(WaferMapQuadrant),
control: {
type: 'select',
labels: {
[WaferMapQuadrant.bottomLeft]: 'BottomLeft',
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
[WaferMapQuadrant.bottomRight]: 'BottomRight',
[WaferMapQuadrant.topLeft]: 'TopLeft',
[WaferMapQuadrant.topRight]: 'TopRight'
}
}
},
orientation: {
description: 'Notch orientation',
options: Object.values(WaferMapOrientation),
control: {
type: 'select',
labels: {
[WaferMapOrientation.left]: 'Left',
[WaferMapOrientation.top]: 'Top',
[WaferMapOrientation.right]: 'Right',
[WaferMapOrientation.bottom]: 'Bottom'
}
}
},
maxCharacters: {
description:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a name: configuration that uses the attribute name for these args, ie name: 'max-characters'. Similar to the above it allows it to map more closely to the HTML representation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied

Copy link
Member

@rajsite rajsite Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DStavilaNI I think there was a misunderstanding. The goal is so the names in the story align with the names in the user html example:
image

Currently the html that is rendered is also incorrect:

image

I'd expect the attribute names in storybook to look like max-characters as my comment described and not maxcharacters as your change shows. For such a big deviation from comments it may be worth asking for a clarification.

The expected HTML is:

<nimble-wafer-map
    colors-scale-mode="linear"
    die-labels-hidden
    max-characters="4"
    orientation="left"
    quadrant="bottom-left"
></nimble-wafer-map>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of revertting the changes in the PR I created the following issue: #836

Those changes need to be addressed for others to build on the storybook changes.

'Represents the number of characters allowed to be displayed within a single die. As the die values are represented by Floating point numbers, we must have the liberty of limiting how many characters we are willing to display within a single die.',
control: { type: 'number' }
},
dieLabelsHidden: {
description:
'Boolean value that determines if the dies labels in the wafer map view are shown or not. Default value is false.',
control: { type: 'boolean' }
},
dieLabelsSuffix: {
description:
'String that can be added as a label at the end of each wafer map die value',
control: { type: 'string' }
},
colorsScaleMode: {
description:
'Enum value that determines if the colorScale represents continuous gradient values (linear), or is set categorically (ordinal).',
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
options: Object.values(WaferMapColorsScaleMode),
control: {
type: 'select',
labels: {
[WaferMapColorsScaleMode.linear]: 'Linear',
[WaferMapColorsScaleMode.ordinal]: 'Ordinal'
}
}
},
highlightedValues: {
description:
'Represents an array of die indexes that will be highlighted in the wafer map view',
options: ['set1', 'set2', 'set3', 'set4'],
control: {
type: 'select',
labels: {
set1: 'Highlighted Values Set 1',
set2: 'Highlighted Values Set 2',
set3: 'Highlighted Values Set 3',
set4: 'Highlighted Values Set 4'
}
},
mapping: {
set1: HIGHLIGHTEDVALUESETS[0],
set2: HIGHLIGHTEDVALUESETS[1],
set3: HIGHLIGHTEDVALUESETS[2],
set4: HIGHLIGHTEDVALUESETS[3]
}
},
colorScale: {
description:
'Represents the color spectrum which shows the status of the dies on the wafer.',
options: ['set1'],
control: {
type: 'select',
labels: {
set1: 'Color Scale 1'
}
},
mapping: {
set1: WAFERMAPCOLORSCALESETS[0]
}
}
}
};

export default metadata;

export const waferMap: StoryObj<WafermapArgs> = {};
33 changes: 33 additions & 0 deletions packages/nimble-components/src/wafer-map/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@ export const WaferMapQuadrant = {
topRight: 'top-right'
} as const;

export const HighlightedValuesSets = [
DStavilaNI marked this conversation as resolved.
Show resolved Hide resolved
[0, 1, 2, 3],
[4, 5, 6, 7],
[1, 5, 7, 15],
[0, 2, 7, 10]
];

export const WafermapDiesSet: WaferMapDie[] = [
{ x: 0, y: 0, value: 100 },
{ x: 0, y: 1, value: 50 },
{ x: 0, y: 2, value: 12 },
{ x: 0, y: 3, value: 99 },
{ x: 1, y: 0, value: 78 },
{ x: 1, y: 1, value: 88 },
{ x: 1, y: 2, value: 68 },
{ x: 1, y: 3, value: 99 },
{ x: 2, y: 0, value: 99 },
{ x: 2, y: 1, value: 80 },
{ x: 2, y: 2, value: 99 },
{ x: 2, y: 3, value: 100 },
{ x: 3, y: 0, value: 40 },
{ x: 3, y: 1, value: 10 },
{ x: 3, y: 2, value: 15 },
{ x: 3, y: 3, value: 30 }
];

export const WaferMapColorsScaleSets: WaferMapColorsScale[] = [
{
colors: ['red', 'orange', 'green'],
values: [1, 50, 100]
}
];

export type WaferMapQuadrant =
typeof WaferMapQuadrant[keyof typeof WaferMapQuadrant];

Expand Down