Skip to content

Commit

Permalink
feat(dialog): add quick property to skip animations
Browse files Browse the repository at this point in the history
  • Loading branch information
vdegenne committed Feb 21, 2024
1 parent 3e934e1 commit ee591b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dialog/demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<KnobTypesToKnobs<StoryKnobs>>(
'Dialog',
[
new Knob("quick", {
defaultValue: false,
ui: boolInput(),
}),
new Knob('icon', {defaultValue: '', ui: textInput()}),
new Knob('headline', {defaultValue: 'Dialog', ui: textInput()}),
new Knob('supportingText', {
Expand Down
1 change: 1 addition & 0 deletions dialog/demo/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions dialog/internal/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ee591b3

Please sign in to comment.