@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.
Files changed (65) hide show
  1. package/README.md +193 -9
  2. package/custom-elements.json +461 -6
  3. package/package.json +26 -4
  4. package/sp-coach-indicator.d.ts +6 -0
  5. package/sp-coach-indicator.dev.js +5 -0
  6. package/sp-coach-indicator.dev.js.map +7 -0
  7. package/sp-coach-indicator.js +2 -0
  8. package/sp-coach-indicator.js.map +7 -0
  9. package/src/CoachIndicator.d.ts +12 -0
  10. package/src/CoachIndicator.dev.js +58 -0
  11. package/src/CoachIndicator.dev.js.map +7 -0
  12. package/src/CoachIndicator.js +6 -0
  13. package/src/CoachIndicator.js.map +7 -0
  14. package/src/Coachmark.d.ts +49 -4
  15. package/src/Coachmark.dev.js +261 -13
  16. package/src/Coachmark.dev.js.map +2 -2
  17. package/src/Coachmark.js +112 -5
  18. package/src/Coachmark.js.map +3 -3
  19. package/src/CoachmarkItem.d.ts +18 -0
  20. package/src/CoachmarkItem.dev.js +7 -0
  21. package/src/CoachmarkItem.dev.js.map +7 -0
  22. package/src/CoachmarkItem.js +2 -0
  23. package/src/CoachmarkItem.js.map +7 -0
  24. package/src/coach-indicator.css.d.ts +2 -0
  25. package/src/coach-indicator.css.dev.js +91 -0
  26. package/src/coach-indicator.css.dev.js.map +7 -0
  27. package/src/coach-indicator.css.js +88 -0
  28. package/src/coach-indicator.css.js.map +7 -0
  29. package/src/coachmark.css.dev.js +99 -75
  30. package/src/coachmark.css.dev.js.map +2 -2
  31. package/src/coachmark.css.js +99 -75
  32. package/src/coachmark.css.js.map +2 -2
  33. package/src/index.d.ts +2 -0
  34. package/src/index.dev.js +2 -0
  35. package/src/index.dev.js.map +2 -2
  36. package/src/index.js +1 -1
  37. package/src/index.js.map +2 -2
  38. package/src/spectrum-coach-indicator.css.d.ts +2 -0
  39. package/src/spectrum-coach-indicator.css.dev.js +91 -0
  40. package/src/spectrum-coach-indicator.css.dev.js.map +7 -0
  41. package/src/spectrum-coach-indicator.css.js +88 -0
  42. package/src/spectrum-coach-indicator.css.js.map +7 -0
  43. package/src/spectrum-coachmark.css.dev.js +97 -75
  44. package/src/spectrum-coachmark.css.dev.js.map +2 -2
  45. package/src/spectrum-coachmark.css.js +97 -75
  46. package/src/spectrum-coachmark.css.js.map +2 -2
  47. package/src/spectrum-config.js +33 -39
  48. package/stories/coach-indicator-static.stories.js +22 -0
  49. package/stories/coach-indicator-static.stories.js.map +7 -0
  50. package/stories/coach-indicator.stories.js +18 -0
  51. package/stories/coach-indicator.stories.js.map +7 -0
  52. package/stories/coachmark.stories.js +254 -8
  53. package/stories/coachmark.stories.js.map +2 -2
  54. package/stories/images.js +5 -0
  55. package/stories/images.js.map +7 -0
  56. package/test/benchmark/basic-test.js +17 -1
  57. package/test/benchmark/basic-test.js.map +2 -2
  58. package/test/coach-indicator-static.test-vrt.js +5 -0
  59. package/test/coach-indicator-static.test-vrt.js.map +7 -0
  60. package/test/coach-indicator.test-vrt.js +5 -0
  61. package/test/coach-indicator.test-vrt.js.map +7 -0
  62. package/test/coach-indicator.test.js +32 -0
  63. package/test/coach-indicator.test.js.map +7 -0
  64. package/test/coachmark.test.js +183 -6
  65. package/test/coachmark.test.js.map +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Description
2
2
 
3
- An `<sp-coachmark>` element can be used to bring added attention to specific parts of your page.
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
- ## Standard
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></sp-coachmark>
31
- <sp-coachmark variant="dark"></sp-coachmark>
32
- <sp-coachmark variant="light"></sp-coachmark>
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
- ## Quiet
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 quiet></sp-coachmark>
39
- <sp-coachmark quiet variant="dark"></sp-coachmark>
40
- <sp-coachmark quiet variant="light"></sp-coachmark>
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>