Skip to content

Commit 4ad2940

Browse files
authored
Added the sample app layout back to the Explorer (#167)
1 parent 88e9432 commit 4ad2940

File tree

21 files changed

+492
-53
lines changed

21 files changed

+492
-53
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"Appliable",
2323
"culori",
2424
"Demi",
25+
"listbox",
2526
"Lrgb",
2627
"okhsl",
2728
"tablist",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Export default component styles",
4+
"packageName": "@adaptive-web/adaptive-web-components",
5+
"email": "47367562+bheston@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/adaptive-ui-explorer/src/app.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,25 @@ import {
3030
ViewTemplate,
3131
} from "@microsoft/fast-element";
3232
import { DesignToken } from "@microsoft/fast-foundation";
33+
import { AdaptiveDesignSystem, componentBaseStyles } from "@adaptive-web/adaptive-web-components";
34+
import { AllComponents } from "@adaptive-web/adaptive-web-components/all-components";
3335
import { ComponentType } from "./component-type.js";
34-
import "./components/color-block.js";
35-
import "./components/control-pane/index.js";
36-
import "./components/layer-background/index.js";
37-
import "./components/palette-gradient/palette-gradient.js";
36+
import { ColorBlock } from "./components/color-block.js";
37+
import { ControlPane } from "./components/control-pane/index.js";
38+
import { LayerBackground } from "./components/layer-background/index.js";
39+
import { PaletteGradient } from "./components/palette-gradient/palette-gradient.js";
40+
import { SampleApp } from "./sample/index.js";
41+
42+
AdaptiveDesignSystem.defineComponents(AllComponents);
3843

3944
DesignToken.registerDefaultStyleTarget();
4045

46+
ColorBlock;
47+
ControlPane;
48+
LayerBackground;
49+
PaletteGradient;
50+
SampleApp;
51+
4152
const colorBlockTemplate = html<App>`
4253
${repeat(
4354
(x) => x.backgrounds,
@@ -54,6 +65,27 @@ const colorBlockTemplate = html<App>`
5465
)}
5566
`;
5667

68+
const sampleTemplate = html<App>`
69+
<app-design-system-provider style="display: flex;">
70+
<app-layer-background
71+
id="light-mode"
72+
base-layer-luminance="${LayerBaseLuminance.LightMode}"
73+
background-layer-recipe="-3"
74+
style="flex-grow: 1; padding: 100px;"
75+
>
76+
<app-sample-app></app-sample-app>
77+
</app-layer-background>
78+
<app-layer-background
79+
id="dark-mode"
80+
base-layer-luminance="${LayerBaseLuminance.DarkMode}"
81+
background-layer-recipe="-3"
82+
style="flex-grow: 1; padding: 100px;"
83+
>
84+
<app-sample-app></app-sample-app>
85+
</app-layer-background>
86+
</app-design-system-provider>
87+
`;
88+
5789
const template = html<App>`
5890
<div class="container fill">
5991
<div class="row fill">
@@ -79,7 +111,6 @@ const template = html<App>`
79111
id="control-pane"
80112
class="control-pane-container"
81113
base-layer-luminance="${LayerBaseLuminance.DarkMode}"
82-
background-layer-recipe="-1"
83114
>
84115
<app-control-pane
85116
:componentType="${(x) => x.componentType}"
@@ -154,6 +185,7 @@ export interface SwatchInfo {
154185

155186
@customElement({
156187
name: `app-design-system-provider`,
188+
styles: componentBaseStyles,
157189
template: html`
158190
<slot></slot>
159191
`,
@@ -249,7 +281,11 @@ export class App extends FASTElement implements AppAttributes {
249281
public designSystemElement: FASTElement;
250282

251283
public componentTypeTemplate(): ViewTemplate<App, any> {
252-
return colorBlockTemplate;
284+
if (this.componentType === ComponentType.sample) {
285+
return sampleTemplate;
286+
} else {
287+
return colorBlockTemplate;
288+
}
253289
}
254290

255291
private updateBackgrounds(): void {

packages/adaptive-ui-explorer/src/component-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export enum ComponentType {
22
backplate = "backplate",
33
text = "text",
44
form = "form",
5+
sample = "sample",
56
}

packages/adaptive-ui-explorer/src/components/color-block.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ import {
3636
when,
3737
} from "@microsoft/fast-element";
3838
import { ComponentType } from "../component-type.js";
39-
import "./adaptive-component.js";
40-
import "./style-example.js";
41-
import "./swatch.js";
39+
import { AdaptiveComponent } from "./adaptive-component.js";
40+
import { StyleExample } from "./style-example.js";
41+
import { AppSwatch } from "./swatch.js";
42+
43+
AdaptiveComponent;
44+
StyleExample;
45+
AppSwatch;
4246

4347
const backplateComponents = html<ColorBlock>`
4448
<app-style-example :disabledState=${x => x.disabledState} :styles="${x => accentFillReadableControlStyles}">

