@spectrum-web-components/coachmark 0.40.5 → 0.41.1
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/README.md +193 -9
- package/custom-elements.json +461 -6
- package/package.json +26 -4
- package/sp-coach-indicator.d.ts +6 -0
- package/sp-coach-indicator.dev.js +5 -0
- package/sp-coach-indicator.dev.js.map +7 -0
- package/sp-coach-indicator.js +2 -0
- package/sp-coach-indicator.js.map +7 -0
- package/src/CoachIndicator.d.ts +12 -0
- package/src/CoachIndicator.dev.js +58 -0
- package/src/CoachIndicator.dev.js.map +7 -0
- package/src/CoachIndicator.js +6 -0
- package/src/CoachIndicator.js.map +7 -0
- package/src/Coachmark.d.ts +49 -4
- package/src/Coachmark.dev.js +261 -13
- package/src/Coachmark.dev.js.map +2 -2
- package/src/Coachmark.js +112 -5
- package/src/Coachmark.js.map +3 -3
- package/src/CoachmarkItem.d.ts +18 -0
- package/src/CoachmarkItem.dev.js +7 -0
- package/src/CoachmarkItem.dev.js.map +7 -0
- package/src/CoachmarkItem.js +2 -0
- package/src/CoachmarkItem.js.map +7 -0
- package/src/coach-indicator.css.d.ts +2 -0
- package/src/coach-indicator.css.dev.js +91 -0
- package/src/coach-indicator.css.dev.js.map +7 -0
- package/src/coach-indicator.css.js +88 -0
- package/src/coach-indicator.css.js.map +7 -0
- package/src/coachmark.css.dev.js +99 -75
- package/src/coachmark.css.dev.js.map +2 -2
- package/src/coachmark.css.js +99 -75
- package/src/coachmark.css.js.map +2 -2
- package/src/index.d.ts +2 -0
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +2 -2
- package/src/index.js +1 -1
- package/src/index.js.map +2 -2
- package/src/spectrum-coach-indicator.css.d.ts +2 -0
- package/src/spectrum-coach-indicator.css.dev.js +91 -0
- package/src/spectrum-coach-indicator.css.dev.js.map +7 -0
- package/src/spectrum-coach-indicator.css.js +88 -0
- package/src/spectrum-coach-indicator.css.js.map +7 -0
- package/src/spectrum-coachmark.css.dev.js +97 -75
- package/src/spectrum-coachmark.css.dev.js.map +2 -2
- package/src/spectrum-coachmark.css.js +97 -75
- package/src/spectrum-coachmark.css.js.map +2 -2
- package/src/spectrum-config.js +33 -39
- package/stories/coach-indicator-static.stories.js +22 -0
- package/stories/coach-indicator-static.stories.js.map +7 -0
- package/stories/coach-indicator.stories.js +18 -0
- package/stories/coach-indicator.stories.js.map +7 -0
- package/stories/coachmark.stories.js +254 -8
- package/stories/coachmark.stories.js.map +2 -2
- package/stories/images.js +5 -0
- package/stories/images.js.map +7 -0
- package/test/benchmark/basic-test.js +17 -1
- package/test/benchmark/basic-test.js.map +2 -2
- package/test/coach-indicator-static.test-vrt.js +5 -0
- package/test/coach-indicator-static.test-vrt.js.map +7 -0
- package/test/coach-indicator.test-vrt.js +5 -0
- package/test/coach-indicator.test-vrt.js.map +7 -0
- package/test/coach-indicator.test.js +32 -0
- package/test/coach-indicator.test.js.map +7 -0
- package/test/coachmark.test.js +183 -6
- package/test/coachmark.test.js.map +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Description
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`<sp-coachmark>` is a temporary message that educates users through new or unfamiliar product experiences. They can be chained into a sequence to form a tour.
|
|
4
4
|
|
|
5
5
|
### Usage
|
|
6
6
|
|
|
@@ -16,6 +16,7 @@ Import the side effectful registration of `<sp-coachmark>` via:
|
|
|
16
16
|
|
|
17
17
|
```
|
|
18
18
|
import '@spectrum-web-components/coachmark/sp-coachmark.js';
|
|
19
|
+
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
When looking to leverage the `Coachmark` base class as a type and/or for extension purposes, do so via:
|
|
@@ -24,18 +25,201 @@ When looking to leverage the `Coachmark` base class as a type and/or for extensi
|
|
|
24
25
|
import { Coachmark } from '@spectrum-web-components/coachmark';
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
##
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
## Default
|
|
31
|
+
|
|
32
|
+
Coachmark can take a `placement` and an `offset` similar to the [Overlay](https://opensource.adobe.com/spectrum-web-components/components/overlay/).
|
|
28
33
|
|
|
29
34
|
```html
|
|
30
|
-
<sp-coachmark
|
|
31
|
-
<
|
|
32
|
-
<
|
|
35
|
+
<sp-coachmark open>
|
|
36
|
+
<div slot="title">Coachmark with Text Only</div>
|
|
37
|
+
<div slot="content">
|
|
38
|
+
This is a Coachmark with nothing but text in it. Kind of lonely in here.
|
|
39
|
+
</div>
|
|
40
|
+
</sp-coachmark>
|
|
33
41
|
```
|
|
34
42
|
|
|
35
|
-
##
|
|
43
|
+
## Using Action Menu
|
|
44
|
+
|
|
45
|
+
Coach marks can include an `<sp-action-menu>`, which appears at the top right of the coach mark. The `<sp-action-menu>` should only include ways to interact with the coach mark tour as a whole, with options like “Skip tour” or “Restart tour.”
|
|
36
46
|
|
|
37
47
|
```html
|
|
38
|
-
<sp-coachmark
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
<sp-coachmark
|
|
49
|
+
open
|
|
50
|
+
current-step="2"
|
|
51
|
+
total-steps="8"
|
|
52
|
+
primary-cta="Next"
|
|
53
|
+
secondary-cta="Previous"
|
|
54
|
+
>
|
|
55
|
+
<div slot="title">Coachmark with Text Only</div>
|
|
56
|
+
<div slot="content">
|
|
57
|
+
This is a Coachmark with nothing but text in it. Kind of lonely in here.
|
|
58
|
+
</div>
|
|
59
|
+
<sp-action-menu placement="bottom-end" quiet slot="actions">
|
|
60
|
+
<sp-menu-item>Skip tour</sp-menu-item>
|
|
61
|
+
<sp-menu-item>Restart tour</sp-menu-item>
|
|
62
|
+
</sp-action-menu>
|
|
63
|
+
</sp-coachmark>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## User Action Dependent
|
|
67
|
+
|
|
68
|
+
User action-dependent coachmarks are designed to guide users based on their interactions within your application. In such cases, there is no "Next Step" button, as the coachmark progresses when the user takes a specific action. This allows users to learn by doing, rather than simply reading instructions. The coachmark remains until the user performs the required action or takes an alternative route in the tour, such as skipping, restarting, or moving back to a previous step.
|
|
69
|
+
|
|
70
|
+
Inside the `<sp-coachmark>`, add the content and instructions for the coachmark in the `<sp-coachmark>`. You can also define primary and secondary CTA buttons for user interaction.
|
|
71
|
+
|
|
72
|
+
**Event Handling:**
|
|
73
|
+
|
|
74
|
+
The primary and secondary CTA buttons within the coachmark popover can be configured to dispatch events when clicked.
|
|
75
|
+
|
|
76
|
+
```html-live
|
|
77
|
+
<sp-coachmark
|
|
78
|
+
id="coachmark-action"
|
|
79
|
+
open
|
|
80
|
+
current-step="2"
|
|
81
|
+
total-steps="8"
|
|
82
|
+
primary-cta="Asset added"
|
|
83
|
+
secondary-cta="Previous"
|
|
84
|
+
>
|
|
85
|
+
<div slot="title">Coachmark with user action</div>
|
|
86
|
+
<div slot="content">
|
|
87
|
+
This is a Coachmark with nothing but text in it. Kind of lonely in here.
|
|
88
|
+
</div>
|
|
89
|
+
<sp-action-menu placement="bottom-end" quiet slot="actions">
|
|
90
|
+
<sp-menu-item>Skip tour</sp-menu-item>
|
|
91
|
+
<sp-menu-item>Restart tour</sp-menu-item>
|
|
92
|
+
</sp-action-menu>
|
|
93
|
+
</sp-coachmark>
|
|
94
|
+
<script type="module">
|
|
95
|
+
const initCoachMark = () => {
|
|
96
|
+
const coachmark = document.querySelector('#coachmark-action');
|
|
97
|
+
coachmark.addEventListener('primary', () => console.log('primary call to action'));
|
|
98
|
+
coachmark.addEventListener('secondary', () => console.log('secondary call to action'));
|
|
99
|
+
|
|
100
|
+
};
|
|
101
|
+
customElements.whenDefined('sp-coachmark').then(() => {
|
|
102
|
+
initCoachMark();
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
41
105
|
```
|
|
106
|
+
|
|
107
|
+
<script type="module">
|
|
108
|
+
const initCoachMark = () => {
|
|
109
|
+
const coachmark = document.querySelector('#coachmark-action');
|
|
110
|
+
coachmark.addEventListener('primary', () => console.log('primary call to action'));
|
|
111
|
+
coachmark.addEventListener('secondary', () => console.log('secondary call to action'));
|
|
112
|
+
};
|
|
113
|
+
customElements.whenDefined('sp-coachmark').then(() => {
|
|
114
|
+
initCoachMark();
|
|
115
|
+
});
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
## Using Images, GIFs
|
|
119
|
+
|
|
120
|
+
Coach marks can contain images or videos that relate to their content, such as demonstrations of gestures, the feature being used, or illustrations.
|
|
121
|
+
To use these kinds of media in your rich tooltip, specify a `src`, the type of media, either by using the string or `media-type` object, and
|
|
122
|
+
an optional `imageAlt` text describing the content.
|
|
123
|
+
|
|
124
|
+
Media Types allowed: `Images & Gifs`
|
|
125
|
+
|
|
126
|
+
### Image
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<sp-coachmark
|
|
130
|
+
current-step="2"
|
|
131
|
+
total-steps="8"
|
|
132
|
+
open
|
|
133
|
+
primary-cta="Next"
|
|
134
|
+
secondary-cta="Previous"
|
|
135
|
+
src="https://picsum.photos/id/237/200/300"
|
|
136
|
+
media-type="image"
|
|
137
|
+
>
|
|
138
|
+
<div slot="title">Coachmark with 16:9 image</div>
|
|
139
|
+
<div slot="content">This is a Coachmark with some description</div>
|
|
140
|
+
<sp-action-menu placement="bottom-end" quiet slot="actions">
|
|
141
|
+
<sp-menu-item>Skip tour</sp-menu-item>
|
|
142
|
+
<sp-menu-item>Restart tour</sp-menu-item>
|
|
143
|
+
</sp-action-menu>
|
|
144
|
+
</sp-coachmark>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Custom Image/Gif
|
|
148
|
+
|
|
149
|
+
A custom media can also be added via `<slot name="cover-photo"></slot>`
|
|
150
|
+
|
|
151
|
+
```html
|
|
152
|
+
<sp-coachmark
|
|
153
|
+
current-step="2"
|
|
154
|
+
total-steps="8"
|
|
155
|
+
open
|
|
156
|
+
primary-cta="Next"
|
|
157
|
+
secondary-cta="Previous"
|
|
158
|
+
>
|
|
159
|
+
<div slot="title">Coachmark with 16:9 image</div>
|
|
160
|
+
<div slot="content">This is a Coachmark with some description</div>
|
|
161
|
+
<img slot="asset" src="https://picsum.photos/id/237/200/300" alt="" />
|
|
162
|
+
<sp-action-menu placement="bottom-end" quiet slot="actions">
|
|
163
|
+
<sp-menu-item>Skip tour</sp-menu-item>
|
|
164
|
+
<sp-menu-item>Restart tour</sp-menu-item>
|
|
165
|
+
</sp-action-menu>
|
|
166
|
+
</sp-coachmark>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Shortcut keys and modifier keys
|
|
170
|
+
|
|
171
|
+
Shortcut keys and modifier keys are ways to show users how to trigger a particular tool.
|
|
172
|
+
|
|
173
|
+
The `shortcutKey` is the primary key used to trigger an interaction and are typically an alphanumeric value (and thus will be rendered as an uppercase character), while the
|
|
174
|
+
`modifierKeys` are an array of `string`s that represent alternate keys that can be pressed, like `Shift`, `Alt`, `Cmd`, etc.
|
|
175
|
+
|
|
176
|
+
```html-live
|
|
177
|
+
<sp-coachmark
|
|
178
|
+
open
|
|
179
|
+
current-step="2"
|
|
180
|
+
total-steps="8"
|
|
181
|
+
primary-cta="Next"
|
|
182
|
+
secondary-cta="Previous"
|
|
183
|
+
id="coachmark-keys"
|
|
184
|
+
>
|
|
185
|
+
<sp-action-menu placement="bottom-end" quiet slot="actions">
|
|
186
|
+
<sp-menu-item>Skip tour</sp-menu-item>
|
|
187
|
+
<sp-menu-item>Restart tour</sp-menu-item>
|
|
188
|
+
</sp-action-menu>
|
|
189
|
+
</sp-coachmark>
|
|
190
|
+
<script type="module">
|
|
191
|
+
const initCoachMark = () => {
|
|
192
|
+
const coachmark = document.querySelector('#coachmark-keys');
|
|
193
|
+
const modifierKeys = ['⇧ Shift', '⌘'];
|
|
194
|
+
const content = {
|
|
195
|
+
title: 'I am a Coachmark with keys',
|
|
196
|
+
description: 'This is a Coachmark with nothing but text in it.'
|
|
197
|
+
};
|
|
198
|
+
coachmark.content= content
|
|
199
|
+
coachmark.modifierKeys = modifierKeys
|
|
200
|
+
};
|
|
201
|
+
customElements.whenDefined('code-example').then(() => {
|
|
202
|
+
customElements.whenDefined('sp-coachmark').then(() => {
|
|
203
|
+
initCoachMark();
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
</script>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
<script type="module">
|
|
210
|
+
const initCoachMark = () => {
|
|
211
|
+
const coachmark = document.querySelector('#coachmark-keys');
|
|
212
|
+
const modifierKeys = ['⇧ Shift', '⌘'];
|
|
213
|
+
const content = {
|
|
214
|
+
title: 'I am a Coachmark with keys',
|
|
215
|
+
description: 'This is a Coachmark with nothing but text in it.'
|
|
216
|
+
};
|
|
217
|
+
coachmark.content= content
|
|
218
|
+
coachmark.modifierKeys = modifierKeys
|
|
219
|
+
};
|
|
220
|
+
customElements.whenDefined('code-example').then(() => {
|
|
221
|
+
customElements.whenDefined('sp-coachmark').then(() => {
|
|
222
|
+
initCoachMark();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
</script>
|