11import { css , customElement , FASTElement , html , observable , repeat , when } from "@microsoft/fast-element" ;
2+ import { twoWay } from "@microsoft/fast-element/binding/two-way.js" ;
23import { DesignToken , staticallyCompose } from "@microsoft/fast-foundation" ;
34import { StyleProperty , StylePropertyShorthand , Styles } from "@adaptive-web/adaptive-ui" ;
45import { neutralStrokeReadableRest } from "@adaptive-web/adaptive-ui/reference" ;
56import type { AdaptiveDesignTokenOrGroup , PluginUINodeData } from "@adaptive-web/adaptive-ui-designer-core" ;
67import { StatesState } from "@adaptive-web/adaptive-ui-designer-core" ;
7- import type { PluginMessage } from "../core/messages.js" ;
8+ import type { PluginMessage , SkipInvisibleNodesMessage } from "../core/messages.js" ;
89import SubtractIcon from "./assets/subtract.svg" ;
910import { UIController } from "./ui-controller.js" ;
1011import { AppliedDesignTokenItem , StyleModuleDisplay , StyleModuleDisplayList } from "./ui-controller-styles.js" ;
@@ -195,7 +196,7 @@ const footerTemplate = html<App>`
195196 <adaptive-button
196197 appearance="stealth"
197198 aria-label=${ genStylesLabel }
198- style="display: ${ ( x ) => ( x . controller . code . supportsCodeGen ? "block" : "none" ) } ;"
199+ style="display: ${ /* HACK: Not using this currently (x) => (x.controller.code.supportsCodeGen ? "block" : */ "none" /*)*/ } ;"
199200 @click=${ ( x ) => {
200201 const val = x . controller . code . generateForSelectedNodes ( ) ;
201202 clipboardCopy ( val ) ;
@@ -218,6 +219,7 @@ const template = html<App>`
218219 <adaptive-tabs activeid="styling">
219220 <adaptive-tab id="styling">Styling</adaptive-tab>
220221 <adaptive-tab id="tokens">Design Tokens</adaptive-tab>
222+ <adaptive-tab id="settings">Settings</adaptive-tab>
221223 <adaptive-tab-panel id="stylingPanel">
222224 <div style="overflow-y: overlay;">
223225 ${ when (
@@ -435,6 +437,12 @@ const template = html<App>`
435437 ) }
436438 ${ when ( ( x ) => ! x . supportsDesignSystem , html ` <div> Selected layers don't support design tokens</div> ` ) }
437439 </adaptive-tab-panel>
440+ <adaptive-tab-panel id="settingsPanel">
441+ <div class="settings-layout">
442+ <adaptive-switch :checked="${ twoWay ( ( x ) => x . controller . autoRefreshEnabled ) } ">Auto refresh</adaptive-switch>
443+ <adaptive-switch :checked="${ twoWay ( ( x ) => x . skipInvisibleNodes ) } ">Skip invisible nodes (composition mode)</adaptive-switch>
444+ </div>
445+ </adaptive-tab-panel>
438446 </adaptive-tabs>
439447 ${ ( x ) => footerTemplate }
440448` ;
@@ -513,6 +521,13 @@ const styles = css`
513521 height: 100%;
514522 }
515523
524+ .settings-layout {
525+ display: flex;
526+ flex-direction: column;
527+ gap: 16px;
528+ padding: 16px;
529+ }
530+
516531 footer {
517532 display: grid;
518533 grid-template-columns: 1fr auto;
@@ -637,31 +652,43 @@ export class App extends FASTElement {
637652 }
638653 }
639654
655+ @observable
656+ public skipInvisibleNodes : boolean = false ;
657+ protected skipInvisibleNodesChanged ( prev : boolean , next : boolean ) {
658+ const message : SkipInvisibleNodesMessage = {
659+ type : "SKIP_INVISIBLE_NODES" ,
660+ value : next
661+ } ;
662+ this . dispatchMessage ( message ) ;
663+ }
664+
640665 constructor ( ) {
641666 super ( ) ;
642667
643668 this . controller = new UIController ( ( message ) => this . dispatchMessage ( message ) ) ;
644669 }
645670
646671 private refreshObservables ( ) {
647- this . backgroundTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . backgroundFill ] ) ;
648- this . foregroundTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . foregroundFill ] ) ;
649- this . borderFillTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . borderFill ) ;
650- this . borderThicknessTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . borderThickness ) ;
651- this . densityTokens = this . controller . styles . getAppliedDesignTokens ( [ ...StylePropertyShorthand . padding , StyleProperty . gap ] ) ;
652- this . cornerRadiusTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . cornerRadius ) ;
653- this . textTokens = this . controller . styles . getAppliedDesignTokens ( [
654- StyleProperty . fontFamily ,
655- StyleProperty . fontStyle ,
656- StyleProperty . fontWeight ,
657- StyleProperty . fontSize ,
658- StyleProperty . lineHeight
659- ] ) ;
660- this . shadowTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . shadow ] ) ;
661-
662- this . appliedStyleModules = this . controller . styles . getAppliedStyleModules ( ) ;
663-
664- this . statesState = this . controller . states . getState ( ) ;
672+ if ( this . controller ) {
673+ this . backgroundTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . backgroundFill ] ) ;
674+ this . foregroundTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . foregroundFill ] ) ;
675+ this . borderFillTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . borderFill ) ;
676+ this . borderThicknessTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . borderThickness ) ;
677+ this . densityTokens = this . controller . styles . getAppliedDesignTokens ( [ ...StylePropertyShorthand . padding , StyleProperty . gap ] ) ;
678+ this . cornerRadiusTokens = this . controller . styles . getAppliedDesignTokens ( StylePropertyShorthand . cornerRadius ) ;
679+ this . textTokens = this . controller . styles . getAppliedDesignTokens ( [
680+ StyleProperty . fontFamily ,
681+ StyleProperty . fontStyle ,
682+ StyleProperty . fontWeight ,
683+ StyleProperty . fontSize ,
684+ StyleProperty . lineHeight
685+ ] ) ;
686+ this . shadowTokens = this . controller . styles . getAppliedDesignTokens ( [ StyleProperty . shadow ] ) ;
687+
688+ this . appliedStyleModules = this . controller . styles . getAppliedStyleModules ( ) ;
689+
690+ this . statesState = this . controller . states . getState ( ) ;
691+ }
665692 }
666693
667694 private dispatchMessage ( message : PluginMessage ) : void {
0 commit comments