Skip to content

Commit c9f4cf7

Browse files
bryanforbesagubler
authored andcommitted
Themable Dialog animations (#604)
* Push to progress * Push to progress
1 parent 3ea2c7b commit c9f4cf7

4 files changed

Lines changed: 52 additions & 16 deletions

File tree

src/dialog/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import commonBundle from '../common/nls/common';
1212
import Icon from '../icon/index';
1313
import * as fixedCss from './styles/dialog.m.css';
1414
import * as css from '../theme/dialog.m.css';
15-
import * as animations from '../common/styles/animations.m.css';
1615
import { GlobalEvent } from '../global-event/index';
1716
import { customElement } from '@dojo/framework/widget-core/decorators/customElement';
1817

@@ -160,8 +159,8 @@ export class DialogBase<P extends DialogProperties = DialogProperties> extends T
160159
const { underlay } = this.properties;
161160
return v('div', {
162161
classes: [ this.theme(underlay ? css.underlayVisible : null), fixedCss.underlay ],
163-
enterAnimation: animations.fadeIn,
164-
exitAnimation: animations.fadeOut,
162+
enterAnimation: this.theme(css.underlayEnter) || undefined,
163+
exitAnimation: this.theme(css.underlayExit) || undefined,
165164
key: 'underlay',
166165
onclick: this._onUnderlayClick
167166
});
@@ -172,8 +171,8 @@ export class DialogBase<P extends DialogProperties = DialogProperties> extends T
172171
aria = {},
173172
closeable = true,
174173
closeText,
175-
enterAnimation = animations.fadeIn,
176-
exitAnimation = animations.fadeOut,
174+
enterAnimation = this.theme(css.enter) || undefined,
175+
exitAnimation = this.theme(css.exit) || undefined,
177176
modal,
178177
open = false,
179178
role = 'dialog',

src/dialog/tests/unit/Dialog.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Dialog, { DialogProperties } from '../../index';
99
import Icon from '../../../icon/index';
1010
import * as css from '../../../theme/dialog.m.css';
1111
import * as fixedCss from '../../styles/dialog.m.css';
12-
import * as animations from '../../../common/styles/animations.m.css';
1312
import { Keys } from '../../../common/util';
1413
import { GlobalEvent } from '../../../global-event/index';
1514
import {
@@ -46,16 +45,16 @@ const expected = function(open = false, closeable = false, children: any[] = [])
4645
}),
4746
v('div', {
4847
classes: [ null, fixedCss.underlay ],
49-
enterAnimation: animations.fadeIn,
50-
exitAnimation: animations.fadeOut,
48+
enterAnimation: css.underlayEnter,
49+
exitAnimation: css.underlayExit,
5150
key: 'underlay',
5251
onclick: noop
5352
}),
5453
v('div', {
5554
'aria-labelledby': '',
5655
classes: css.main,
57-
enterAnimation: animations.fadeIn,
58-
exitAnimation: animations.fadeOut,
56+
enterAnimation: css.enter,
57+
exitAnimation: css.exit,
5958
key: 'main',
6059
role: 'dialog',
6160
tabIndex: -1
@@ -120,8 +119,8 @@ registerSuite('Dialog', {
120119
}),
121120
v('div', {
122121
classes: [ css.underlayVisible, fixedCss.underlay ],
123-
enterAnimation: animations.fadeIn,
124-
exitAnimation: animations.fadeOut,
122+
enterAnimation: css.underlayEnter,
123+
exitAnimation: css.underlayExit,
125124
key: 'underlay',
126125
onclick: noop
127126
}),
@@ -174,17 +173,17 @@ registerSuite('Dialog', {
174173
}),
175174
v('div', {
176175
classes: [ null, fixedCss.underlay ],
177-
enterAnimation: animations.fadeIn,
178-
exitAnimation: animations.fadeOut,
176+
enterAnimation: css.underlayEnter,
177+
exitAnimation: css.underlayExit,
179178
key: 'underlay',
180179
onclick: noop
181180
}),
182181
v('div', {
183182
role: 'dialog',
184183
'aria-labelledby': '',
185184
classes: css.main,
186-
enterAnimation: animations.fadeIn,
187-
exitAnimation: animations.fadeOut,
185+
enterAnimation: css.enter,
186+
exitAnimation: css.exit,
188187
key: 'main',
189188
tabIndex: -1
190189
}, [

src/theme/dialog.m.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,35 @@
4040
background: var(--underlay-background);
4141
z-index: var(--zindex-dialog);
4242
}
43+
44+
@keyframes fadeIn {
45+
from {
46+
opacity: 0;
47+
}
48+
to {
49+
opacity: 1;
50+
}
51+
}
52+
53+
.enter,
54+
.underlayEnter {
55+
animation-duration: var(--short-animation-duration);
56+
animation-fill-mode: both;
57+
animation-name: fadeIn;
58+
}
59+
60+
@keyframes fadeOut {
61+
from {
62+
opacity: 1;
63+
}
64+
to {
65+
opacity: 0;
66+
}
67+
}
68+
69+
.exit,
70+
.underlayExit {
71+
animation-duration: var(--short-animation-duration);
72+
animation-fill-mode: both;
73+
animation-name: fadeOut;
74+
}

src/theme/dialog.m.css.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ export const title: string;
44
export const close: string;
55
export const content: string;
66
export const underlayVisible: string;
7+
export const enter: string;
8+
export const underlayEnter: string;
9+
export const fadeIn: string;
10+
export const exit: string;
11+
export const underlayExit: string;
12+
export const fadeOut: string;

0 commit comments

Comments
 (0)