packages/adaptive-ui-explorer/src/components/control-pane/control-pane.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import type { WcagContrastLevel } from "@adaptive-web/adaptive-ui/reference";
2-
import { FASTElement, observable } from "@microsoft/fast-element";
3-
2+
import { customElement, FASTElement, observable } from "@microsoft/fast-element";
3+
import { controlPaneStyles as styles } from "./control-pane.styles.js";
4+
import { controlPaneTemplate as template } from "./control-pane.template.js";
5+
6+
@customElement({
7+
name: "app-control-pane",
8+
styles,
9+
template: template(),
10+
})
411
export class ControlPane extends FASTElement {
512
@observable
613
public componentType: string;
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
import { ControlPane } from "./control-pane.js";
2-
import { controlPaneStyles as styles } from "./control-pane.styles.js";
3-
import { controlPaneTemplate as template } from "./control-pane.template.js";
4-
5-
ControlPane.define({
6-
name: "app-control-pane",
7-
styles,
8-
template: template(),
9-
});
10-
111
export { ControlPane } from "./control-pane.js";

packages/adaptive-ui-explorer/src/components/layer-background/index.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { Swatch } from '@adaptive-web/adaptive-ui';
2-
import {
3-
neutralForegroundRest,
4-
} from "@adaptive-web/adaptive-ui/migration";
52
import {
63
fillColor,
74
layerFillBaseLuminance,
@@ -15,13 +12,35 @@ import {
1512
layerFillFixedPlus3,
1613
layerFillFixedPlus4,
1714
layerPalette,
15+
neutralStrokeStrongRest,
1816
} from "@adaptive-web/adaptive-ui/reference";
19-
import { attr, css, ElementViewTemplate, FASTElement, html, nullableNumberConverter } from "@microsoft/fast-element";
17+
import { componentBaseStyles } from '@adaptive-web/adaptive-web-components';
18+
import { attr, css, customElement, ElementViewTemplate, FASTElement, html, nullableNumberConverter } from "@microsoft/fast-element";
2019
import { DesignToken, DesignTokenChangeRecord, display } from "@microsoft/fast-foundation";
2120

21+
const layerBackgroundStyles = css`
22+
${componentBaseStyles}
23+
24+
${display("block")} :host {
25+
background: ${fillColor};
26+
color: ${neutralStrokeStrongRest};
27+
}
28+
`;
29+
30+
function layerBackgroundTemplate<T extends LayerBackground>(): ElementViewTemplate<T> {
31+
return html<T>`
32+
<slot></slot>
33+
`;
34+
}
35+
36+
@customElement({
37+
name: "app-layer-background",
38+
styles: layerBackgroundStyles,
39+
template: layerBackgroundTemplate(),
40+
})
2241
export class LayerBackground extends FASTElement {
2342
@attr({ attribute: "base-layer-luminance", converter: nullableNumberConverter })
24-
public baseLayerLuminance: number = 1;
43+
public baseLayerLuminance: number;
2544
protected baseLayerLuminanceChanged(prev: number, next: number): void {
2645
layerFillBaseLuminance.setValueFor(this, this.baseLayerLuminance);
2746
this.updateBackgroundColor();
@@ -96,22 +115,3 @@ export class LayerBackground extends FASTElement {
96115
layerPalette.unsubscribe(this);
97116
}
98117
}
99-
100-
export function layerBackgroundTemplate<T extends LayerBackground>(): ElementViewTemplate<T> {
101-
return html<T>`
102-
<slot></slot>
103-
`;
104-
}
105-
106-
export const layerBackgroundStyles = css`
107-
${display("block")} :host {
108-
background: ${fillColor};
109-
color: ${neutralForegroundRest};
110-
}
111-
`;
112-
113-
LayerBackground.define({
114-
name: "app-layer-background",
115-
styles: layerBackgroundStyles,
116-
template: layerBackgroundTemplate(),
117-
});
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
export { PaletteGradient } from "./palette-gradient.js";
2-
export { paletteGradientStyles as styles } from "./palette-gradient.styles.js";
3-
export { paletteGradientTemplate as template } from "./palette-gradient.template.js";

packages/adaptive-ui-explorer/src/components/style-example.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { InteractiveTokenGroup, StyleProperty, Styles, Swatch, TypedCSSDesignToken } from "@adaptive-web/adaptive-ui";
22
import { fillColor } from '@adaptive-web/adaptive-ui/reference';
33
import { css, customElement, FASTElement, html, observable, repeat, volatile } from "@microsoft/fast-element";
4-
import { SwatchType } from "./swatch.js";
5-
import "./adaptive-component.js";
6-
import "./swatch.js";
4+
import { AdaptiveComponent } from "./adaptive-component.js";
5+
import { AppSwatch, SwatchType } from "./swatch.js";
6+
7+
AdaptiveComponent;
8+
AppSwatch;
79

810
const template = html<StyleExample>`
911
<template>

0 commit comments

Comments
 (0)