@splendidlabz/svelte 0.4.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.
Files changed (153) hide show
  1. package/.eslintrc.cjs +3 -0
  2. package/CHANGELOG.md +91 -0
  3. package/actions/breakpoint-observer.js +71 -0
  4. package/actions/index.js +6 -0
  5. package/actions/portal.js +20 -0
  6. package/actions/resize-observer.js +43 -0
  7. package/actions/scroll-observer.js +47 -0
  8. package/common.js +21 -0
  9. package/components/Accordion/Accordion.svelte +108 -0
  10. package/components/Accordion/index.js +3 -0
  11. package/components/Breadcrumbs/Breadcrumbs.svelte +69 -0
  12. package/components/Breadcrumbs/Crumb.svelte +37 -0
  13. package/components/Breadcrumbs/CrumbCustom.svelte +14 -0
  14. package/components/Breadcrumbs/index.js +5 -0
  15. package/components/BrowserFrame.svelte +37 -0
  16. package/components/BrowserWithTabs.svelte +28 -0
  17. package/components/CQChecker/CQChecker.astro +20 -0
  18. package/components/CQChecker/CQChecker.svelte +89 -0
  19. package/components/Callout/Callout.svelte +17 -0
  20. package/components/Callout/index.js +3 -0
  21. package/components/Codepen/Codepen.astro +29 -0
  22. package/components/Codepen/Codepen.svelte +24 -0
  23. package/components/Codepen/index.js +3 -0
  24. package/components/ContentList/ContentList-old.svelte +117 -0
  25. package/components/ContentList/ContentList.svelte +68 -0
  26. package/components/ContentList/index.js +3 -0
  27. package/components/Disclosure/Drawer/Drawer.svelte +35 -0
  28. package/components/Disclosure/Drawer/DrawerCloseButton.svelte +31 -0
  29. package/components/Disclosure/Drawer/DrawerContent-wrecked.svelte +198 -0
  30. package/components/Disclosure/Drawer/DrawerContent.svelte +164 -0
  31. package/components/Disclosure/Drawer/DrawerTrigger.svelte +32 -0
  32. package/components/Disclosure/Drawer/drawer.js +112 -0
  33. package/components/Disclosure/Drawer/index.js +6 -0
  34. package/components/Disclosure/Dropdown/DropdownContent.svelte +15 -0
  35. package/components/Disclosure/Dropdown/DropdownTrigger.svelte +14 -0
  36. package/components/Disclosure/Dropdown/dropdown.js +4 -0
  37. package/components/Disclosure/Dropdown/index.js +4 -0
  38. package/components/Disclosure/Modal/ModalContent.svelte +3 -0
  39. package/components/Disclosure/Modal/ModalTrigger.svelte +33 -0
  40. package/components/Disclosure/Modal/exit-intent.js +17 -0
  41. package/components/Disclosure/Modal/modal.js +13 -0
  42. package/components/Disclosure/Popover/PopoverCloseButton.svelte +29 -0
  43. package/components/Disclosure/Popover/PopoverContent.svelte +107 -0
  44. package/components/Disclosure/Popover/PopoverTrigger.svelte +33 -0
  45. package/components/Disclosure/Popover/floating.js +171 -0
  46. package/components/Disclosure/Popover/index.js +5 -0
  47. package/components/Disclosure/Popover/popover.js +18 -0
  48. package/components/Disclosure/Popover/references/FollowTheMouse.svelte +45 -0
  49. package/components/Disclosure/Tooltip/Tooltip.svelte +14 -0
  50. package/components/Disclosure/Tooltip/TooltipContent.svelte +7 -0
  51. package/components/Disclosure/Tooltip/TooltipTrigger.svelte +33 -0
  52. package/components/Disclosure/Tooltip/index.js +5 -0
  53. package/components/Disclosure/Tooltip/tooltip.js +22 -0
  54. package/components/Disclosure/disclosure-store.js +48 -0
  55. package/components/Disclosure/disclosure.js +439 -0
  56. package/components/Disclosure/index.js +3 -0
  57. package/components/Disclosure/state.svelte.js +138 -0
  58. package/components/FancyList/FancyList.svelte +49 -0
  59. package/components/FancyList/index.js +3 -0
  60. package/components/Form/Button.svelte +24 -0
  61. package/components/Form/Checkbox.svelte +80 -0
  62. package/components/Form/Checkboxes.svelte +48 -0
  63. package/components/Form/Combobox/AutocompleteInput.svelte +63 -0
  64. package/components/Form/Combobox/AutocompleteOptions.svelte +74 -0
  65. package/components/Form/Combobox/TimepickerInput.svelte +81 -0
  66. package/components/Form/Combobox/TimepickerOptions.svelte +100 -0
  67. package/components/Form/Combobox/autocomplete-matching.js +114 -0
  68. package/components/Form/Combobox/autocomplete.js +393 -0
  69. package/components/Form/Combobox/combobox-store.js +65 -0
  70. package/components/Form/Combobox/combobox.js +359 -0
  71. package/components/Form/Combobox/index.js +14 -0
  72. package/components/Form/Combobox/timepicker.js +119 -0
  73. package/components/Form/Form.svelte +62 -0
  74. package/components/Form/Hidden.svelte +16 -0
  75. package/components/Form/Radio.svelte +69 -0
  76. package/components/Form/Radios.svelte +50 -0
  77. package/components/Form/Select.svelte +127 -0
  78. package/components/Form/Switch.svelte +50 -0
  79. package/components/Form/TextInput.svelte +87 -0
  80. package/components/Form/Textarea.svelte +103 -0
  81. package/components/Form/check.svg +3 -0
  82. package/components/Form/index.js +12 -0
  83. package/components/Highlight/Highlight.svelte +27 -0
  84. package/components/Highlight/_Highlight.scss +19 -0
  85. package/components/Highlight/index.js +2 -0
  86. package/components/Image.svelte +24 -0
  87. package/components/InteractiveRegion/InteractiveRegion.svelte +47 -0
  88. package/components/InteractiveRegion/index.js +3 -0
  89. package/components/List/Lia.svelte +12 -0
  90. package/components/List/NestedListItem.svelte +50 -0
  91. package/components/List/index.js +3 -0
  92. package/components/Markdown/Markdown.svelte +35 -0
  93. package/components/Masonry/Masonry.svelte +79 -0
  94. package/components/Masonry/index.js +3 -0
  95. package/components/PerspectiveHover/PerspectiveHover.svelte +10 -0
  96. package/components/PerspectiveHover/perspective-hover.js +46 -0
  97. package/components/Populate/ConditionalPopulate.svelte +33 -0
  98. package/components/Populate/Populate.svelte +45 -0
  99. package/components/Populate/actions.js +29 -0
  100. package/components/Populate/get-value.js +17 -0
  101. package/components/Populate/index.js +4 -0
  102. package/components/Portal.svelte +27 -0
  103. package/components/PushToLocalStorage.svelte +30 -0
  104. package/components/Resizer/Resizer.svelte +32 -0
  105. package/components/Resizer/draggable.js +23 -0
  106. package/components/Resizer/index.js +3 -0
  107. package/components/Resizer/resizer.js +133 -0
  108. package/components/SVG/SVG.svelte +120 -0
  109. package/components/Scrambler/Scrambler.svelte +27 -0
  110. package/components/Scrambler/index.js +3 -0
  111. package/components/Spotlight/PointerPosition.js +32 -0
  112. package/components/Spotlight/Spotlight.svelte +9 -0
  113. package/components/Status.svelte +27 -0
  114. package/components/Switcheroo/Switcheroo.svelte +71 -0
  115. package/components/Switcheroo/index.js +3 -0
  116. package/components/Table/RowGroup.svelte +8 -0
  117. package/components/Table/Table.svelte +23 -0
  118. package/components/Table/Td.svelte +20 -0
  119. package/components/Table/Th.svelte +27 -0
  120. package/components/Table/Thead.svelte +8 -0
  121. package/components/Table/Tr.svelte +8 -0
  122. package/components/Table/index.js +17 -0
  123. package/components/Table/table.js +35 -0
  124. package/components/Tabs/Tab.svelte +12 -0
  125. package/components/Tabs/Tablist.svelte +62 -0
  126. package/components/Tabs/Tabpanel.svelte +10 -0
  127. package/components/Tabs/Tabpanels.svelte +12 -0
  128. package/components/Tabs/index.js +6 -0
  129. package/components/Tabs/tab-store.js +60 -0
  130. package/components/Tabs/tabs.js +364 -0
  131. package/components/Tabs-Old/Tab.svelte +9 -0
  132. package/components/Tabs-Old/Tablist.svelte +13 -0
  133. package/components/Tabs-Old/Tabpanel.svelte +10 -0
  134. package/components/Tabs-Old/Tabpanels.svelte +14 -0
  135. package/components/Tabs-Old/Tabs.svelte +83 -0
  136. package/components/Tabs-Old/index.js +7 -0
  137. package/components/Tabs-Old/tabs.js +306 -0
  138. package/components/Textwall/Repeat.svelte +10 -0
  139. package/components/Textwall/Textwall.svelte +30 -0
  140. package/components/Textwall/index.js +4 -0
  141. package/components/Typewriter/Typewriter.svelte +70 -0
  142. package/components/Typewriter/index.js +3 -0
  143. package/components/Video.svelte +46 -0
  144. package/components/Vimeo.svelte +18 -0
  145. package/components/Wrapper.svelte +22 -0
  146. package/components/Youtube.svelte +15 -0
  147. package/components/_shared/accessibility.js +9 -0
  148. package/components/_shared/key.js +1 -0
  149. package/components/_shared/transitions.js +48 -0
  150. package/components/_shared/use-actions.js +31 -0
  151. package/index.js +35 -0
  152. package/jsconfig.json +5 -0
  153. package/package.json +39 -0
