@canonical/react-motion-control 0.0.0-stage → 0.48.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/LICENSE +166 -0
- package/README.md +124 -2
- package/dist/esm/MotionHint/MotionHint.js +19 -0
- package/dist/esm/MotionHint/MotionHint.js.map +1 -0
- package/dist/esm/MotionHint/index.js +2 -0
- package/dist/esm/MotionHint/index.js.map +1 -0
- package/dist/esm/MotionHint/types.js +2 -0
- package/dist/esm/MotionHint/types.js.map +1 -0
- package/dist/esm/MotionScene/Context.js +4 -0
- package/dist/esm/MotionScene/Context.js.map +1 -0
- package/dist/esm/MotionScene/MotionScene.js +76 -0
- package/dist/esm/MotionScene/MotionScene.js.map +1 -0
- package/dist/esm/MotionScene/common/Controls/Controls.js +38 -0
- package/dist/esm/MotionScene/common/Controls/Controls.js.map +1 -0
- package/dist/esm/MotionScene/common/Controls/index.js +2 -0
- package/dist/esm/MotionScene/common/Controls/index.js.map +1 -0
- package/dist/esm/MotionScene/common/Controls/types.js +2 -0
- package/dist/esm/MotionScene/common/Controls/types.js.map +1 -0
- package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js +55 -0
- package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js.map +1 -0
- package/dist/esm/MotionScene/common/ExportSlide/constants.js +11 -0
- package/dist/esm/MotionScene/common/ExportSlide/constants.js.map +1 -0
- package/dist/esm/MotionScene/common/ExportSlide/index.js +3 -0
- package/dist/esm/MotionScene/common/ExportSlide/index.js.map +1 -0
- package/dist/esm/MotionScene/common/ExportSlide/types.js +2 -0
- package/dist/esm/MotionScene/common/ExportSlide/types.js.map +1 -0
- package/dist/esm/MotionScene/common/Frame/Frame.js +19 -0
- package/dist/esm/MotionScene/common/Frame/Frame.js.map +1 -0
- package/dist/esm/MotionScene/common/Frame/index.js +2 -0
- package/dist/esm/MotionScene/common/Frame/index.js.map +1 -0
- package/dist/esm/MotionScene/common/Frame/types.js +2 -0
- package/dist/esm/MotionScene/common/Frame/types.js.map +1 -0
- package/dist/esm/MotionScene/common/Title/Title.js +27 -0
- package/dist/esm/MotionScene/common/Title/Title.js.map +1 -0
- package/dist/esm/MotionScene/common/Title/index.js +2 -0
- package/dist/esm/MotionScene/common/Title/index.js.map +1 -0
- package/dist/esm/MotionScene/common/Title/types.js +2 -0
- package/dist/esm/MotionScene/common/Title/types.js.map +1 -0
- package/dist/esm/MotionScene/common/index.js +5 -0
- package/dist/esm/MotionScene/common/index.js.map +1 -0
- package/dist/esm/MotionScene/index.js +2 -0
- package/dist/esm/MotionScene/index.js.map +1 -0
- package/dist/esm/MotionScene/types.js +2 -0
- package/dist/esm/MotionScene/types.js.map +1 -0
- package/dist/esm/MotionSlide/MotionSlide.js +42 -0
- package/dist/esm/MotionSlide/MotionSlide.js.map +1 -0
- package/dist/esm/MotionSlide/index.js +2 -0
- package/dist/esm/MotionSlide/index.js.map +1 -0
- package/dist/esm/MotionSlide/types.js +2 -0
- package/dist/esm/MotionSlide/types.js.map +1 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/index.js.map +1 -0
- package/dist/esm/hooks/types.js +2 -0
- package/dist/esm/hooks/types.js.map +1 -0
- package/dist/esm/hooks/useMotion.js +228 -0
- package/dist/esm/hooks/useMotion.js.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/styles.css +81 -0
- package/dist/types/MotionHint/MotionHint.d.ts +7 -0
- package/dist/types/MotionHint/MotionHint.d.ts.map +1 -0
- package/dist/types/MotionHint/index.d.ts +3 -0
- package/dist/types/MotionHint/index.d.ts.map +1 -0
- package/dist/types/MotionHint/types.d.ts +7 -0
- package/dist/types/MotionHint/types.d.ts.map +1 -0
- package/dist/types/MotionScene/Context.d.ts +4 -0
- package/dist/types/MotionScene/Context.d.ts.map +1 -0
- package/dist/types/MotionScene/MotionScene.d.ts +8 -0
- package/dist/types/MotionScene/MotionScene.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Controls/Controls.d.ts +8 -0
- package/dist/types/MotionScene/common/Controls/Controls.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Controls/index.d.ts +3 -0
- package/dist/types/MotionScene/common/Controls/index.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Controls/types.d.ts +10 -0
- package/dist/types/MotionScene/common/Controls/types.d.ts.map +1 -0
- package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts +9 -0
- package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts.map +1 -0
- package/dist/types/MotionScene/common/ExportSlide/constants.d.ts +28 -0
- package/dist/types/MotionScene/common/ExportSlide/constants.d.ts.map +1 -0
- package/dist/types/MotionScene/common/ExportSlide/index.d.ts +4 -0
- package/dist/types/MotionScene/common/ExportSlide/index.d.ts.map +1 -0
- package/dist/types/MotionScene/common/ExportSlide/types.d.ts +23 -0
- package/dist/types/MotionScene/common/ExportSlide/types.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Frame/Frame.d.ts +12 -0
- package/dist/types/MotionScene/common/Frame/Frame.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Frame/index.d.ts +3 -0
- package/dist/types/MotionScene/common/Frame/index.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Frame/types.d.ts +11 -0
- package/dist/types/MotionScene/common/Frame/types.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Title/Title.d.ts +8 -0
- package/dist/types/MotionScene/common/Title/Title.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Title/index.d.ts +3 -0
- package/dist/types/MotionScene/common/Title/index.d.ts.map +1 -0
- package/dist/types/MotionScene/common/Title/types.d.ts +18 -0
- package/dist/types/MotionScene/common/Title/types.d.ts.map +1 -0
- package/dist/types/MotionScene/common/index.d.ts +5 -0
- package/dist/types/MotionScene/common/index.d.ts.map +1 -0
- package/dist/types/MotionScene/index.d.ts +4 -0
- package/dist/types/MotionScene/index.d.ts.map +1 -0
- package/dist/types/MotionScene/types.d.ts +31 -0
- package/dist/types/MotionScene/types.d.ts.map +1 -0
- package/dist/types/MotionSlide/MotionSlide.d.ts +15 -0
- package/dist/types/MotionSlide/MotionSlide.d.ts.map +1 -0
- package/dist/types/MotionSlide/index.d.ts +3 -0
- package/dist/types/MotionSlide/index.d.ts.map +1 -0
- package/dist/types/MotionSlide/types.d.ts +26 -0
- package/dist/types/MotionSlide/types.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/types.d.ts +86 -0
- package/dist/types/hooks/types.d.ts.map +1 -0
- package/dist/types/hooks/useMotion.d.ts +16 -0
- package/dist/types/hooks/useMotion.d.ts.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +78 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @canonical/react-motion-control
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components that play `@canonical/motion-control` scenes over an application's own components: a scene in the page, a hint beside the thing it explains, and what a tour over the whole page is made of.
|
|
4
|
+
|
|
5
|
+
A frame is a React subtree: the real component with the props and the data of one state. A scene says which frames to show and which interaction leads from one to the next. Nothing is redrawn for the tutorial, so it looks like the product and changes with it.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @canonical/react-motion-control @canonical/motion-control
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Load both stylesheets once in the application:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import "@canonical/motion-control/style.css";
|
|
17
|
+
import "@canonical/react-motion-control/style.css";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { MotionScene } from "@canonical/react-motion-control";
|
|
24
|
+
|
|
25
|
+
const scene = {
|
|
26
|
+
id: "remove",
|
|
27
|
+
title: "Sliding a task away",
|
|
28
|
+
steps: [
|
|
29
|
+
{ frame: "list.rest", hold: 900, say: "Task 3 is selected." },
|
|
30
|
+
{ do: "slide", on: ".row.on", to: "end", depth: "deep", say: "A slide all the way to the end." },
|
|
31
|
+
{ frame: "list.removed", hold: 1800, say: "Removed, with the way back." },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
<MotionScene scene={scene} profile={{ slideTarget: (target) => target.closest(".row") ?? target }}>
|
|
36
|
+
<MotionScene.Frame name="list.rest" code="L1">
|
|
37
|
+
<TaskList tasks={tasks} selected={2} />
|
|
38
|
+
</MotionScene.Frame>
|
|
39
|
+
<MotionScene.Frame name="list.removed" code="L2">
|
|
40
|
+
<TaskList tasks={tasks} removed={{ at: 2, notice: "Removed · Undo" }} />
|
|
41
|
+
</MotionScene.Frame>
|
|
42
|
+
</MotionScene>;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Component | For |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `MotionScene` | A scene or a clip in the page, with its panel and controls. `show` hides the title's row, the caption's rows or the controls' row, whole or part by part; `titlePlace="below"` puts the title in the panel. |
|
|
48
|
+
| `MotionHint` | A small scene that shows the screen and the words of its caption, and nothing else. |
|
|
49
|
+
| `MotionSlide` | A scene on a slide of a deck, at the slide's full size: the whole figure or the screen alone, centred and scaled to fill it, with a title over it and a caption under it. |
|
|
50
|
+
| `useMotion` | What they are made of: the scene's position, what it shows there, and the ways to move it, for a figure of another shape. |
|
|
51
|
+
|
|
52
|
+
Every frame of a scene is on the page at once, laid on top of the others, so each has its data and its size from the start; only the frame in view shows and can be reached.
|
|
53
|
+
|
|
54
|
+
### Keys
|
|
55
|
+
|
|
56
|
+
Typing shows as a small sign that words are arriving. With `keys="letters"`, a strip of keystrokes stands just over the frame's line: the letters as they arrive, the newest marked, and a named key such as Enter, Backspace or Escape as a cap after them. `--mo-keys-gap` on the figure sets how far over the line it stands.
|
|
57
|
+
|
|
58
|
+
### Slides for a deck
|
|
59
|
+
|
|
60
|
+
The three dots of a scene open a menu whose second entry, Export slide…, records the scene on a slide and hands the reader the file. The form asks for the slide's size, from the usual ones or typed in, whether it shows the whole figure or the screen alone, its title and caption, how many times faster than written the scene plays, the file, an MP4 video or an animated GIF, and the pictures a second. A video is encoded by the browser's own encoder, so it records where the browser offers one, as Chrome and Edge do; elsewhere the form says it cannot, and a GIF records the same slide.
|
|
61
|
+
|
|
62
|
+
`MotionSlide` shows the same slide in a page, at its full size; the page scales what holds it to show it smaller.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<MotionSlide scene={scene} width={1920} height={1080} mode="bare" title="Fixing a typo" keys="letters">
|
|
66
|
+
{frames}
|
|
67
|
+
</MotionSlide>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Outline
|
|
71
|
+
|
|
72
|
+
While keys are typed or pressed, what they go to is outlined in the colour of the interactions. `outline={{ click: true }}` outlines what a click or a tap presses as well; `outline={{ keys: false }}` turns the first off.
|
|
73
|
+
|
|
74
|
+
### Play once or again
|
|
75
|
+
|
|
76
|
+
A scene starts again at its end unless its cast says `"loop": false`. `loop` sets it whatever the cast says, and Loop in the menu behind the three dots lets the reader turn it on and off; the reader's choice wins. A GIF saved from the menu plays again or once as the scene does. `useMotion` gives `loop` and `setLoop` for an application that draws its own controls.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<MotionScene scene={scene} loop={false}>…</MotionScene>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Practice
|
|
83
|
+
|
|
84
|
+
A tap, a click or a hold that the scene marks with `practice: true` waits for the reader to do it on the frame, when the component is given `practice`:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<MotionScene scene={scene} practice>…</MotionScene>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The frame is the application's real component, so the press lands on its real controls.
|
|
91
|
+
|
|
92
|
+
### A tour over the page
|
|
93
|
+
|
|
94
|
+
The package has no tour component: a tour is the application's own dialog, words and way of closing. The Storybook has one made of `MotionScene` as a recipe, with its source on the page, under Documentation, Recipes.
|
|
95
|
+
|
|
96
|
+
### States from one place
|
|
97
|
+
|
|
98
|
+
Keep the states of a component in a module of their own, as props per frame name, and build the frames from it. The same module can serve the component's stories, so a state is written once.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
export const STATES = {
|
|
102
|
+
"list.rest": { tasks, selected: 2 },
|
|
103
|
+
"list.removed": { tasks, removed: { at: 2, notice: "Removed · Undo" } },
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const frames = Object.entries(STATES).map(([name, state]) => (
|
|
107
|
+
<MotionScene.Frame key={name} name={name}>
|
|
108
|
+
<TaskList {...state} />
|
|
109
|
+
</MotionScene.Frame>
|
|
110
|
+
));
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bun run check
|
|
117
|
+
bun run test
|
|
118
|
+
bun run storybook
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The stories play over a small task list that stands for an application's components; it lives in `src/testing` and is not published.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MotionScene } from "../MotionScene/index.js";
|
|
3
|
+
const componentCssClassName = "mo-hint";
|
|
4
|
+
/** A hint shows the screen and the words of its caption, and nothing else. */
|
|
5
|
+
const SHOWN = {
|
|
6
|
+
title: false,
|
|
7
|
+
caption: { code: false, frame: false, interaction: false, count: false },
|
|
8
|
+
timeline: false,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A small scene that plays by itself beside the thing it explains: how a gesture works, what a control does.
|
|
12
|
+
* It shows the screen and the words of its caption, with no title and no controls.
|
|
13
|
+
*
|
|
14
|
+
* `import { MotionHint } from "@canonical/react-motion-control";`
|
|
15
|
+
*/
|
|
16
|
+
const MotionHint = ({ className, ...rest }) => (_jsx(MotionScene, { className: [componentCssClassName, className].filter(Boolean).join(" "), show: SHOWN, ...rest }));
|
|
17
|
+
MotionHint.Frame = MotionScene.Frame;
|
|
18
|
+
export default MotionHint;
|
|
19
|
+
//# sourceMappingURL=MotionHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MotionHint.js","sourceRoot":"","sources":["../../../src/MotionHint/MotionHint.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAExC,8EAA8E;AAC9E,MAAM,KAAK,GAAU;IACnB,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IACxE,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAmB,EAAE,EAAE,CAAC,CAC9D,KAAC,WAAW,IACV,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACvE,IAAI,EAAE,KAAK,KACP,IAAI,GACR,CACH,CAAC;AAEF,UAAU,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;AAErC,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/MotionHint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/MotionHint/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../src/MotionScene/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,OAAO,GAAG,aAAa,CAAc,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;AAE7E,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { assertPresent, listHidden, recordGif, recordVideo, saveFile, } from "@canonical/motion-control/dom";
|
|
3
|
+
import { useMemo, useRef, useState } from "react";
|
|
4
|
+
import { flushSync } from "react-dom";
|
|
5
|
+
import { useMotion } from "../hooks/index.js";
|
|
6
|
+
import Context from "./Context.js";
|
|
7
|
+
import { Controls, ExportSlide, Frame, Title, } from "./common/index.js";
|
|
8
|
+
const componentCssClassName = "motion-figure";
|
|
9
|
+
/**
|
|
10
|
+
* Plays a scene over the application's own components, in the page: a screen that shows one frame at a time,
|
|
11
|
+
* the symbol of each interaction drawn over it, and a panel that names what is in view and holds the controls.
|
|
12
|
+
*
|
|
13
|
+
* The frames are its children, each a `MotionScene.Frame`. They are living React: a frame renders the real
|
|
14
|
+
* component with the props and the data of one state, so a clip looks like the product and changes with it.
|
|
15
|
+
*
|
|
16
|
+
* `import { MotionScene } from "@canonical/react-motion-control";`
|
|
17
|
+
*/
|
|
18
|
+
const MotionScene = ({ scene, titlePlace = "above", show, profile, speeds, keys, outline, practice, loop, autoPlay, onStep, onEnd, className, children, ...rest }) => {
|
|
19
|
+
const figureRef = useRef(null);
|
|
20
|
+
const motion = useMotion(scene, {
|
|
21
|
+
profile,
|
|
22
|
+
speeds,
|
|
23
|
+
keys,
|
|
24
|
+
outline,
|
|
25
|
+
practice,
|
|
26
|
+
loop,
|
|
27
|
+
autoPlay,
|
|
28
|
+
onStep,
|
|
29
|
+
onEnd,
|
|
30
|
+
});
|
|
31
|
+
const sceneFrames = useMemo(() => ({
|
|
32
|
+
current: motion.frame,
|
|
33
|
+
used: new Set(scene.steps.flatMap((step) => ("frame" in step ? [step.frame] : []))),
|
|
34
|
+
}), [motion.frame, scene]);
|
|
35
|
+
const { words } = motion.profile;
|
|
36
|
+
const strip = motion.moment?.strip;
|
|
37
|
+
const above = titlePlace !== "below";
|
|
38
|
+
const waiting = motion.awaiting !== undefined && motion.awaiting === motion.position.index;
|
|
39
|
+
const [exporting, setExporting] = useState(false);
|
|
40
|
+
// A recording shows the scene moment by moment and draws the figure each time, so each moment has to be on
|
|
41
|
+
// the page before the next line runs. The scene is left where it was.
|
|
42
|
+
const record = async (format, options) => {
|
|
43
|
+
const figure = assertPresent(figureRef.current, "the figure");
|
|
44
|
+
const timeline = assertPresent(motion.timeline, "the scene's timeline");
|
|
45
|
+
const before = assertPresent(motion.moment, "the moment in view").time;
|
|
46
|
+
motion.pause();
|
|
47
|
+
try {
|
|
48
|
+
const recordFile = format === "mp4" ? recordVideo : recordGif;
|
|
49
|
+
const bytes = await recordFile({
|
|
50
|
+
root: figure,
|
|
51
|
+
total: timeline.total,
|
|
52
|
+
poseAt: (time) => flushSync(() => motion.seek(time)),
|
|
53
|
+
loop: motion.loop,
|
|
54
|
+
}, options);
|
|
55
|
+
saveFile(bytes, `${scene.id}.${format}`, format === "mp4" ? "video/mp4" : "image/gif");
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
motion.seek(before);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const title = (_jsx(Title, { scene: scene, words: words, onSave: (onProgress) => record("gif", { onProgress }), onExportSlide: () => setExporting(true), loop: motion.loop, onLoop: motion.setLoop }));
|
|
62
|
+
return (_jsxs("figure", { ref: figureRef, id: scene.id, className: [
|
|
63
|
+
componentCssClassName,
|
|
64
|
+
`mo-${scene.device ?? "phone"}`,
|
|
65
|
+
scene.clip && "mo-clip",
|
|
66
|
+
above && "mo-title-above",
|
|
67
|
+
...listHidden(show),
|
|
68
|
+
motion.awaiting !== undefined && "mo-awaiting",
|
|
69
|
+
className,
|
|
70
|
+
]
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.join(" "), ...rest, children: [above && _jsx("div", { className: "mo-meta mo-top", children: title }), _jsxs("div", { className: "mo-stage", children: [_jsx("div", { className: "mo-screen mo-live", ref: motion.screenRef, onClick: (event) => motion.press(event.target), children: _jsx(Context, { value: sceneFrames, children: children }) }), _jsx("div", { className: "mo-layer", ref: motion.layerRef })] }), exporting && (_jsx(ExportSlide, { scene: scene, onClose: () => setExporting(false), onExport: ({ format, slide, speed, fps }, onProgress) => record(format, { slide, speed, fps, onProgress }) })), _jsxs("figcaption", { className: "mo-meta", children: [!above && (_jsxs(_Fragment, { children: [title, _jsx("i", { className: "mo-rule" })] })), _jsx("span", { className: "mo-code", children: strip?.code }), _jsxs("span", { className: "mo-frame", children: [_jsx("span", { className: "mo-name", children: strip?.name }), _jsx("span", { className: "mo-pat", style: { opacity: strip?.patternOpacity }, children: waiting ? `${words.turn} · ${strip?.pattern}` : strip?.pattern })] }), _jsx("span", { className: "mo-count", children: strip?.count }), _jsx("span", { className: "mo-say", children: strip?.say }), _jsx("i", { className: "mo-rule mo-foot" }), _jsx(Controls, { motion: motion, words: words })] })] }));
|
|
73
|
+
};
|
|
74
|
+
MotionScene.Frame = Frame;
|
|
75
|
+
export default MotionScene;
|
|
76
|
+
//# sourceMappingURL=MotionScene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MotionScene.js","sourceRoot":"","sources":["../../../src/MotionScene/MotionScene.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OA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,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,CACtD,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,GAEnD,CACH,EACD,sBAAY,SAAS,EAAC,SAAS,aAC5B,CAAC,KAAK,IAAI,CACT,8BACG,KAAK,EACN,YAAG,SAAS,EAAC,SAAS,GAAG,IACxB,CACJ,EACD,eAAM,SAAS,EAAC,SAAS,YAAE,KAAK,EAAE,IAAI,GAAQ,EAC9C,gBAAM,SAAS,EAAC,UAAU,aACxB,eAAM,SAAS,EAAC,SAAS,YAAE,KAAK,EAAE,IAAI,GAAQ,EAC9C,eAAM,SAAS,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,YAC/D,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,GAC1D,IACF,EACP,eAAM,SAAS,EAAC,UAAU,YAAE,KAAK,EAAE,KAAK,GAAQ,EAChD,eAAM,SAAS,EAAC,QAAQ,YAAE,KAAK,EAAE,GAAG,GAAQ,EAC5C,YAAG,SAAS,EAAC,iBAAiB,GAAG,EACjC,KAAC,QAAQ,IAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAI,IAC/B,IACN,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;AAE1B,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatSpeed, formatTime, PAUSE_SIGN, PLAY_SIGN, TIME_MODES, } from "@canonical/motion-control/dom";
|
|
3
|
+
import { describeAction } from "@canonical/motion-control/moment";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* The controls' row of a scene: back, play and forward; the bar, one segment per step, to press or drag to any
|
|
7
|
+
* moment; and what is read off the bar, the speed and the time.
|
|
8
|
+
*/
|
|
9
|
+
const Controls = ({ motion, words }) => {
|
|
10
|
+
const [timeMode, setTimeMode] = useState("elapsed");
|
|
11
|
+
const { timeline, position, moment, playing } = motion;
|
|
12
|
+
const total = timeline?.total ?? 0;
|
|
13
|
+
const scrub = (event) => {
|
|
14
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
15
|
+
const fraction = (event.clientX - box.left) / (box.width || 1);
|
|
16
|
+
motion.seek(Math.max(0, Math.min(0.9999, fraction)) * total);
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { className: "mo-nav", children: [_jsx("button", { type: "button", className: "mo-st", title: words.back, "aria-label": words.back, onClick: () => motion.stepKeyframe(-1), children: "\u2190" }), _jsx("button", { type: "button", className: "mo-pp", title: playing ? words.pause : words.play, "aria-label": playing ? words.pause : words.play, onClick: playing ? motion.pause : motion.play,
|
|
19
|
+
// The signs are the drawings the package ships, the same as on a page without React.
|
|
20
|
+
// biome-ignore lint/security/noDangerouslySetInnerHtml: a constant of the package, not content.
|
|
21
|
+
dangerouslySetInnerHTML: { __html: playing ? PAUSE_SIGN : PLAY_SIGN } }), _jsx("button", { type: "button", className: "mo-st", title: words.forward, "aria-label": words.forward, onClick: () => motion.stepKeyframe(1), children: "\u2192" })] }), _jsx("span", { className: "mo-tl", onPointerDown: (event) => {
|
|
22
|
+
motion.pause();
|
|
23
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
24
|
+
scrub(event);
|
|
25
|
+
}, onPointerMove: (event) => {
|
|
26
|
+
if (event.buttons > 0)
|
|
27
|
+
scrub(event);
|
|
28
|
+
}, children: timeline?.steps.map((step, index) => {
|
|
29
|
+
const done = index < position.index
|
|
30
|
+
? 100
|
|
31
|
+
: index === position.index
|
|
32
|
+
? position.progress * 100
|
|
33
|
+
: 0;
|
|
34
|
+
return (_jsx("span", { className: `mo-seg${step.chapter ? " mo-ch" : ""}`, style: { flexGrow: timeline.durations[index] }, title: "frame" in step ? step.frame : describeAction(step), children: _jsx("i", { style: { width: `${done}%` } }) }, index));
|
|
35
|
+
}) }), _jsxs("span", { className: "mo-read", children: [_jsx("button", { type: "button", className: "mo-speed", title: words.speed, onClick: motion.cycleSpeed, children: formatSpeed(motion.speed) }), _jsx("button", { type: "button", className: "mo-time", title: words.time[timeMode], onClick: () => setTimeMode(TIME_MODES[(TIME_MODES.indexOf(timeMode) + 1) % TIME_MODES.length]), children: formatTime(timeMode, moment?.time ?? 0, total) })] })] }));
|
|
36
|
+
};
|
|
37
|
+
export default Controls;
|
|
38
|
+
//# sourceMappingURL=Controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controls.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/Controls.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,GAEX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAqB,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD;;;GAGG;AACH,MAAM,QAAQ,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAiB,EAAE,EAAE;IACpD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,SAAS,CAAC,CAAC;IAC9D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACvD,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,KAAoC,EAAQ,EAAE;QAC3D,M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U,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,MAAM,CAAC,UAAU,YAEzB,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GACnB,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,SAAS,EACnB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC3B,OAAO,EAAE,GAAG,EAAE,CACZ,WAAW,CACT,UAAU,CACR,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAC3C,CACd,YAGF,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,CAAC,GACxC,IACJ,IACN,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { DEFAULT_FPS, SLIDE_SIZES } from "./constants.js";
|
|
4
|
+
const componentCssClassName = "mo-export";
|
|
5
|
+
/**
|
|
6
|
+
* A form that exports a scene on a slide: the slide's size, typed in or chosen from the usual ones, whether it
|
|
7
|
+
* shows the whole figure or the screen alone, its title and caption, how fast the scene plays, and whether the
|
|
8
|
+
* file is a video or a GIF. While the scene records, the form says how far it is.
|
|
9
|
+
*/
|
|
10
|
+
const ExportSlide = ({ scene, onClose, onExport }) => {
|
|
11
|
+
const [width, setWidth] = useState(SLIDE_SIZES[0].width);
|
|
12
|
+
const [height, setHeight] = useState(SLIDE_SIZES[0].height);
|
|
13
|
+
const [mode, setMode] = useState("framed");
|
|
14
|
+
const [title, setTitle] = useState(scene.title);
|
|
15
|
+
const [caption, setCaption] = useState("");
|
|
16
|
+
const [speed, setSpeed] = useState(1);
|
|
17
|
+
const [format, setFormat] = useState("mp4");
|
|
18
|
+
// Left empty, the pictures per second follow the file: smooth for a video, small for a GIF.
|
|
19
|
+
const [fps, setFps] = useState("");
|
|
20
|
+
const [done, setDone] = useState();
|
|
21
|
+
const [failure, setFailure] = useState();
|
|
22
|
+
const size = SLIDE_SIZES.find((one) => one.width === width && one.height === height);
|
|
23
|
+
const submit = (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
setFailure(undefined);
|
|
26
|
+
setDone(0);
|
|
27
|
+
void onExport({
|
|
28
|
+
slide: {
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
mode,
|
|
32
|
+
...(title ? { title } : {}),
|
|
33
|
+
...(caption ? { caption } : {}),
|
|
34
|
+
},
|
|
35
|
+
speed,
|
|
36
|
+
format,
|
|
37
|
+
fps: fps === "" ? DEFAULT_FPS[format] : Number(fps),
|
|
38
|
+
}, setDone).then(() => onClose(), (error) => {
|
|
39
|
+
setDone(undefined);
|
|
40
|
+
setFailure(error instanceof Error ? error.message : String(error));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const recording = done !== undefined;
|
|
44
|
+
return (_jsx("dialog", { className: componentCssClassName, open: true, "aria-label": "Export slide", children: _jsxs("form", { onSubmit: submit, children: [_jsxs("fieldset", { disabled: recording, children: [_jsx("legend", { children: "Export slide" }), _jsxs("label", { children: ["Size", _jsxs("select", { value: size?.name ?? "", onChange: (event) => {
|
|
45
|
+
const chosen = SLIDE_SIZES.find((one) => one.name === event.target.value);
|
|
46
|
+
if (chosen) {
|
|
47
|
+
setWidth(chosen.width);
|
|
48
|
+
setHeight(chosen.height);
|
|
49
|
+
}
|
|
50
|
+
}, children: [SLIDE_SIZES.map((one) => (_jsx("option", { value: one.name, children: `${one.name} · ${one.width} × ${one.height}` }, one.name))), _jsx("option", { value: "", children: "Other" })] })] }), _jsxs("label", { children: ["Width", _jsx("input", { type: "number", min: 2, step: 2, value: width, onChange: (event) => setWidth(Number(event.target.value)) })] }), _jsxs("label", { children: ["Height", _jsx("input", { type: "number", min: 2, step: 2, value: height, onChange: (event) => setHeight(Number(event.target.value)) })] }), _jsxs("label", { children: ["Shows", _jsxs("select", { value: mode, onChange: (event) => setMode(event.target.value), children: [_jsx("option", { value: "framed", children: "The whole figure" }), _jsx("option", { value: "bare", children: "The screen alone" })] })] }), _jsxs("label", { children: ["Title", _jsx("input", { value: title, onChange: (event) => setTitle(event.target.value) })] }), _jsxs("label", { children: ["Caption", _jsx("input", { value: caption, onChange: (event) => setCaption(event.target.value) })] }), _jsxs("label", { children: ["Speed", _jsx("input", { type: "number", min: 0.25, step: 0.25, value: speed, onChange: (event) => setSpeed(Number(event.target.value)) })] }), _jsxs("label", { children: ["File", _jsxs("select", { value: format, onChange: (event) => setFormat(event.target.value), children: [_jsx("option", { value: "mp4", children: "Video, MP4" }), _jsx("option", { value: "gif", children: "Animated GIF" })] })] }), _jsxs("label", { children: ["Pictures a second", _jsx("input", { type: "number", min: 1, max: 60, placeholder: String(DEFAULT_FPS[format]), value: fps, onChange: (event) => setFps(event.target.value) })] })] }), _jsx("p", { className: "mo-export-state", role: "status", children: recording
|
|
51
|
+
? `Recording · ${Math.round(done * 100)}%`
|
|
52
|
+
: (failure ?? "") }), _jsxs("div", { className: "mo-export-actions", children: [_jsx("button", { type: "button", onClick: onClose, disabled: recording, children: "Cancel" }), _jsx("button", { type: "submit", disabled: recording, children: "Export" })] })] }) }));
|
|
53
|
+
};
|
|
54
|
+
export default ExportSlide;
|
|
55
|
+
//# sourceMappingURL=ExportSlide.js.map
|
|
@@ -0,0 +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ACzC,SAAS;wBACR,CAAC,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG;wBAC1C,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,GACjB,EACJ,eAAK,SAAS,EAAC,mBAAmB,aAChC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,uBAElD,EACT,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,SAAS,uBAEhC,IACL,IACD,GACA,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The sizes a slide is offered at first, by name; any other can be typed in. */
|
|
2
|
+
export const SLIDE_SIZES = [
|
|
3
|
+
{ name: "4K 16:10", width: 3840, height: 2400 },
|
|
4
|
+
{ name: "4K 16:9", width: 3840, height: 2160 },
|
|
5
|
+
{ name: "1080p 16:9", width: 1920, height: 1080 },
|
|
6
|
+
{ name: "1080p 16:10", width: 1920, height: 1200 },
|
|
7
|
+
{ name: "Square", width: 2160, height: 2160 },
|
|
8
|
+
];
|
|
9
|
+
/** Pictures per second when the reader asks for none: smooth for a video, small for a GIF. */
|
|
10
|
+
export const DEFAULT_FPS = { mp4: 30, gif: 10 };
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/constants.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC/C,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC9C,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IACjD,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAClD,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;CACrC,CAAC;AAEX,8FAA8F;AAC9F,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import Context from "../../Context.js";
|
|
4
|
+
const componentCssClassName = "mo-frame-live";
|
|
5
|
+
/**
|
|
6
|
+
* One frame of a scene: the application's own components in one state, with a name the scene's steps call it
|
|
7
|
+
* by. Every frame a scene shows is on the page at once, so each has its data and its size from the start; only
|
|
8
|
+
* the frame in view shows and can be reached. A frame the scene never shows takes no room, so one set of
|
|
9
|
+
* frames can serve many scenes.
|
|
10
|
+
*
|
|
11
|
+
* `import { MotionScene } from "@canonical/react-motion-control";`
|
|
12
|
+
*/
|
|
13
|
+
const Frame = ({ name, code, className, children, ...rest }) => {
|
|
14
|
+
const scene = useContext(Context);
|
|
15
|
+
const current = scene.current === name;
|
|
16
|
+
return (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-frame": name, "data-code": code, "data-current": current ? "" : undefined, hidden: !scene.used.has(name), inert: !current, ...rest, children: children }));
|
|
17
|
+
};
|
|
18
|
+
export default Frame;
|
|
19
|
+
//# sourceMappingURL=Frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frame.js","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/Frame.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAc,EAAE,EAAE;IACzE,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAC3D,IAAI,eACL,IAAI,kBACD,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EACtC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAC7B,KAAK,EAAE,CAAC,OAAO,KACX,IAAI,YAEP,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|