@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.
- package/.eslintrc.cjs +3 -0
- package/CHANGELOG.md +91 -0
- package/actions/breakpoint-observer.js +71 -0
- package/actions/index.js +6 -0
- package/actions/portal.js +20 -0
- package/actions/resize-observer.js +43 -0
- package/actions/scroll-observer.js +47 -0
- package/common.js +21 -0
- package/components/Accordion/Accordion.svelte +108 -0
- package/components/Accordion/index.js +3 -0
- package/components/Breadcrumbs/Breadcrumbs.svelte +69 -0
- package/components/Breadcrumbs/Crumb.svelte +37 -0
- package/components/Breadcrumbs/CrumbCustom.svelte +14 -0
- package/components/Breadcrumbs/index.js +5 -0
- package/components/BrowserFrame.svelte +37 -0
- package/components/BrowserWithTabs.svelte +28 -0
- package/components/CQChecker/CQChecker.astro +20 -0
- package/components/CQChecker/CQChecker.svelte +89 -0
- package/components/Callout/Callout.svelte +17 -0
- package/components/Callout/index.js +3 -0
- package/components/Codepen/Codepen.astro +29 -0
- package/components/Codepen/Codepen.svelte +24 -0
- package/components/Codepen/index.js +3 -0
- package/components/ContentList/ContentList-old.svelte +117 -0
- package/components/ContentList/ContentList.svelte +68 -0
- package/components/ContentList/index.js +3 -0
- package/components/Disclosure/Drawer/Drawer.svelte +35 -0
- package/components/Disclosure/Drawer/DrawerCloseButton.svelte +31 -0
- package/components/Disclosure/Drawer/DrawerContent-wrecked.svelte +198 -0
- package/components/Disclosure/Drawer/DrawerContent.svelte +164 -0
- package/components/Disclosure/Drawer/DrawerTrigger.svelte +32 -0
- package/components/Disclosure/Drawer/drawer.js +112 -0
- package/components/Disclosure/Drawer/index.js +6 -0
- package/components/Disclosure/Dropdown/DropdownContent.svelte +15 -0
- package/components/Disclosure/Dropdown/DropdownTrigger.svelte +14 -0
- package/components/Disclosure/Dropdown/dropdown.js +4 -0
- package/components/Disclosure/Dropdown/index.js +4 -0
- package/components/Disclosure/Modal/ModalContent.svelte +3 -0
- package/components/Disclosure/Modal/ModalTrigger.svelte +33 -0
- package/components/Disclosure/Modal/exit-intent.js +17 -0
- package/components/Disclosure/Modal/modal.js +13 -0
- package/components/Disclosure/Popover/PopoverCloseButton.svelte +29 -0
- package/components/Disclosure/Popover/PopoverContent.svelte +107 -0
- package/components/Disclosure/Popover/PopoverTrigger.svelte +33 -0
- package/components/Disclosure/Popover/floating.js +171 -0
- package/components/Disclosure/Popover/index.js +5 -0
- package/components/Disclosure/Popover/popover.js +18 -0
- package/components/Disclosure/Popover/references/FollowTheMouse.svelte +45 -0
- package/components/Disclosure/Tooltip/Tooltip.svelte +14 -0
- package/components/Disclosure/Tooltip/TooltipContent.svelte +7 -0
- package/components/Disclosure/Tooltip/TooltipTrigger.svelte +33 -0
- package/components/Disclosure/Tooltip/index.js +5 -0
- package/components/Disclosure/Tooltip/tooltip.js +22 -0
- package/components/Disclosure/disclosure-store.js +48 -0
- package/components/Disclosure/disclosure.js +439 -0
- package/components/Disclosure/index.js +3 -0
- package/components/Disclosure/state.svelte.js +138 -0
- package/components/FancyList/FancyList.svelte +49 -0
- package/components/FancyList/index.js +3 -0
- package/components/Form/Button.svelte +24 -0
- package/components/Form/Checkbox.svelte +80 -0
- package/components/Form/Checkboxes.svelte +48 -0
- package/components/Form/Combobox/AutocompleteInput.svelte +63 -0
- package/components/Form/Combobox/AutocompleteOptions.svelte +74 -0
- package/components/Form/Combobox/TimepickerInput.svelte +81 -0
- package/components/Form/Combobox/TimepickerOptions.svelte +100 -0
- package/components/Form/Combobox/autocomplete-matching.js +114 -0
- package/components/Form/Combobox/autocomplete.js +393 -0
- package/components/Form/Combobox/combobox-store.js +65 -0
- package/components/Form/Combobox/combobox.js +359 -0
- package/components/Form/Combobox/index.js +14 -0
- package/components/Form/Combobox/timepicker.js +119 -0
- package/components/Form/Form.svelte +62 -0
- package/components/Form/Hidden.svelte +16 -0
- package/components/Form/Radio.svelte +69 -0
- package/components/Form/Radios.svelte +50 -0
- package/components/Form/Select.svelte +127 -0
- package/components/Form/Switch.svelte +50 -0
- package/components/Form/TextInput.svelte +87 -0
- package/components/Form/Textarea.svelte +103 -0
- package/components/Form/check.svg +3 -0
- package/components/Form/index.js +12 -0
- package/components/Highlight/Highlight.svelte +27 -0
- package/components/Highlight/_Highlight.scss +19 -0
- package/components/Highlight/index.js +2 -0
- package/components/Image.svelte +24 -0
- package/components/InteractiveRegion/InteractiveRegion.svelte +47 -0
- package/components/InteractiveRegion/index.js +3 -0
- package/components/List/Lia.svelte +12 -0
- package/components/List/NestedListItem.svelte +50 -0
- package/components/List/index.js +3 -0
- package/components/Markdown/Markdown.svelte +35 -0
- package/components/Masonry/Masonry.svelte +79 -0
- package/components/Masonry/index.js +3 -0
- package/components/PerspectiveHover/PerspectiveHover.svelte +10 -0
- package/components/PerspectiveHover/perspective-hover.js +46 -0
- package/components/Populate/ConditionalPopulate.svelte +33 -0
- package/components/Populate/Populate.svelte +45 -0
- package/components/Populate/actions.js +29 -0
- package/components/Populate/get-value.js +17 -0
- package/components/Populate/index.js +4 -0
- package/components/Portal.svelte +27 -0
- package/components/PushToLocalStorage.svelte +30 -0
- package/components/Resizer/Resizer.svelte +32 -0
- package/components/Resizer/draggable.js +23 -0
- package/components/Resizer/index.js +3 -0
- package/components/Resizer/resizer.js +133 -0
- package/components/SVG/SVG.svelte +120 -0
- package/components/Scrambler/Scrambler.svelte +27 -0
- package/components/Scrambler/index.js +3 -0
- package/components/Spotlight/PointerPosition.js +32 -0
- package/components/Spotlight/Spotlight.svelte +9 -0
- package/components/Status.svelte +27 -0
- package/components/Switcheroo/Switcheroo.svelte +71 -0
- package/components/Switcheroo/index.js +3 -0
- package/components/Table/RowGroup.svelte +8 -0
- package/components/Table/Table.svelte +23 -0
- package/components/Table/Td.svelte +20 -0
- package/components/Table/Th.svelte +27 -0
- package/components/Table/Thead.svelte +8 -0
- package/components/Table/Tr.svelte +8 -0
- package/components/Table/index.js +17 -0
- package/components/Table/table.js +35 -0
- package/components/Tabs/Tab.svelte +12 -0
- package/components/Tabs/Tablist.svelte +62 -0
- package/components/Tabs/Tabpanel.svelte +10 -0
- package/components/Tabs/Tabpanels.svelte +12 -0
- package/components/Tabs/index.js +6 -0
- package/components/Tabs/tab-store.js +60 -0
- package/components/Tabs/tabs.js +364 -0
- package/components/Tabs-Old/Tab.svelte +9 -0
- package/components/Tabs-Old/Tablist.svelte +13 -0
- package/components/Tabs-Old/Tabpanel.svelte +10 -0
- package/components/Tabs-Old/Tabpanels.svelte +14 -0
- package/components/Tabs-Old/Tabs.svelte +83 -0
- package/components/Tabs-Old/index.js +7 -0
- package/components/Tabs-Old/tabs.js +306 -0
- package/components/Textwall/Repeat.svelte +10 -0
- package/components/Textwall/Textwall.svelte +30 -0
- package/components/Textwall/index.js +4 -0
- package/components/Typewriter/Typewriter.svelte +70 -0
- package/components/Typewriter/index.js +3 -0
- package/components/Video.svelte +46 -0
- package/components/Vimeo.svelte +18 -0
- package/components/Wrapper.svelte +22 -0
- package/components/Youtube.svelte +15 -0
- package/components/_shared/accessibility.js +9 -0
- package/components/_shared/key.js +1 -0
- package/components/_shared/transitions.js +48 -0
- package/components/_shared/use-actions.js +31 -0
- package/index.js +35 -0
- package/jsconfig.json +5 -0
- package/package.json +39 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// Need to check how to better let people include their styles...
|
|
3
|
+
// import style from '../scss/styles.scss?inline'
|
|
4
|
+
import { onMount } from 'svelte'
|
|
5
|
+
|
|
6
|
+
export let containers, increment, startAt
|
|
7
|
+
export let useIFrame = false
|
|
8
|
+
export let border = true
|
|
9
|
+
|
|
10
|
+
// ========================
|
|
11
|
+
// Configuration
|
|
12
|
+
// ========================
|
|
13
|
+
containers = containers || 10
|
|
14
|
+
increment = increment || 50 // px
|
|
15
|
+
startAt = startAt || 300 // px
|
|
16
|
+
|
|
17
|
+
// ========================
|
|
18
|
+
// Borders
|
|
19
|
+
// ========================
|
|
20
|
+
if (border) border = '1px var(--border-style) black'
|
|
21
|
+
else border = 'none'
|
|
22
|
+
|
|
23
|
+
// ========================
|
|
24
|
+
// For Iframe
|
|
25
|
+
// ========================
|
|
26
|
+
let slotContainer
|
|
27
|
+
let srcdoc
|
|
28
|
+
|
|
29
|
+
if (useIFrame) {
|
|
30
|
+
onMount(_ => {
|
|
31
|
+
// For Astro Slots
|
|
32
|
+
const slotContent = slotContainer.firstElementChild.firstElementChild
|
|
33
|
+
if (!slotContent) return
|
|
34
|
+
|
|
35
|
+
srcdoc = `
|
|
36
|
+
<html>
|
|
37
|
+
<body>
|
|
38
|
+
${slotContent.outerHTML}
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
41
|
+
`
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resetFrameHeight() {
|
|
46
|
+
const iframe = this
|
|
47
|
+
|
|
48
|
+
// Link Stylesheet
|
|
49
|
+
const head = iframe.contentDocument.head
|
|
50
|
+
const styleTag = document.createElement('style')
|
|
51
|
+
styleTag.innerText = 'style'
|
|
52
|
+
head.appendChild(styleTag)
|
|
53
|
+
|
|
54
|
+
styleTag.onload = function () {
|
|
55
|
+
const height = iframe.contentWindow.document.body.scrollHeight
|
|
56
|
+
const iframePadding = 16
|
|
57
|
+
iframe.style.height = height + iframePadding * 2 + 1 + 'px'
|
|
58
|
+
iframe.style.padding = iframePadding + 'px'
|
|
59
|
+
iframe.style.border = '1px var(--border-style) black'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div class="CQCheckerGrid">
|
|
65
|
+
{#each Array(containers).fill() as _, i}
|
|
66
|
+
{@const width = i * increment + startAt + 'px'}
|
|
67
|
+
<div class="CQContainer" style={`width: ${width};`}>
|
|
68
|
+
{#if srcdoc}
|
|
69
|
+
<div class="size">{width} (iframe mode)</div>
|
|
70
|
+
<iframe
|
|
71
|
+
title="{width} (iframe mode)"
|
|
72
|
+
frameborder="0"
|
|
73
|
+
{srcdoc}
|
|
74
|
+
{width}
|
|
75
|
+
on:load={resetFrameHeight}
|
|
76
|
+
></iframe>
|
|
77
|
+
{:else}
|
|
78
|
+
<div class="size">{width}</div>
|
|
79
|
+
<div
|
|
80
|
+
class="slotContent"
|
|
81
|
+
style={` border: ${border}`}
|
|
82
|
+
bind:this={slotContainer}
|
|
83
|
+
>
|
|
84
|
+
<slot />
|
|
85
|
+
</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
88
|
+
{/each}
|
|
89
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!-- BREAKING CHANGES TO CALLOUT -->
|
|
2
|
+
<!-- Rename CalloutPrefix to CalloutHeader -->
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
import { toTitle } from '@splendidlabz/utils'
|
|
6
|
+
|
|
7
|
+
let klass = ''
|
|
8
|
+
export { klass as class }
|
|
9
|
+
export let type = 'note'
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div class="Callout Callout-{type} ${klass}" data-type={type}>
|
|
13
|
+
<div class="CalloutHeader">{toTitle(type)}</div>
|
|
14
|
+
<div class="CalloutContent Prose">
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
const {
|
|
3
|
+
height = 300,
|
|
4
|
+
defaultTab = 'result',
|
|
5
|
+
user = 'zellwk',
|
|
6
|
+
author = 'Zell Liew',
|
|
7
|
+
themeID = 7929,
|
|
8
|
+
hash,
|
|
9
|
+
title,
|
|
10
|
+
} = Astro.props
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class="Codepen"
|
|
15
|
+
data-height={height}
|
|
16
|
+
data-theme-id={themeID}
|
|
17
|
+
data-default-tab={defaultTab}
|
|
18
|
+
data-user={user}
|
|
19
|
+
data-slug-hash={hash}
|
|
20
|
+
style=`height: ${height}px;`
|
|
21
|
+
data-pen-title={title}
|
|
22
|
+
>
|
|
23
|
+
<!-- prettier-ignore -->
|
|
24
|
+
<span>
|
|
25
|
+
See the Pen <a href=`https://codepen.io/${user}/pen/${hash}`> {title} </a>by {author} (<a href={`https://codepen.io/${user}`}>@{user}</a>) on<a href="https://codepen.io">CodePen</a>.
|
|
26
|
+
</span>
|
|
27
|
+
|
|
28
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
29
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let klass = ''
|
|
3
|
+
export { klass as class }
|
|
4
|
+
export let user, themeId, hash, title
|
|
5
|
+
export let height = 300
|
|
6
|
+
export let defaultTab = 'result'
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
class="Codepen {klass}"
|
|
11
|
+
data-height={height}
|
|
12
|
+
data-theme-id={themeId}
|
|
13
|
+
data-default-tab={defaultTab}
|
|
14
|
+
data-user={user}
|
|
15
|
+
data-slug-hash={hash}
|
|
16
|
+
style={`height: ${height}px;`}
|
|
17
|
+
data-pen-title={title}
|
|
18
|
+
>
|
|
19
|
+
<!-- prettier-ignore -->
|
|
20
|
+
<span>See the Pen
|
|
21
|
+
<a href={`https://codepen.io/${user}/pen/${hash}`}>{title}</a> by {user} (<a href={`https://codepen.io/${user}`}> @{user}</a>) on <a href="https://codepen.io">CodePen</a>.
|
|
22
|
+
</span>
|
|
23
|
+
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
export let label = 'Contents'
|
|
4
|
+
export let labelClass = ''
|
|
5
|
+
export let headings = ['h2', 'h3', 'h4', 'h5', 'h6']
|
|
6
|
+
export let selector = null
|
|
7
|
+
|
|
8
|
+
let structure = []
|
|
9
|
+
|
|
10
|
+
// Search the DOM so we have to do onMount
|
|
11
|
+
onMount(async _ => {
|
|
12
|
+
selector = document.querySelector(selector) || document
|
|
13
|
+
|
|
14
|
+
const elements = Array.from(selector.querySelectorAll(headings))
|
|
15
|
+
|
|
16
|
+
elements.forEach(element => {
|
|
17
|
+
const heading = element.tagName.toLowerCase()
|
|
18
|
+
const id = element.id
|
|
19
|
+
const label = element.textContent
|
|
20
|
+
|
|
21
|
+
if (heading === 'h1' || heading === 'h2') {
|
|
22
|
+
structure.push({ id, label, children: [] })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (heading === 'h3') {
|
|
26
|
+
const last = structure[structure.length - 1]
|
|
27
|
+
last.children.push({ id, label, children: [] })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (heading === 'h4') {
|
|
31
|
+
const last = structure[structure.length - 1]
|
|
32
|
+
const lastChild = last.children[last.children.length - 1]
|
|
33
|
+
lastChild.children.push({ id, label, children: [] })
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (heading === 'h5') {
|
|
37
|
+
const last = structure[structure.length - 1]
|
|
38
|
+
const lastChild = last.children[last.children.length - 1]
|
|
39
|
+
const lastGrandChild = lastChild.children[lastChild.children.length - 1]
|
|
40
|
+
lastGrandChild.children.push({ id, label, children: [] })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (heading === 'h6') {
|
|
44
|
+
const last = structure[structure.length - 1]
|
|
45
|
+
const lastChild = last.children[last.children.length - 1]
|
|
46
|
+
const lastGrandChild = lastChild.children[lastChild.children.length - 1]
|
|
47
|
+
const lastGreatGrandChild =
|
|
48
|
+
lastGrandChild.children[lastGrandChild.children.length - 1]
|
|
49
|
+
lastGreatGrandChild.children.push({ id, label })
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Reassign to trigger update
|
|
54
|
+
structure = structure
|
|
55
|
+
})
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
{#if structure.length}
|
|
59
|
+
<div class="ContentList" {...$$restProps}>
|
|
60
|
+
<div class="Label {labelClass}">{label}</div>
|
|
61
|
+
|
|
62
|
+
<!-- H1 and H2 -->
|
|
63
|
+
<ul>
|
|
64
|
+
{#each structure as level1}
|
|
65
|
+
<li class="level-1">
|
|
66
|
+
<a href="#{level1.id}">{level1.label}</a>
|
|
67
|
+
|
|
68
|
+
<!-- H3 -->
|
|
69
|
+
{#if level1.children}
|
|
70
|
+
<ul>
|
|
71
|
+
{#each level1.children as level2}
|
|
72
|
+
<li class="level-2">
|
|
73
|
+
<a href="#{level2.id}">{level2.label}</a>
|
|
74
|
+
|
|
75
|
+
<!-- H4 -->
|
|
76
|
+
{#if level2.children}
|
|
77
|
+
<ul>
|
|
78
|
+
{#each level2.children as level3}
|
|
79
|
+
<li class="level-3">
|
|
80
|
+
<a href="#{level3.id}">{level3.label}</a>
|
|
81
|
+
|
|
82
|
+
<!-- H5 -->
|
|
83
|
+
{#if level3.children}
|
|
84
|
+
<ul>
|
|
85
|
+
{#each level3.children as level4}
|
|
86
|
+
<li class="level-4">
|
|
87
|
+
<a href="#{level4.id}">{level4.label}</a>
|
|
88
|
+
|
|
89
|
+
<!-- H6 -->
|
|
90
|
+
{#if level4.children}
|
|
91
|
+
<ul>
|
|
92
|
+
{#each level4.children as level5}
|
|
93
|
+
<li class="level-5">
|
|
94
|
+
<a href="#{level5.id}"
|
|
95
|
+
>{level5.label}</a
|
|
96
|
+
>
|
|
97
|
+
</li>
|
|
98
|
+
{/each}
|
|
99
|
+
</ul>
|
|
100
|
+
{/if}
|
|
101
|
+
</li>
|
|
102
|
+
{/each}
|
|
103
|
+
</ul>
|
|
104
|
+
{/if}
|
|
105
|
+
</li>
|
|
106
|
+
{/each}
|
|
107
|
+
</ul>
|
|
108
|
+
{/if}
|
|
109
|
+
</li>
|
|
110
|
+
{/each}
|
|
111
|
+
</ul>
|
|
112
|
+
{/if}
|
|
113
|
+
</li>
|
|
114
|
+
{/each}
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
{/if}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import NestedList from '../List/NestedListItem.svelte'
|
|
4
|
+
|
|
5
|
+
let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
export let selector = null
|
|
8
|
+
export let label = 'Contents'
|
|
9
|
+
export let labelClass = ''
|
|
10
|
+
export let listClass = null
|
|
11
|
+
export let liClass = null
|
|
12
|
+
export let aClass = null
|
|
13
|
+
|
|
14
|
+
export let options = {
|
|
15
|
+
includes: ['h2', 'h3', 'h4', 'h5', 'h6'],
|
|
16
|
+
excludes: [],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let structure = []
|
|
20
|
+
|
|
21
|
+
onMount(() => {
|
|
22
|
+
if (typeof window === 'undefined') return
|
|
23
|
+
const targetElement = selector ? document.querySelector(selector) : document
|
|
24
|
+
const elements = Array.from(
|
|
25
|
+
targetElement.querySelectorAll(options.includes.join(',')),
|
|
26
|
+
).filter(el => {
|
|
27
|
+
if (el.matches('.ContentList-exclude')) return false
|
|
28
|
+
if (options.excludes.some(selector => el.matches(selector))) return false
|
|
29
|
+
return true
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
structure = buildStructure(elements)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function buildStructure(elements) {
|
|
36
|
+
const structure = []
|
|
37
|
+
const stack = [{ headingLevel: 0, children: structure }]
|
|
38
|
+
|
|
39
|
+
elements.forEach(element => {
|
|
40
|
+
const headingLevel = parseInt(element.tagName.charAt(1))
|
|
41
|
+
const item = {
|
|
42
|
+
href: `#${element.id}`,
|
|
43
|
+
label: element.textContent,
|
|
44
|
+
liClass,
|
|
45
|
+
aClass,
|
|
46
|
+
children: [],
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
while (headingLevel <= stack[stack.length - 1].headingLevel) {
|
|
50
|
+
stack.pop()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
stack[stack.length - 1].children.push(item)
|
|
54
|
+
stack.push({ headingLevel, children: item.children })
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return structure
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
{#if structure.length}
|
|
62
|
+
<div class="ContentList {klass}" {...$$restProps}>
|
|
63
|
+
<div class="Label {labelClass}">{label}</div>
|
|
64
|
+
<ul class="IndentedList {listClass}">
|
|
65
|
+
<NestedList items={structure} />
|
|
66
|
+
</ul>
|
|
67
|
+
</div>
|
|
68
|
+
{/if}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
+
import DrawerCloseButton from './DrawerCloseButton.svelte'
|
|
4
|
+
import DrawerContent from './DrawerContent.svelte'
|
|
5
|
+
import DrawerTrigger from './DrawerTrigger.svelte'
|
|
6
|
+
|
|
7
|
+
export let triggerIcon = null
|
|
8
|
+
export let triggerClass = ''
|
|
9
|
+
export let contentClass = ''
|
|
10
|
+
export let closeButtonIcon = 'tabler:x'
|
|
11
|
+
export let closeButtonClass = ''
|
|
12
|
+
|
|
13
|
+
export let id = ''
|
|
14
|
+
export let triggerOptions = {}
|
|
15
|
+
export let contentOptions = {}
|
|
16
|
+
|
|
17
|
+
id = id || randomString(8)
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<DrawerTrigger
|
|
21
|
+
target={id}
|
|
22
|
+
class={triggerClass}
|
|
23
|
+
icon={triggerIcon}
|
|
24
|
+
options={triggerOptions}
|
|
25
|
+
>
|
|
26
|
+
<slot name="trigger" />
|
|
27
|
+
</DrawerTrigger>
|
|
28
|
+
|
|
29
|
+
<DrawerContent {id} class={contentClass} options={contentOptions}>
|
|
30
|
+
<div class="Horizontal">
|
|
31
|
+
<slot name="content-header"></slot>
|
|
32
|
+
<DrawerCloseButton class={closeButtonClass} icon={closeButtonIcon} />
|
|
33
|
+
</div>
|
|
34
|
+
<slot name="content"></slot>
|
|
35
|
+
</DrawerContent>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import SVG from '../../SVG/SVG.svelte'
|
|
3
|
+
import { close, getDisclosure } from '../disclosure.js'
|
|
4
|
+
|
|
5
|
+
export let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
export let icon = 'tabler:x'
|
|
8
|
+
export let iconClass = ''
|
|
9
|
+
|
|
10
|
+
export let target = null
|
|
11
|
+
|
|
12
|
+
let button = null
|
|
13
|
+
|
|
14
|
+
function handleClick() {
|
|
15
|
+
const id =
|
|
16
|
+
document.querySelector(`${target}`)?.id ||
|
|
17
|
+
button.closest('.DrawerContent').id
|
|
18
|
+
const d = getDisclosure(id)
|
|
19
|
+
close(d, { shouldFocusTrigger: true })
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<button
|
|
24
|
+
aria-label="Close dialog"
|
|
25
|
+
class="DrawerCloseButton Button-icon {klass}"
|
|
26
|
+
bind:this={button}
|
|
27
|
+
on:click={handleClick}
|
|
28
|
+
{...$$restProps}
|
|
29
|
+
>
|
|
30
|
+
<slot><SVG class={iconClass} {icon} /></slot>
|
|
31
|
+
</button>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<!-- Drawers are not working currently because we changed the Disclosure implementation. -->
|
|
2
|
+
<script>
|
|
3
|
+
import { splitObject, toStyleString } from '@splendidlabz/utils'
|
|
4
|
+
import Portal from '../../Portal.svelte'
|
|
5
|
+
import { transit } from '../../_shared/transitions.js'
|
|
6
|
+
import { disclosures } from '../disclosure-store.js'
|
|
7
|
+
import {
|
|
8
|
+
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
9
|
+
disclosureContent,
|
|
10
|
+
} from '../disclosure.js'
|
|
11
|
+
import {
|
|
12
|
+
drawerContentOptKeys,
|
|
13
|
+
drawerPositionDefaultOpts,
|
|
14
|
+
getPosition,
|
|
15
|
+
getTransitionXY,
|
|
16
|
+
} from './drawer.js'
|
|
17
|
+
|
|
18
|
+
let klass = ''
|
|
19
|
+
let styleString = ''
|
|
20
|
+
export { klass as class }
|
|
21
|
+
export { styleString as style }
|
|
22
|
+
|
|
23
|
+
export let id
|
|
24
|
+
export let options = {}
|
|
25
|
+
|
|
26
|
+
const { picked: userDisclosureOpts } = splitObject(
|
|
27
|
+
options,
|
|
28
|
+
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const { picked: userDrawerOpts } = splitObject(options, drawerContentOptKeys)
|
|
32
|
+
|
|
33
|
+
const opts = {
|
|
34
|
+
...drawerPositionDefaultOpts[options.position],
|
|
35
|
+
...options,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// if (options.transition === 'push') options.transition = push
|
|
39
|
+
|
|
40
|
+
let d
|
|
41
|
+
$: d = $disclosures.find(d => d.id === id)
|
|
42
|
+
|
|
43
|
+
const style = toStyleString(getPosition(opts)) + styleString
|
|
44
|
+
const { position, overlay, placement, blurOverlay } = opts
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<!-- This is one of the first things I'll switch to Svelte 5 for the snippet functionality. When switching, we might have to change to nanostores? -->
|
|
48
|
+
|
|
49
|
+
<!-- Note: We temporarily support aria-label and aria-labelledby accessibility properties only because {...$$restProps} breaks transitions — it stops inward transition from working from working. -->
|
|
50
|
+
{#if position === 'fixed' && overlay}
|
|
51
|
+
<Portal>
|
|
52
|
+
{#key visible}
|
|
53
|
+
<div
|
|
54
|
+
hidden={!visible}
|
|
55
|
+
class="DrawerOverlay"
|
|
56
|
+
class:DrawerOverlay-Blur={blurOverlay}
|
|
57
|
+
transition:transit|global={opts}
|
|
58
|
+
>
|
|
59
|
+
<div
|
|
60
|
+
{id}
|
|
61
|
+
hidden={!visible}
|
|
62
|
+
{style}
|
|
63
|
+
class="DrawerContent {klass}"
|
|
64
|
+
bind:this={d.nodes.contentNode}
|
|
65
|
+
use:disclosureContent={{ id: d.id }}
|
|
66
|
+
aria-label={$$restProps['aria-label']}
|
|
67
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
68
|
+
transition:transit|global={{
|
|
69
|
+
placement,
|
|
70
|
+
...getTransitionXY(placement),
|
|
71
|
+
...opts,
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
{/key}
|
|
78
|
+
</Portal>
|
|
79
|
+
{/if}
|
|
80
|
+
|
|
81
|
+
{#if position === 'fixed' && !overlay}
|
|
82
|
+
<Portal>
|
|
83
|
+
{#key visible}
|
|
84
|
+
<div
|
|
85
|
+
{id}
|
|
86
|
+
{style}
|
|
87
|
+
hidden={!visible}
|
|
88
|
+
class="DrawerContent {klass}"
|
|
89
|
+
bind:this={d.nodes.contentNode}
|
|
90
|
+
use:disclosureContent={{ id: d.id }}
|
|
91
|
+
aria-label={$$restProps['aria-label']}
|
|
92
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
93
|
+
transition:transit|global={{
|
|
94
|
+
placement,
|
|
95
|
+
...opts,
|
|
96
|
+
...getTransitionXY(placement),
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<slot />
|
|
100
|
+
</div>
|
|
101
|
+
{/key}
|
|
102
|
+
</Portal>
|
|
103
|
+
{/if}
|
|
104
|
+
|
|
105
|
+
{#if position === 'absolute' || position === 'static'}
|
|
106
|
+
{#key visible}
|
|
107
|
+
<div
|
|
108
|
+
{id}
|
|
109
|
+
{style}
|
|
110
|
+
hidden={!visible}
|
|
111
|
+
class="DrawerContent {klass}"
|
|
112
|
+
bind:this={d.nodes.contentNode}
|
|
113
|
+
use:disclosureContent={{ id: d.id }}
|
|
114
|
+
aria-label={$$restProps['aria-label']}
|
|
115
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
116
|
+
transition:transit|global={{
|
|
117
|
+
placement,
|
|
118
|
+
...opts,
|
|
119
|
+
...getTransitionXY(placement),
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<slot />
|
|
123
|
+
</div>
|
|
124
|
+
{/key}
|
|
125
|
+
{/if}
|
|
126
|
+
|
|
127
|
+
<!-- {#if d.state.show}
|
|
128
|
+
{#if strategy === 'static'}
|
|
129
|
+
<div
|
|
130
|
+
{id}
|
|
131
|
+
{style}
|
|
132
|
+
class="DrawerContent {klass}"
|
|
133
|
+
bind:this={d.nodes.contentNode}
|
|
134
|
+
use:disclosureContent={{ id: d.id }}
|
|
135
|
+
aria-label={$$restProps['aria-label']}
|
|
136
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
137
|
+
>
|
|
138
|
+
<slot />
|
|
139
|
+
</div>
|
|
140
|
+
{:else if strategy === 'absolute'}
|
|
141
|
+
<div
|
|
142
|
+
{id}
|
|
143
|
+
{style}
|
|
144
|
+
class="DrawerContent {klass}"
|
|
145
|
+
bind:this={d.nodes.contentNode}
|
|
146
|
+
use:disclosureContent={{ id: d.id }}
|
|
147
|
+
aria-label={$$restProps['aria-label']}
|
|
148
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
149
|
+
transition:fly|global={{
|
|
150
|
+
...transitionOpts,
|
|
151
|
+
...getTransitionXY(placement),
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<slot />
|
|
155
|
+
</div>
|
|
156
|
+
{:else if strategy === 'fixed' && !overlay}
|
|
157
|
+
<Portal>
|
|
158
|
+
<div
|
|
159
|
+
{id}
|
|
160
|
+
{style}
|
|
161
|
+
class="DrawerContent {klass}"
|
|
162
|
+
bind:this={d.nodes.contentNode}
|
|
163
|
+
use:disclosureContent={{ id: d.id }}
|
|
164
|
+
aria-label={$$restProps['aria-label']}
|
|
165
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
166
|
+
transition:fly|global={{
|
|
167
|
+
...transitionOpts,
|
|
168
|
+
...getTransitionXY(placement),
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
<slot />
|
|
172
|
+
</div>
|
|
173
|
+
</Portal>
|
|
174
|
+
{:else if strategy === 'fixed' && overlay}
|
|
175
|
+
<Portal>
|
|
176
|
+
<div
|
|
177
|
+
class="DrawerOverlay {blurBackdrop ? 'DrawerOverlay-BlurBackdrop' : ''}"
|
|
178
|
+
transition:fade|global={transitionOpts}
|
|
179
|
+
>
|
|
180
|
+
<div
|
|
181
|
+
{id}
|
|
182
|
+
{style}
|
|
183
|
+
class="DrawerContent {klass}"
|
|
184
|
+
bind:this={d.nodes.contentNode}
|
|
185
|
+
use:disclosureContent={{ id: d.id }}
|
|
186
|
+
aria-label={$$restProps['aria-label']}
|
|
187
|
+
aria-labelledBy={$$restProps['aria-labelledBy']}
|
|
188
|
+
transition:fly|global={{
|
|
189
|
+
...transitionOpts,
|
|
190
|
+
...getTransitionXY(placement),
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
<slot />
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</Portal>
|
|
197
|
+
{/if}
|
|
198
|
+
{/if} -->
|