From ee591b3f1b9656b6e33d664a26cf348cb008acd7 Mon Sep 17 00:00:00 2001 From: vdegenne Date: Wed, 21 Feb 2024 11:33:45 +0100 Subject: [PATCH] feat(dialog): add `quick` property to skip animations --- dialog/demo/demo.ts | 6 +++++- dialog/demo/stories.ts | 1 + dialog/internal/dialog.ts | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dialog/demo/demo.ts b/dialog/demo/demo.ts index 4b82893e59..3cd7f7bf9f 100644 --- a/dialog/demo/demo.ts +++ b/dialog/demo/demo.ts @@ -13,13 +13,17 @@ import { materialInitsToStoryInits, setUpDemo, } from './material-collection.js'; -import {Knob, textInput} from './index.js'; +import {boolInput, Knob, textInput} from './index.js'; import {stories, StoryKnobs} from './stories.js'; const collection = new MaterialCollection>( 'Dialog', [ + new Knob("quick", { + defaultValue: false, + ui: boolInput(), + }), new Knob('icon', {defaultValue: '', ui: textInput()}), new Knob('headline', {defaultValue: 'Dialog', ui: textInput()}), new Knob('supportingText', { diff --git a/dialog/demo/stories.ts b/dialog/demo/stories.ts index e63038f586..04a8702a31 100644 --- a/dialog/demo/stories.ts +++ b/dialog/demo/stories.ts @@ -19,6 +19,7 @@ import {css, html, nothing} from 'lit'; /** Knob types for dialog stories. */ export interface StoryKnobs { + quick: boolean; icon: string; headline: string; supportingText: string; diff --git a/dialog/internal/dialog.ts b/dialog/internal/dialog.ts index ce16476e87..b4b763df52 100644 --- a/dialog/internal/dialog.ts +++ b/dialog/internal/dialog.ts @@ -59,6 +59,11 @@ export class Dialog extends LitElement { } } + /** + * Skips the opening and closing animations. + */ + @property({type: Boolean}) quick = false; + /** * Gets or sets the dialog's return value, usually to indicate which button * a user pressed to close it. @@ -396,6 +401,10 @@ export class Dialog extends LitElement { } private async animateDialog(animation: DialogAnimation) { + if (this.quick) { + return; + } + const {dialog, scrim, container, headline, content, actions} = this; if (!dialog || !scrim || !container || !headline || !content || !actions) { return;