@atlaskit/top-layer 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +4 -4
- package/dist/cjs/animations/presets.js +96 -9
- package/dist/cjs/entry-points/animations.js +12 -0
- package/dist/es2019/animations/presets.js +145 -2
- package/dist/es2019/entry-points/animations.js +1 -1
- package/dist/esm/animations/presets.js +93 -9
- package/dist/esm/entry-points/animations.js +1 -1
- package/dist/types/animations/presets.d.ts +16 -0
- package/dist/types/entry-points/animations.d.ts +1 -1
- package/dist/types-ts4.5/animations/presets.d.ts +16 -0
- package/dist/types-ts4.5/entry-points/animations.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/top-layer
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`2fd74328732bf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2fd74328732bf) -
|
|
8
|
+
Add dialogMotion animation preset with token-based motion values and backdrop animation
|
|
9
|
+
|
|
3
10
|
## 0.16.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -55,8 +55,8 @@ function MyPopup({ isOpen, onClose }: { isOpen: boolean; onClose: () => void })
|
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
- Focus restoration is automatic. The browser handles it for outermost popovers; `Popover`
|
|
59
|
-
|
|
58
|
+
- Focus restoration is automatic. The browser handles it for outermost popovers; `Popover` snapshots
|
|
59
|
+
`document.activeElement` on open and restores it on close for nested cases.
|
|
60
60
|
- For default overlay styling (background, shadow, border-radius), wrap content in `PopoverSurface`
|
|
61
61
|
from `@atlaskit/top-layer/popover-surface`.
|
|
62
62
|
- For trigger-less or custom-positioned UI (flag, tooltip, react-select menu portal), use `Popover`
|
|
@@ -88,8 +88,8 @@ Compound component for modal dialogs using the native `<dialog>` element with `.
|
|
|
88
88
|
## Animations
|
|
89
89
|
|
|
90
90
|
Both `Popover` and `Dialog` support CSS-based entry/exit animations via the `animate` prop.
|
|
91
|
-
Animations use
|
|
92
|
-
|
|
91
|
+
Animations use [`@starting-style`](https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style)
|
|
92
|
+
for entry and
|
|
93
93
|
[`allow-discrete`](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior) on
|
|
94
94
|
`display`/`overlay` for exit — no JavaScript animation coordination required.
|
|
95
95
|
|
|
@@ -4,23 +4,80 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.dialogFade = dialogFade;
|
|
7
|
+
exports.dialogMotion = dialogMotion;
|
|
7
8
|
exports.dialogSlideUpAndFade = dialogSlideUpAndFade;
|
|
8
9
|
exports.fade = fade;
|
|
10
|
+
exports.popupMotion = popupMotion;
|
|
9
11
|
exports.scaleAndFade = scaleAndFade;
|
|
10
12
|
exports.slideAndFade = slideAndFade;
|
|
11
13
|
var _resolvePlacement = require("../internal/resolve-placement");
|
|
12
|
-
//
|
|
14
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
15
|
+
// Popover presets
|
|
16
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
18
|
+
// ── popupMotion ──
|
|
19
|
+
|
|
20
|
+
var POPUP_MOTION_CSS = "\n [data-ds-popover-popup-motion] {\n animation: var(--ds-popover-motion-exit);\n animation-fill-mode: forwards;\n transition:\n overlay 150ms allow-discrete,\n display 150ms allow-discrete;\n }\n\n [data-ds-popover-popup-motion]:popover-open {\n animation: var(--ds-popover-motion-enter);\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-popover-popup-motion],\n [data-ds-popover-popup-motion]:popover-open {\n animation: none;\n transition-duration: 0s;\n }\n }\n";
|
|
21
|
+
function getPopupMotionProperties(_ref) {
|
|
22
|
+
var placement = _ref.placement;
|
|
19
23
|
var _getPlacement = (0, _resolvePlacement.getPlacement)({
|
|
20
24
|
placement: placement
|
|
21
25
|
}),
|
|
22
26
|
axis = _getPlacement.axis,
|
|
23
27
|
edge = _getPlacement.edge;
|
|
28
|
+
if (axis === 'block' && edge === 'start') {
|
|
29
|
+
return {
|
|
30
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
31
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (axis === 'inline' && edge === 'start') {
|
|
35
|
+
return {
|
|
36
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
37
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (axis === 'inline' && edge === 'end') {
|
|
41
|
+
return {
|
|
42
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
43
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Default: block/end (popover below trigger)
|
|
47
|
+
return {
|
|
48
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
49
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
54
|
+
function popupMotion() {
|
|
55
|
+
return {
|
|
56
|
+
name: 'popup-motion',
|
|
57
|
+
css: POPUP_MOTION_CSS,
|
|
58
|
+
enterDurationMs: 150,
|
|
59
|
+
exitDurationMs: 100,
|
|
60
|
+
getProperties: function getProperties(_ref2) {
|
|
61
|
+
var placement = _ref2.placement;
|
|
62
|
+
return getPopupMotionProperties({
|
|
63
|
+
placement: placement
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── slideAndFade ──
|
|
70
|
+
|
|
71
|
+
function getSlideAndFadeProperties(_ref3) {
|
|
72
|
+
var placement = _ref3.placement,
|
|
73
|
+
distance = _ref3.distance;
|
|
74
|
+
var pos = "".concat(distance, "px");
|
|
75
|
+
var neg = "-".concat(distance, "px");
|
|
76
|
+
var _getPlacement2 = (0, _resolvePlacement.getPlacement)({
|
|
77
|
+
placement: placement
|
|
78
|
+
}),
|
|
79
|
+
axis = _getPlacement2.axis,
|
|
80
|
+
edge = _getPlacement2.edge;
|
|
24
81
|
if (axis === 'block' && edge === 'start') {
|
|
25
82
|
return {
|
|
26
83
|
'--ds-popover-tx': '0',
|
|
@@ -73,14 +130,15 @@ var SLIDE_AND_FADE_CSS = "\n[data-ds-popover-slide-and-fade] {\n opacity: 0;\n
|
|
|
73
130
|
* <Popover animate={slideAndFade({ distance: 8 })} />
|
|
74
131
|
* ```
|
|
75
132
|
*/
|
|
133
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
76
134
|
function slideAndFade(options) {
|
|
77
135
|
var _options$distance;
|
|
78
136
|
var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
|
|
79
137
|
return {
|
|
80
138
|
name: 'slide-and-fade',
|
|
81
139
|
css: SLIDE_AND_FADE_CSS,
|
|
82
|
-
getProperties: function getProperties(
|
|
83
|
-
var placement =
|
|
140
|
+
getProperties: function getProperties(_ref4) {
|
|
141
|
+
var placement = _ref4.placement;
|
|
84
142
|
return getSlideAndFadeProperties({
|
|
85
143
|
placement: placement,
|
|
86
144
|
distance: distance
|
|
@@ -147,7 +205,36 @@ function scaleAndFade() {
|
|
|
147
205
|
// Dialog presets
|
|
148
206
|
// ══════════════════════════════════════════════════════════════════════════════
|
|
149
207
|
|
|
150
|
-
//
|
|
208
|
+
// ── dialogMotion ──
|
|
209
|
+
|
|
210
|
+
var DIALOG_MOTION_CSS = "\n [data-ds-dialog-motion] {\n animation: ".concat("var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)", ";\n animation-fill-mode: forwards;\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open] {\n animation: ", "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)", ";\n animation-fill-mode: backwards;\n }\n\n [data-ds-dialog-motion]::backdrop {\n animation: ", "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)", ";\n animation-fill-mode: forwards;\n background-color: var(--ds-blanket, #050C1F75);\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open]::backdrop {\n animation: ", "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)", ";\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-motion],\n [data-ds-dialog-motion][open],\n [data-ds-dialog-motion]::backdrop,\n [data-ds-dialog-motion][open]::backdrop {\n animation: none;\n transition-duration: 0s;\n }\n }\n");
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Dialog motion animation.
|
|
214
|
+
*
|
|
215
|
+
* Includes backdrop fade animation.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
220
|
+
*
|
|
221
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
222
|
+
* ...
|
|
223
|
+
* </Dialog>
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
227
|
+
function dialogMotion() {
|
|
228
|
+
// Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
|
|
229
|
+
return {
|
|
230
|
+
name: 'motion',
|
|
231
|
+
css: DIALOG_MOTION_CSS,
|
|
232
|
+
enterDurationMs: 250,
|
|
233
|
+
exitDurationMs: 200
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ── dialogSlideUpAndFade ──
|
|
151
238
|
|
|
152
239
|
var DIALOG_SLIDE_UP_AND_FADE_CSS = "\n[data-ds-dialog-slide-up-and-fade] {\n opacity: 0;\n transform: translateY(calc(-1 * var(--ds-dialog-ty, 12px)));\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open] {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open] {\n opacity: 0;\n transform: translateY(var(--ds-dialog-ty, 12px));\n }\n}\n\n[data-ds-dialog-slide-up-and-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-slide-up-and-fade],\n [data-ds-dialog-slide-up-and-fade][open],\n [data-ds-dialog-slide-up-and-fade]::backdrop,\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
|
|
153
240
|
|
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "dialogFade", {
|
|
|
9
9
|
return _presets.dialogFade;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "dialogMotion", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _presets.dialogMotion;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "dialogSlideUpAndFade", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function get() {
|
|
@@ -21,6 +27,12 @@ Object.defineProperty(exports, "fade", {
|
|
|
21
27
|
return _presets.fade;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "popupMotion", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _presets.popupMotion;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
Object.defineProperty(exports, "scaleAndFade", {
|
|
25
37
|
enumerable: true,
|
|
26
38
|
get: function get() {
|
|
@@ -1,6 +1,82 @@
|
|
|
1
1
|
import { getPlacement } from '../internal/resolve-placement';
|
|
2
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
3
|
+
// Popover presets
|
|
4
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
|
|
6
|
+
// ── popupMotion ──
|
|
7
|
+
|
|
8
|
+
const POPUP_MOTION_CSS = `
|
|
9
|
+
[data-ds-popover-popup-motion] {
|
|
10
|
+
animation: var(--ds-popover-motion-exit);
|
|
11
|
+
animation-fill-mode: forwards;
|
|
12
|
+
transition:
|
|
13
|
+
overlay 150ms allow-discrete,
|
|
14
|
+
display 150ms allow-discrete;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-ds-popover-popup-motion]:popover-open {
|
|
18
|
+
animation: var(--ds-popover-motion-enter);
|
|
19
|
+
animation-fill-mode: backwards;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (prefers-reduced-motion: reduce) {
|
|
23
|
+
[data-ds-popover-popup-motion],
|
|
24
|
+
[data-ds-popover-popup-motion]:popover-open {
|
|
25
|
+
animation: none;
|
|
26
|
+
transition-duration: 0s;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
function getPopupMotionProperties({
|
|
31
|
+
placement
|
|
32
|
+
}) {
|
|
33
|
+
const {
|
|
34
|
+
axis,
|
|
35
|
+
edge
|
|
36
|
+
} = getPlacement({
|
|
37
|
+
placement
|
|
38
|
+
});
|
|
39
|
+
if (axis === 'block' && edge === 'start') {
|
|
40
|
+
return {
|
|
41
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
42
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (axis === 'inline' && edge === 'start') {
|
|
46
|
+
return {
|
|
47
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
48
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (axis === 'inline' && edge === 'end') {
|
|
52
|
+
return {
|
|
53
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
54
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Default: block/end (popover below trigger)
|
|
58
|
+
return {
|
|
59
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
60
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
65
|
+
export function popupMotion() {
|
|
66
|
+
return {
|
|
67
|
+
name: 'popup-motion',
|
|
68
|
+
css: POPUP_MOTION_CSS,
|
|
69
|
+
enterDurationMs: 150,
|
|
70
|
+
exitDurationMs: 100,
|
|
71
|
+
getProperties: ({
|
|
72
|
+
placement
|
|
73
|
+
}) => getPopupMotionProperties({
|
|
74
|
+
placement
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
}
|
|
2
78
|
|
|
3
|
-
// slideAndFade
|
|
79
|
+
// ── slideAndFade ──
|
|
4
80
|
|
|
5
81
|
function getSlideAndFadeProperties({
|
|
6
82
|
placement,
|
|
@@ -106,6 +182,7 @@ const SLIDE_AND_FADE_CSS = `
|
|
|
106
182
|
* <Popover animate={slideAndFade({ distance: 8 })} />
|
|
107
183
|
* ```
|
|
108
184
|
*/
|
|
185
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
109
186
|
export function slideAndFade(options) {
|
|
110
187
|
var _options$distance;
|
|
111
188
|
const distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
|
|
@@ -235,7 +312,73 @@ export function scaleAndFade() {
|
|
|
235
312
|
// Dialog presets
|
|
236
313
|
// ══════════════════════════════════════════════════════════════════════════════
|
|
237
314
|
|
|
238
|
-
//
|
|
315
|
+
// ── dialogMotion ──
|
|
316
|
+
|
|
317
|
+
const DIALOG_MOTION_CSS = `
|
|
318
|
+
[data-ds-dialog-motion] {
|
|
319
|
+
animation: ${"var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)"};
|
|
320
|
+
animation-fill-mode: forwards;
|
|
321
|
+
transition:
|
|
322
|
+
overlay 200ms allow-discrete,
|
|
323
|
+
display 200ms allow-discrete;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
[data-ds-dialog-motion][open] {
|
|
327
|
+
animation: ${"var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)"};
|
|
328
|
+
animation-fill-mode: backwards;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
[data-ds-dialog-motion]::backdrop {
|
|
332
|
+
animation: ${"var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"};
|
|
333
|
+
animation-fill-mode: forwards;
|
|
334
|
+
background-color: var(--ds-blanket, #050C1F75);
|
|
335
|
+
transition:
|
|
336
|
+
overlay 200ms allow-discrete,
|
|
337
|
+
display 200ms allow-discrete;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
[data-ds-dialog-motion][open]::backdrop {
|
|
341
|
+
animation: ${"var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)"};
|
|
342
|
+
animation-fill-mode: backwards;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@media (prefers-reduced-motion: reduce) {
|
|
346
|
+
[data-ds-dialog-motion],
|
|
347
|
+
[data-ds-dialog-motion][open],
|
|
348
|
+
[data-ds-dialog-motion]::backdrop,
|
|
349
|
+
[data-ds-dialog-motion][open]::backdrop {
|
|
350
|
+
animation: none;
|
|
351
|
+
transition-duration: 0s;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
`;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Dialog motion animation.
|
|
358
|
+
*
|
|
359
|
+
* Includes backdrop fade animation.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```tsx
|
|
363
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
364
|
+
*
|
|
365
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
366
|
+
* ...
|
|
367
|
+
* </Dialog>
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
371
|
+
export function dialogMotion() {
|
|
372
|
+
// Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
|
|
373
|
+
return {
|
|
374
|
+
name: 'motion',
|
|
375
|
+
css: DIALOG_MOTION_CSS,
|
|
376
|
+
enterDurationMs: 250,
|
|
377
|
+
exitDurationMs: 200
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// ── dialogSlideUpAndFade ──
|
|
239
382
|
|
|
240
383
|
const DIALOG_SLIDE_UP_AND_FADE_CSS = `
|
|
241
384
|
[data-ds-dialog-slide-up-and-fade] {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
|
|
1
|
+
export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
|
|
@@ -1,17 +1,71 @@
|
|
|
1
1
|
import { getPlacement } from '../internal/resolve-placement';
|
|
2
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
3
|
+
// Popover presets
|
|
4
|
+
// ══════════════════════════════════════════════════════════════════════════════
|
|
2
5
|
|
|
3
|
-
//
|
|
6
|
+
// ── popupMotion ──
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var pos = "".concat(distance, "px");
|
|
9
|
-
var neg = "-".concat(distance, "px");
|
|
8
|
+
var POPUP_MOTION_CSS = "\n [data-ds-popover-popup-motion] {\n animation: var(--ds-popover-motion-exit);\n animation-fill-mode: forwards;\n transition:\n overlay 150ms allow-discrete,\n display 150ms allow-discrete;\n }\n\n [data-ds-popover-popup-motion]:popover-open {\n animation: var(--ds-popover-motion-enter);\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-popover-popup-motion],\n [data-ds-popover-popup-motion]:popover-open {\n animation: none;\n transition-duration: 0s;\n }\n }\n";
|
|
9
|
+
function getPopupMotionProperties(_ref) {
|
|
10
|
+
var placement = _ref.placement;
|
|
10
11
|
var _getPlacement = getPlacement({
|
|
11
12
|
placement: placement
|
|
12
13
|
}),
|
|
13
14
|
axis = _getPlacement.axis,
|
|
14
15
|
edge = _getPlacement.edge;
|
|
16
|
+
if (axis === 'block' && edge === 'start') {
|
|
17
|
+
return {
|
|
18
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-top, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInTop8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
19
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-top, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutTop8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (axis === 'inline' && edge === 'start') {
|
|
23
|
+
return {
|
|
24
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-left, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInLeft8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
25
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-left, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutLeft8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (axis === 'inline' && edge === 'end') {
|
|
29
|
+
return {
|
|
30
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-right, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInRight8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
31
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-right, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutRight8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// Default: block/end (popover below trigger)
|
|
35
|
+
return {
|
|
36
|
+
'--ds-popover-motion-enter': "var(--ds-popup-enter-bottom, 150ms cubic-bezier(0.4, 1, 0.6, 1) SlideInBottom8px, 150ms cubic-bezier(0.4, 1, 0.6, 1) FadeIn0to100)",
|
|
37
|
+
'--ds-popover-motion-exit': "var(--ds-popup-exit-bottom, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) SlideOutBottom8px, 100ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)"
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
42
|
+
export function popupMotion() {
|
|
43
|
+
return {
|
|
44
|
+
name: 'popup-motion',
|
|
45
|
+
css: POPUP_MOTION_CSS,
|
|
46
|
+
enterDurationMs: 150,
|
|
47
|
+
exitDurationMs: 100,
|
|
48
|
+
getProperties: function getProperties(_ref2) {
|
|
49
|
+
var placement = _ref2.placement;
|
|
50
|
+
return getPopupMotionProperties({
|
|
51
|
+
placement: placement
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ── slideAndFade ──
|
|
58
|
+
|
|
59
|
+
function getSlideAndFadeProperties(_ref3) {
|
|
60
|
+
var placement = _ref3.placement,
|
|
61
|
+
distance = _ref3.distance;
|
|
62
|
+
var pos = "".concat(distance, "px");
|
|
63
|
+
var neg = "-".concat(distance, "px");
|
|
64
|
+
var _getPlacement2 = getPlacement({
|
|
65
|
+
placement: placement
|
|
66
|
+
}),
|
|
67
|
+
axis = _getPlacement2.axis,
|
|
68
|
+
edge = _getPlacement2.edge;
|
|
15
69
|
if (axis === 'block' && edge === 'start') {
|
|
16
70
|
return {
|
|
17
71
|
'--ds-popover-tx': '0',
|
|
@@ -64,14 +118,15 @@ var SLIDE_AND_FADE_CSS = "\n[data-ds-popover-slide-and-fade] {\n opacity: 0;\n
|
|
|
64
118
|
* <Popover animate={slideAndFade({ distance: 8 })} />
|
|
65
119
|
* ```
|
|
66
120
|
*/
|
|
121
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
67
122
|
export function slideAndFade(options) {
|
|
68
123
|
var _options$distance;
|
|
69
124
|
var distance = (_options$distance = options === null || options === void 0 ? void 0 : options.distance) !== null && _options$distance !== void 0 ? _options$distance : 4;
|
|
70
125
|
return {
|
|
71
126
|
name: 'slide-and-fade',
|
|
72
127
|
css: SLIDE_AND_FADE_CSS,
|
|
73
|
-
getProperties: function getProperties(
|
|
74
|
-
var placement =
|
|
128
|
+
getProperties: function getProperties(_ref4) {
|
|
129
|
+
var placement = _ref4.placement;
|
|
75
130
|
return getSlideAndFadeProperties({
|
|
76
131
|
placement: placement,
|
|
77
132
|
distance: distance
|
|
@@ -138,7 +193,36 @@ export function scaleAndFade() {
|
|
|
138
193
|
// Dialog presets
|
|
139
194
|
// ══════════════════════════════════════════════════════════════════════════════
|
|
140
195
|
|
|
141
|
-
//
|
|
196
|
+
// ── dialogMotion ──
|
|
197
|
+
|
|
198
|
+
var DIALOG_MOTION_CSS = "\n [data-ds-dialog-motion] {\n animation: ".concat("var(--ds-modal-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) ScaleOut100to95)", ";\n animation-fill-mode: forwards;\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open] {\n animation: ", "var(--ds-modal-enter, 250ms cubic-bezier(0.4, 0, 0, 1) ScaleIn95to100)", ";\n animation-fill-mode: backwards;\n }\n\n [data-ds-dialog-motion]::backdrop {\n animation: ", "var(--ds-blanket-exit, 200ms cubic-bezier(0.6, 0, 0.8, 0.6) FadeOut100to0)", ";\n animation-fill-mode: forwards;\n background-color: var(--ds-blanket, #050C1F75);\n transition:\n overlay 200ms allow-discrete,\n display 200ms allow-discrete;\n }\n\n [data-ds-dialog-motion][open]::backdrop {\n animation: ", "var(--ds-blanket-enter, 250ms cubic-bezier(0.4, 0, 0, 1) FadeIn0to100)", ";\n animation-fill-mode: backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-motion],\n [data-ds-dialog-motion][open],\n [data-ds-dialog-motion]::backdrop,\n [data-ds-dialog-motion][open]::backdrop {\n animation: none;\n transition-duration: 0s;\n }\n }\n");
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Dialog motion animation.
|
|
202
|
+
*
|
|
203
|
+
* Includes backdrop fade animation.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```tsx
|
|
207
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
208
|
+
*
|
|
209
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
210
|
+
* ...
|
|
211
|
+
* </Dialog>
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
215
|
+
export function dialogMotion() {
|
|
216
|
+
// Bare preset name; `Dialog` prefixes it via `data-ds-dialog-{name}`.
|
|
217
|
+
return {
|
|
218
|
+
name: 'motion',
|
|
219
|
+
css: DIALOG_MOTION_CSS,
|
|
220
|
+
enterDurationMs: 250,
|
|
221
|
+
exitDurationMs: 200
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ── dialogSlideUpAndFade ──
|
|
142
226
|
|
|
143
227
|
var DIALOG_SLIDE_UP_AND_FADE_CSS = "\n[data-ds-dialog-slide-up-and-fade] {\n opacity: 0;\n transform: translateY(calc(-1 * var(--ds-dialog-ty, 12px)));\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open] {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open] {\n opacity: 0;\n transform: translateY(var(--ds-dialog-ty, 12px));\n }\n}\n\n[data-ds-dialog-slide-up-and-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-slide-up-and-fade],\n [data-ds-dialog-slide-up-and-fade][open],\n [data-ds-dialog-slide-up-and-fade]::backdrop,\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
|
|
144
228
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
|
|
1
|
+
export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade } from '../animations/presets';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TAnimationPreset } from './types';
|
|
2
|
+
export declare function popupMotion(): TAnimationPreset;
|
|
2
3
|
type TSlideAndFadeOptions = {
|
|
3
4
|
/**
|
|
4
5
|
* Slide distance in pixels. Defaults to `4`.
|
|
@@ -51,6 +52,21 @@ export declare function fade(): TAnimationPreset;
|
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
54
|
export declare function scaleAndFade(): TAnimationPreset;
|
|
55
|
+
/**
|
|
56
|
+
* Dialog motion animation.
|
|
57
|
+
*
|
|
58
|
+
* Includes backdrop fade animation.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
63
|
+
*
|
|
64
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
65
|
+
* ...
|
|
66
|
+
* </Dialog>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function dialogMotion(): TAnimationPreset;
|
|
54
70
|
type TDialogSlideUpAndFadeOptions = {
|
|
55
71
|
/**
|
|
56
72
|
* Slide distance in pixels. Defaults to `12`.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade, } from '../animations/presets';
|
|
1
|
+
export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade, } from '../animations/presets';
|
|
2
2
|
export type { TAnimationPreset } from '../animations/types';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TAnimationPreset } from './types';
|
|
2
|
+
export declare function popupMotion(): TAnimationPreset;
|
|
2
3
|
type TSlideAndFadeOptions = {
|
|
3
4
|
/**
|
|
4
5
|
* Slide distance in pixels. Defaults to `4`.
|
|
@@ -51,6 +52,21 @@ export declare function fade(): TAnimationPreset;
|
|
|
51
52
|
* ```
|
|
52
53
|
*/
|
|
53
54
|
export declare function scaleAndFade(): TAnimationPreset;
|
|
55
|
+
/**
|
|
56
|
+
* Dialog motion animation.
|
|
57
|
+
*
|
|
58
|
+
* Includes backdrop fade animation.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* import { dialogMotion } from '@atlaskit/top-layer/animations';
|
|
63
|
+
*
|
|
64
|
+
* <Dialog animate={dialogMotion()} isOpen={isOpen} onClose={handleClose} label="...">
|
|
65
|
+
* ...
|
|
66
|
+
* </Dialog>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function dialogMotion(): TAnimationPreset;
|
|
54
70
|
type TDialogSlideUpAndFadeOptions = {
|
|
55
71
|
/**
|
|
56
72
|
* Slide distance in pixels. Defaults to `12`.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade, } from '../animations/presets';
|
|
1
|
+
export { dialogMotion, popupMotion, slideAndFade, fade, scaleAndFade, dialogSlideUpAndFade, dialogFade, } from '../animations/presets';
|
|
2
2
|
export type { TAnimationPreset } from '../animations/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/top-layer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Low-level layering primitives based on popover and dialog",
|
|
5
5
|
"homepage": "https://atlassian.design/components/top-layer",
|
|
6
6
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/css": "^0.19.0",
|
|
39
39
|
"@atlaskit/ds-lib": "^7.0.0",
|
|
40
40
|
"@atlaskit/layering": "^3.8.0",
|
|
41
|
-
"@atlaskit/tokens": "^13.
|
|
41
|
+
"@atlaskit/tokens": "^13.4.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"@compiled/react": "^0.20.0",
|
|
44
44
|
"bind-event-listener": "^3.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@af/visual-regression": "workspace:^",
|
|
54
54
|
"@atlaskit/button": "^23.11.0",
|
|
55
55
|
"@atlaskit/heading": "^5.4.0",
|
|
56
|
-
"@atlaskit/lozenge": "^13.
|
|
56
|
+
"@atlaskit/lozenge": "^13.9.0",
|
|
57
57
|
"@atlaskit/primitives": "^19.0.0",
|
|
58
58
|
"@atlaskit/ssr": "workspace:^",
|
|
59
59
|
"@atlaskit/textfield": "^8.3.0",
|