@@ -0,0 +1,306 @@
1
+ export default function createTabs({
2
+ activeTab = 0,
3
+ orientation = 'horizontal',
4
+ placement = 'left',
5
+ mode = 'tab',
6
+ breakpoints = null,
7
+ scrollBehaviour = 'auto',
8
+ }) {
9
+ // Structure of _Tabs
10
+ // { tab: HTMLElement, panel: HTMLElement, id }
11
+ let tabsNode = null
12
+ const _tabs = []
13
+
14
+ let state = {
15
+ activeTab: 0,
16
+ orientation,
17
+ placement,
18
+ mode,
19
+ curentStructure: mode,
20
+ shouldFocus: false, // What is this?!
21
+ }
22
+
23
+ state = new Proxy(state, {
24
+ get(target, prop) {
25
+ return Reflect.get(...arguments)
26
+ },
27
+
28
+ set(target, prop) {
29
+ Reflect.set(...arguments)
30
+ if (prop === 'activeTab') {
31
+ toIndexSystem()
32
+ setActiveTab()
33
+ setActivePanel()
34
+ dispatchChange()
35
+ }
36
+
37
+ if (prop === 'mode') {
38
+ // Maybe detect if the value has changed if possible. Cos if it didn't change then no need to do anything here. One way is ta add a currentStructure into the state.
39
+ const value = target[prop]
40
+ if (value === 'tab') toTab()
41
+ if (value === 'accordion') toAccordion()
42
+ }
43
+ return true
44
+ },
45
+ })
46
+
47
+ // Initial Setup
48
+ updateTabStructure({ orientation, placement, mode })
49
+
50
+ // ========================
51
+ // Public API
52
+ // ========================
53
+ function tabs(node) {
54
+ tabsNode = node
55
+ }
56
+
57
+ function tablist(node) {
58
+ const tabs = Array.from(node.querySelectorAll('[role="tab"]'))
59
+
60
+ tabs.forEach((tab, index) => {
61
+ const slot = _tabs[index] || {}
62
+ if (slot) _tabs[index] = { ...slot, tab, index }
63
+ if (!slot) tabs.push({ tab })
64
+ })
65
+
66
+ // Add Event Listeners
67
+ node.addEventListener('click', handleClick)
68
+ node.addEventListener('keydown', handleKeyboard)
69
+
70
+ initializeActiveTab()
71
+
72
+ return {
73
+ destroy() {
74
+ node.removeEventListener('click', handleClick)
75
+ node.removeEventListener('keydown', handleKeyboard)
76
+ },
77
+ }
78
+ }
79
+
80
+ function tabpanels(node) {
81
+ const panels = Array.from(node.querySelectorAll('[role="tabpanel"]'))
82
+
83
+ panels.forEach((panel, index) => {
84
+ const slot = _tabs[index] || {}
85
+ if (slot) _tabs[index] = { ...slot, panel, target: panel.id }
86
+ if (!slot) tabs.push({ panel, target: panel.id })
87
+ })
88
+
89
+ initializeActiveTab()
90
+
91
+ node.addEventListener('keydown', handleKeyboardInTabpanel)
92
+ window.addEventListener('hashchange', initializeActiveTab)
93
+
94
+ return {
95
+ destroy() {
96
+ node.removeEventListener('keydown', handleKeyboardInTabpanel)
97
+ window.removeEventListener('hashchange', initializeActiveTab)
98
+ },
99
+ }
100
+ }
101
+
102
+ // ========================
103
+ // Internal API
104
+ // ========================
105
+
106
+ // Initialize to what the user provided.
107
+ // But if the URL contains the #id of the tabpanel then we initialize to that tabpanel instead.
108
+ function initializeActiveTab() {
109
+ state.activeTab = getInitialActiveTab()
110
+
111
+ const { hash } = window.location
112
+ if (hash) return scrollToTab(hash)
113
+ }
114
+
115
+ // Base the active tab according to the 'active' attribute placed in tabs
116
+ function getInitialActiveTab() {
117
+ const activeTabRef = _tabs.findIndex(
118
+ ({ tab }) => tab.getAttribute('aria-selected') === 'true',
119
+ )
120
+
121
+ if (activeTabRef >= 0) return activeTabRef
122
+ return activeTab // Returns the user defined activeTab in properties if 'aria-selected' is not found in the tabs
123
+ }
124
+
125
+ function scrollToTab(hash) {
126
+ const target = _tabs.find(item => {
127
+ return `#${item.target}` === hash
128
+ })
129
+ if (!target) return
130
+
131
+ // Set the active tab.
132
+ state.activeTab = target.index
133
+
134
+ // Scroll user to the Tabs component instead of the Tabpanel — so users can still see the Tabs.
135
+ target.tab.parentElement?.parentElement?.scrollIntoView({
136
+ behavior: scrollBehaviour,
137
+ })
138
+ }
139
+
140
+ function toIndexSystem() {
141
+ if (typeof state.activeTab === 'number') return
142
+ const activeIndex = _tabs.findIndex(tab => {
143
+ return tab.target === state.activeTab
144
+ })
145
+ state.activeTab = activeIndex
146
+ }
147
+
148
+ function isActiveTab(index) {
149
+ if (typeof state.activeTab === 'number') {
150
+ return state.activeTab === index
151
+ }
152
+ }
153
+
154
+ function setActiveTab() {
155
+ _tabs.forEach((item, index) => {
156
+ const { tab } = item
157
+ if (isActiveTab(index)) {
158
+ tab.setAttribute('aria-selected', 'true')
159
+ tab.setAttribute('tabindex', '0')
160
+
161
+ if (state.shouldFocus) tab.focus()
162
+ } else {
163
+ tab.removeAttribute('aria-selected')
164
+ tab.setAttribute('tabindex', '-1')
165
+ }
166
+ })
167
+ }
168
+
169
+ function setActivePanel() {
170
+ _tabs.forEach((item, index) => {
171
+ const { panel } = item
172
+ if (!panel) return // Because they may not have initialized yet
173
+ if (isActiveTab(index)) {
174
+ panel.removeAttribute('hidden')
175
+ panel.setAttribute('tabindex', '0')
176
+ } else {
177
+ panel.setAttribute('hidden', 'true')
178
+ panel.removeAttribute('tabindex')
179
+ }
180
+ })
181
+ }
182
+
183
+ function dispatchChange() {
184
+ if (!tabsNode) return
185
+ const { activeTab, orientation, placement, mode } = state
186
+ const event = new CustomEvent('change', {
187
+ detail: {
188
+ activeTab,
189
+ activeTabNode: _tabs[activeTab].tab,
190
+ orientation,
191
+ placement,
192
+ mode,
193
+ },
194
+ })
195
+
196
+ tabsNode.dispatchEvent(event)
197
+ }
198
+
199
+ function activatePrevTab() {
200
+ if (state.activeTab > 0) {
201
+ state.shouldFocus = true
202
+ state.activeTab = state.activeTab - 1
203
+ }
204
+ }
205
+
206
+ function activateNextTab() {
207
+ if (state.activeTab < _tabs.length - 1) {
208
+ state.shouldFocus = true
209
+ state.activeTab = state.activeTab + 1
210
+ }
211
+ }
212
+
213
+ function focusTab() {
214
+ const activeTab = _tabs[state.activeTab]
215
+ const { tab } = activeTab
216
+ tab.focus()
217
+ }
218
+
219
+ function focusTabpanel() {
220
+ const activeTab = _tabs[state.activeTab]
221
+ const { panel } = activeTab
222
+ panel.focus()
223
+ }
224
+
225
+ function updateTabStructure(structure) {
226
+ const { placement, orientation, mode } = structure
227
+
228
+ if (orientation !== 'horizontal' && orientation !== 'vertical') {
229
+ throw new Error(
230
+ `The orientation must be either "horizontal" or "vertical". You passed: ${orientation}`,
231
+ )
232
+ }
233
+
234
+ if (placement !== 'left' && placement !== 'right') {
235
+ throw new Error(
236
+ `The placement must be either "left" or "right". You passed: ${placement}`,
237
+ )
238
+ }
239
+
240
+ if (mode !== 'tab' && mode !== 'accordion') {
241
+ throw new Error(
242
+ `The mode must be either "tab" or "accordion". You passed: ${mode}`,
243
+ )
244
+ }
245
+
246
+ state.orientation = orientation
247
+ state.placement = placement
248
+ state.mode = mode
249
+ }
250
+
251
+ function toTab() {
252
+ // if (state.currentStructure === 'tab') return
253
+ }
254
+
255
+ function toAccordion() {
256
+ // if (state.currentStructure === 'accordion') return
257
+ }
258
+
259
+ // ========================
260
+ // Event Handlers
261
+ // ========================
262
+ function handleClick(event) {
263
+ const tab = event.target.closest('[role="tab"]')
264
+ const item = _tabs.find(item => item.tab === tab)
265
+ if (!item) return
266
+
267
+ state.shouldFocus = true
268
+ state.activeTab = item.index
269
+ }
270
+
271
+ function handleKeyboard(event) {
272
+ if (state.orientation === 'horizontal') {
273
+ if (event.key === 'ArrowLeft') activatePrevTab()
274
+ if (event.key === 'ArrowRight') activateNextTab()
275
+ if (event.key === 'ArrowDown') focusTabpanel()
276
+ }
277
+
278
+ if (state.orientation === 'vertical') {
279
+ if (event.key === 'ArrowUp') activatePrevTab()
280
+ if (event.key === 'ArrowDown') activateNextTab()
281
+
282
+ if (placement === 'left' && event.key === 'ArrowRight') focusTabpanel()
283
+ if (placement === 'right' && event.key === 'ArrowLeft') focusTabpanel()
284
+ }
285
+ }
286
+
287
+ function handleKeyboardInTabpanel(event) {
288
+ if (state.orientation === 'horizontal') {
289
+ if (event.key === 'ArrowUp') focusTab()
290
+ }
291
+
292
+ if (state.orientation === 'vertical') {
293
+ if (placement === 'left' && event.key === 'ArrowLeft') focusTab()
294
+ if (placement === 'right' && event.key === 'ArrowRight') focusTab()
295
+ }
296
+ }
297
+
298
+ return {
299
+ tabs,
300
+ tablist,
301
+ tabpanels,
302
+ updateTabStructure,
303
+ activateNextTab,
304
+ activatePrevTab,
305
+ }
306
+ }
@@ -0,0 +1,10 @@
1
+ <script>
2
+ export let times = 1
3
+ let ariaHidden = $$restProps['aria-hidden']
4
+ </script>
5
+
6
+ <div aria-hidden={ariaHidden}>
7
+ {#each Array.from({ length: times }) as time}
8
+ <slot />
9
+ {/each}
10
+ </div>
@@ -0,0 +1,30 @@
1
+ <script>
2
+ import Repeat from './Repeat.svelte'
3
+
4
+ let klass = ''
5
+ export { klass as class }
6
+ export let contentClass
7
+ export let repeat = 100
8
+
9
+ let ariaLabel = $$restProps['aria-label']
10
+
11
+ if (!ariaLabel) throw new Error('aria-label is required for text wall')
12
+ </script>
13
+
14
+ <!-- Have to see the Splendid Docs Landing for usage! -->
15
+ <div class="Textwall {klass}" aria-label={ariaLabel}>
16
+ <div class="Stack">
17
+ <div class="TextwallBoundary-before Pos-top Foreground">
18
+ <slot name="before" />
19
+ </div>
20
+ <div class="Stack overflow-hidden">
21
+ <div class="TextwallDimensions"></div>
22
+ <div class="TextwallContent {contentClass}">
23
+ <Repeat aria-hidden times={repeat}><slot /></Repeat>
24
+ </div>
25
+ </div>
26
+ <div class="TextwallBoundary-after Pos-bottom Foreground">
27
+ <slot name="after" />
28
+ </div>
29
+ </div>
30
+ </div>
@@ -0,0 +1,4 @@
1
+ import Repeat from './Repeat.svelte'
2
+ import Textwall from './Textwall.svelte'
3
+
4
+ export { Textwall, Repeat }
@@ -0,0 +1,70 @@
1
+ <script>
2
+ import { onMount } from 'svelte'
3
+
4
+ let klass = ''
5
+ export { klass as class }
6
+ export let options = {}
7
+ export let content = []
8
+
9
+ const defaultOoptions = {
10
+ deleteSpeed: 25, // ms
11
+ writeSpeed: 35, // ms
12
+ pauseBeforeWriting: 250, // ms
13
+ pauseBeforeDeleting: 1000, // ms
14
+ }
15
+
16
+ const { deleteSpeed, writeSpeed, pauseBeforeWriting, pauseBeforeDeleting } = {
17
+ ...defaultOoptions,
18
+ ...options,
19
+ }
20
+
21
+ let phase = 0
22
+ let contentToDisplay = content[phase]
23
+ let displayedContent = contentToDisplay // Initial value
24
+
25
+ onMount(() => {
26
+ backspaceEffect()
27
+ })
28
+
29
+ function backspaceEffect() {
30
+ // If there are any characters left to remove, remove them
31
+ if (displayedContent.length) {
32
+ setTimeout(() => {
33
+ displayedContent = displayedContent.slice(0, -1)
34
+ backspaceEffect()
35
+ }, deleteSpeed)
36
+ } else {
37
+ // If there are no characters left to remove, we begin writing characters, but after a delay.
38
+ setTimeout(() => {
39
+ // Get the right set of words to display
40
+ phase += 1
41
+ if (!content[phase]) phase = 0
42
+ contentToDisplay = content[phase]
43
+
44
+ writeEffect()
45
+ }, pauseBeforeWriting)
46
+ }
47
+ }
48
+
49
+ function writeEffect() {
50
+ setTimeout(_ => {
51
+ const index = displayedContent.length || 0
52
+ displayedContent = displayedContent + contentToDisplay[index]
53
+
54
+ // Write until we've written all the characters
55
+ if (displayedContent.length !== contentToDisplay.length) {
56
+ writeEffect()
57
+ return
58
+ }
59
+
60
+ // Pause for a bit before we start backspacing
61
+ setTimeout(_ => {
62
+ backspaceEffect()
63
+ }, pauseBeforeDeleting)
64
+ }, writeSpeed)
65
+ }
66
+ </script>
67
+
68
+ <span class="Typewriter {klass}">
69
+ {displayedContent}
70
+ </span>
@@ -0,0 +1,3 @@
1
+ import Typewriter from './Typewriter.svelte'
2
+
3
+ export { Typewriter }
@@ -0,0 +1,46 @@
1
+ <script>
2
+ let klass = ''
3
+ export { klass as class }
4
+ export let src, alt, gifReplacement, caption
5
+
6
+ let props = {
7
+ playsinline: true,
8
+ controls: true,
9
+ ...$$restProps,
10
+ }
11
+
12
+ // This will be a Gif replacement instead of an actual video
13
+ // so we change video properties to match its use case.
14
+ if (gifReplacement) {
15
+ props = {
16
+ ...props,
17
+ autoplay: true,
18
+ loop: true,
19
+ muted: true,
20
+ controls: false,
21
+ }
22
+ }
23
+ </script>
24
+
25
+ {#if caption}
26
+ <figure class={klass} aria-label={caption}>
27
+ <!-- svelte-ignore a11y-media-has-caption -->
28
+ <video {...props}>
29
+ <source {src} type="video/mp4" />
30
+ {alt}. Your browser doesn't support the HTML video element. Click
31
+ <a href={src}>this link</a>
32
+ to watch the video.
33
+ </video>
34
+ <figcaption aria-hidden>{caption}</figcaption>
35
+ </figure>
36
+ {/if}
37
+
38
+ {#if !caption}
39
+ <!-- svelte-ignore a11y-media-has-caption -->
40
+ <video class={klass} {...props}>
41
+ <source {src} type="video/mp4" />
42
+ {alt}. Your browser doesn't support the HTML video element. Click
43
+ <a href={src}>this link</a>
44
+ to watch the video.
45
+ </video>
46
+ {/if}
@@ -0,0 +1,18 @@
1
+ <script>
2
+ let klass = ''
3
+ export { klass as class }
4
+ export let title, id, hash
5
+
6
+ let src = `https://player.vimeo.com/video/${id}`
7
+ if (hash) src += `?h=${hash}`
8
+ </script>
9
+
10
+ <div class={`Vimeo ${klass}`}>
11
+ <iframe
12
+ {src}
13
+ {title}
14
+ allowfullscreen
15
+ frameborder="0"
16
+ allow="autoplay; fullscreen; picture-in-picture"
17
+ />
18
+ </div>
@@ -0,0 +1,22 @@
1
+ <script>
2
+ export let condition = false
3
+ export let tag = ''
4
+ export let component = ''
5
+ </script>
6
+
7
+ <!-- Wraps with a component -->
8
+ {#if condition && component}
9
+ <svelte:component this={component} {...$$restProps} />
10
+ {/if}
11
+
12
+ <!-- Wraps with a tag -->
13
+ {#if condition && tag}
14
+ <svelte:element this={tag} {...$$restProps}>
15
+ <slot />
16
+ </svelte:element>
17
+ {/if}
18
+
19
+ <!-- No wrap -->
20
+ {#if !condition}
21
+ <slot />
22
+ {/if}
@@ -0,0 +1,15 @@
1
+ <script>
2
+ export let id, title
3
+ const link = `https://www.youtube.com/embed/${id}`
4
+ </script>
5
+
6
+ <!-- IMPROVE: Not sure if height and width is needed -->
7
+ <div class="Youtube">
8
+ <iframe
9
+ src={link}
10
+ {title}
11
+ frameborder="0"
12
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
13
+ allowfullscreen
14
+ />
15
+ </div>
@@ -0,0 +1,9 @@
1
+ export function hasLabel(label, labelledBy) {
2
+ if (label || labelledBy) return true
3
+ }
4
+
5
+ export function isInvalidAriaPopup(value) {
6
+ const allowedPopoupValues = ['dialog', 'menu', 'listbox', 'grid', 'tree']
7
+ if (!allowedPopoupValues.includes(value)) return true
8
+ return false
9
+ }
@@ -0,0 +1 @@
1
+ export const key = Symbol('key')
@@ -0,0 +1,48 @@
1
+ import * as eFns from 'svelte/easing'
2
+ import * as tFns from 'svelte/transition'
3
+
4
+ export const DEFAULT_TRANSITION_OPTS = {
5
+ transition: 'fade',
6
+ easing: 'easeInOut',
7
+ duration: 300,
8
+ delay: 0,
9
+ }
10
+
11
+ const BUILT_IN_TRANSITIONS = [
12
+ 'fade',
13
+ 'blur',
14
+ 'fly',
15
+ 'slide',
16
+ 'scale',
17
+ 'draw',
18
+ 'crossfade',
19
+ ]
20
+
21
+ export function transit(node, params) {
22
+ const opts = { ...DEFAULT_TRANSITION_OPTS, ...params }
23
+ const { easing, transition, ...rest } = opts
24
+
25
+ const e = eFns[easing]
26
+
27
+ if (BUILT_IN_TRANSITIONS.includes(transition)) {
28
+ const t = tFns[transition]
29
+ return t(node, {
30
+ ...rest,
31
+ easing: e,
32
+ axis: getAxis(params.placement),
33
+ })
34
+ }
35
+
36
+ if (typeof transition === 'function') {
37
+ return transition(node, {
38
+ ...rest,
39
+ easing: e,
40
+ })
41
+ }
42
+ }
43
+
44
+ function getAxis(placement) {
45
+ if (!placement) return 'y'
46
+ if (placement === 'top' || placement === 'bottom') return 'y'
47
+ if (placement === 'left' || placement === 'right') return 'x'
48
+ }
@@ -0,0 +1,31 @@
1
+ // Grabbed from https://github.com/radiofrance/svelte-component-actions/tree/main
2
+ export function useActions(node, actions) {
3
+ if (!actions) return
4
+
5
+ const actionReturns = actions.map(actionEntry => {
6
+ const [action, params] = Array.isArray(actionEntry)
7
+ ? actionEntry
8
+ : [actionEntry]
9
+ return action(node, params)
10
+ })
11
+
12
+ return {
13
+ update(newActions) {
14
+ if (!newActions || newActions.length !== actionReturns.length) {
15
+ throw new Error('You must not change the length of an actions array.')
16
+ }
17
+ newActions.forEach((actionEntry, i) => {
18
+ const returnEntry = actionReturns[i]
19
+ const [, params] = Array.isArray(actionEntry)
20
+ ? actionEntry
21
+ : [actionEntry]
22
+ returnEntry?.update?.(params)
23
+ })
24
+ },
25
+ destroy() {
26
+ actionReturns.forEach(returnEntry => {
27
+ returnEntry?.destroy?.()
28
+ })
29
+ },
30
+ }
31
+ }
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ export * from './components/Accordion/index.js'
2
+ export * from './components/Breadcrumbs/index.js'
3
+ export * from './components/Callout/index.js'
4
+ export * from './components/Codepen/index.js'
5
+ export * from './components/ContentList/index.js'
6
+ export * from './components/Disclosure/index.js'
7
+ export * from './components/FancyList/index.js'
8
+ export * from './components/Form/index.js'
9
+ export * from './components/Highlight/index.js'
10
+ export * from './components/InteractiveRegion/index.js'
11
+ export * from './components/List/index.js'
12
+ export * from './components/Masonry/index.js'
13
+ export * from './components/Populate/index.js'
14
+ export * from './components/Resizer/index.js'
15
+ export * from './components/Scrambler/index.js'
16
+ export * from './components/Switcheroo/index.js'
17
+ export * from './components/Table/index.js'
18
+ export * from './components/Tabs/index.js'
19
+ export * from './components/Textwall/index.js'
20
+ export * from './components/Typewriter/index.js'
21
+
22
+ export { default as BrowserFrame } from './components/BrowserFrame.svelte'
23
+ export { default as BrowserWithTabs } from './components/BrowserWithTabs.svelte'
24
+ export { default as CQChecker } from './components/CQChecker/CQChecker.svelte'
25
+ export { default as Image } from './components/Image.svelte'
26
+ export { default as Markdown } from './components/Markdown/Markdown.svelte'
27
+ export { default as PerspectiveHover } from './components/PerspectiveHover/PerspectiveHover.svelte'
28
+ export { default as Portal } from './components/Portal.svelte'
29
+ export { default as PushToLocalStorage } from './components/PushToLocalStorage.svelte'
30
+ export { default as Spotlight } from './components/Spotlight/Spotlight.svelte'
31
+ export { default as Status } from './components/Status.svelte'
32
+ export { default as SVG } from './components/SVG/SVG.svelte'
33
+ export { default as Video } from './components/Video.svelte'
34
+ export { default as Vimeo } from './components/Vimeo.svelte'
35
+ export { default as Youtube } from './components/Youtube.svelte'
package/jsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkJs": true
4
+ }
5
+ }