@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
package/.eslintrc.cjs
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @splendidlabz/svelte
|
|
2
|
+
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8ef3178: - Add table component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @splendidlabz/styles@2.2.0
|
|
13
|
+
|
|
14
|
+
## 0.3.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Add Svelte condition to export
|
|
19
|
+
|
|
20
|
+
## 0.3.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Removed directory imports in favor of ESM
|
|
25
|
+
|
|
26
|
+
## 0.3.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- Add robust before/after element styling with InputGroup
|
|
31
|
+
- - Add Combobox with Dynamic Haystack option
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 8ef3178: Ensure combobox options use default cursor
|
|
36
|
+
- a9128f4: - Fix all util pathways
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- Updated dependencies [8ef3178]
|
|
41
|
+
- Updated dependencies [a9128f4]
|
|
42
|
+
- @splendidlabz/layouts@2.0.1
|
|
43
|
+
- @splendidlabz/styles@2.1.0
|
|
44
|
+
- @splendidlabz/utils@1.3.0
|
|
45
|
+
|
|
46
|
+
## 0.2.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- a9128f4: - Add `Combobox` component
|
|
51
|
+
- Add `Select` component
|
|
52
|
+
- Upgraded `TextInput` and `Select` components to include `.InputGroup` styles which allow for lots of input variations.
|
|
53
|
+
- Element bindings now use `ref` instead of `elem`
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- a9128f4: Major work on Forms and Form element controls in this patch.
|
|
58
|
+
|
|
59
|
+
- Ensure `Form` works with normal `POST` request when `onSubmit` is not defined. Also included `felte` library for form validation in the future.
|
|
60
|
+
- `TextInput` must now take in either a `label` or `placeholder`.
|
|
61
|
+
- Add disabled and readonly styles to TextInput and its label
|
|
62
|
+
- `Textarea` can now take in the same properties as `TextInput`.
|
|
63
|
+
- Allow `Checbox` to bind to reference
|
|
64
|
+
- Fix `Checkbox` element to contain its native `on` value.
|
|
65
|
+
- Add disabled and readonly styles to checkbox and its label
|
|
66
|
+
|
|
67
|
+
There's some work on the internal `disclosure` action and stores as well.
|
|
68
|
+
|
|
69
|
+
- Change default `focusTarget` to `null` to facilitate usage in other components.
|
|
70
|
+
- Remove the need to pass in default `disclosure` options. This is now handled in the disclosure store automatically.
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [6c6ecec]
|
|
73
|
+
- Updated dependencies [6f28588]
|
|
74
|
+
- Updated dependencies [a9128f4]
|
|
75
|
+
- Updated dependencies [a9128f4]
|
|
76
|
+
- Updated dependencies [a9128f4]
|
|
77
|
+
- @splendidlabz/layouts@2.0.0
|
|
78
|
+
- @splendidlabz/styles@2.0.0
|
|
79
|
+
- @splendidlabz/utils@1.2.0
|
|
80
|
+
|
|
81
|
+
## 0.1.2
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Fix populate dependencies path
|
|
86
|
+
|
|
87
|
+
## 0.1.1
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Fix package.json
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isEmpty, omitEmpty } from '@splendidlabz/utils'
|
|
2
|
+
import { resizeObserver } from '@splendidlabz/utils/actions'
|
|
3
|
+
|
|
4
|
+
const DEFAULT_BREAKPOINT_OPTIONS = {
|
|
5
|
+
breakpoints: {},
|
|
6
|
+
breakpointType: 'media', // media
|
|
7
|
+
callback: null,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function breakpointObserver(node, props = {}) {
|
|
11
|
+
const options = { ...DEFAULT_BREAKPOINT_OPTIONS, ...omitEmpty(props) }
|
|
12
|
+
if (isEmpty(options.breakpoints)) return
|
|
13
|
+
|
|
14
|
+
const { breakpointType } = options
|
|
15
|
+
|
|
16
|
+
let observedNode
|
|
17
|
+
if (breakpointType === 'media') observedNode = document.body
|
|
18
|
+
else observedNode = node
|
|
19
|
+
|
|
20
|
+
let activeBreakpointValue = 0
|
|
21
|
+
const breakpoints = createBreakpointArray(options.breakpoints)
|
|
22
|
+
|
|
23
|
+
const observer = resizeObserver(observedNode, {
|
|
24
|
+
observe: true,
|
|
25
|
+
callback: observerCB,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Observer Callback
|
|
29
|
+
function observerCB({ entry }) {
|
|
30
|
+
let { width } = entry.contentRect
|
|
31
|
+
if (breakpointType === 'media') width = window.innerWidth
|
|
32
|
+
|
|
33
|
+
// Check for the current breakpoint
|
|
34
|
+
const currentBreakpoint = getCurrentBreakpoint({ breakpoints, width })
|
|
35
|
+
const { breakpoint, value } = currentBreakpoint
|
|
36
|
+
|
|
37
|
+
// Check if breakpoint is active
|
|
38
|
+
if (activeBreakpointValue === breakpoint) return
|
|
39
|
+
activeBreakpointValue = breakpoint
|
|
40
|
+
|
|
41
|
+
// Runs callback
|
|
42
|
+
if (options.callback)
|
|
43
|
+
options.callback({
|
|
44
|
+
node: observedNode,
|
|
45
|
+
breakpoint,
|
|
46
|
+
value,
|
|
47
|
+
observer,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
destroy() {
|
|
53
|
+
observer.disconnect(observedNode)
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// breakpoints={{
|
|
59
|
+
// 0: { ... },
|
|
60
|
+
// 1000: { ... },
|
|
61
|
+
// }}
|
|
62
|
+
function createBreakpointArray(breakpoints) {
|
|
63
|
+
return Object.entries(breakpoints).map(([key, value]) => {
|
|
64
|
+
return { breakpoint: parseFloat(key), value }
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getCurrentBreakpoint({ breakpoints, width }) {
|
|
69
|
+
const filtered = breakpoints.filter(({ breakpoint }) => width >= breakpoint)
|
|
70
|
+
return filtered[filtered.length - 1]
|
|
71
|
+
}
|
package/actions/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function Portal(node, options = {}) {
|
|
2
|
+
const { target, class: klass } = options
|
|
3
|
+
|
|
4
|
+
const portal = document.createElement('div')
|
|
5
|
+
portal.classList.add('Portal')
|
|
6
|
+
if (klass) portal.classList.add(klass)
|
|
7
|
+
portal.append(node)
|
|
8
|
+
|
|
9
|
+
let portalTarget
|
|
10
|
+
if (target) portalTarget = document.querySelector(target)
|
|
11
|
+
if (!target) portalTarget = document.body
|
|
12
|
+
|
|
13
|
+
portalTarget.append(portal)
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
destroy() {
|
|
17
|
+
portalTarget.removeChild(portal)
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
// TODO: Move to Utils/Dom
|
|
3
|
+
// Components to update before switching: Switcheroo, Masonry
|
|
4
|
+
// Can also use breakpointsObserver for Switcheroo instead.
|
|
5
|
+
import { notEmpty } from '@splendidlabz/utils'
|
|
6
|
+
|
|
7
|
+
export function resizeObserver(node, options) {
|
|
8
|
+
// We set the option here to prevent observer from being created unless necessary.
|
|
9
|
+
if (!options.observe) return
|
|
10
|
+
|
|
11
|
+
const observer = new ResizeObserver(observerFn)
|
|
12
|
+
|
|
13
|
+
function observerFn(entries) {
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
if (options.callback) {
|
|
16
|
+
options.callback({ node, entry, observer })
|
|
17
|
+
} else {
|
|
18
|
+
node.dispatchEvent(
|
|
19
|
+
new CustomEvent('resize', {
|
|
20
|
+
detail: { node, entry, observer },
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
observer.observe(node)
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
destroy() {
|
|
31
|
+
observer.unobserve(node)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Need to change Switcheroo before we remove this.
|
|
37
|
+
export function createBreakpointArray(breakpoints) {
|
|
38
|
+
if (notEmpty(breakpoints)) {
|
|
39
|
+
return Object.entries(breakpoints).map(([key, value]) => {
|
|
40
|
+
return { breakpoint: parseFloat(key), value }
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
|
|
3
|
+
// TODO: Move to Utils/Dom
|
|
4
|
+
/**
|
|
5
|
+
* Scroll Observer
|
|
6
|
+
* @param {Number} threshold Float between 0 to 1. When to fire a threshold event.
|
|
7
|
+
* @param {Number} tolerance Float between 0 to 1. Tolerance for event firing.
|
|
8
|
+
*/
|
|
9
|
+
export default function scrollObserver(
|
|
10
|
+
node,
|
|
11
|
+
{
|
|
12
|
+
threshold = 0, // Float between 0 to 1.
|
|
13
|
+
tolerance = 0.1, // Float between 0 to 1. Tolerance for event firing
|
|
14
|
+
} = {},
|
|
15
|
+
) {
|
|
16
|
+
let prevScrollTop = 0
|
|
17
|
+
|
|
18
|
+
function observe(event) {
|
|
19
|
+
const { documentElement } = document
|
|
20
|
+
const scrollTop = documentElement.scrollTop
|
|
21
|
+
const scrollDirection = scrollTop > prevScrollTop ? 'down' : 'up'
|
|
22
|
+
const scrollPercent =
|
|
23
|
+
scrollTop / (documentElement.scrollHeight - documentElement.clientHeight)
|
|
24
|
+
|
|
25
|
+
if (scrollDirection === 'down') {
|
|
26
|
+
node.dispatchEvent(new CustomEvent('scrolldown'))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (scrollDirection === 'up') {
|
|
30
|
+
node.dispatchEvent(new CustomEvent('scrollUp'))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (scrollPercent > threshold && scrollPercent < threshold + tolerance) {
|
|
34
|
+
node.dispatchEvent(new CustomEvent(`${scrollDirection}:threshold`))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
prevScrollTop = scrollTop
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
node.addEventListener('scroll', observe)
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
destroy() {
|
|
44
|
+
node.removeEventListener('scroll', observe)
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
package/common.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Common components we use in Svelte
|
|
2
|
+
// We include each component individually to reduce bundle size
|
|
3
|
+
import { Callout } from './components/Callout'
|
|
4
|
+
import { Codepen } from './components/Codepen'
|
|
5
|
+
import FancyList from './components/FancyList/FancyList.svelte'
|
|
6
|
+
import Image from './components/Image.svelte'
|
|
7
|
+
import SVG from './components/SVG/SVG.svelte'
|
|
8
|
+
import Video from './components/Video.svelte'
|
|
9
|
+
import Vimeo from './components/Vimeo.svelte'
|
|
10
|
+
import Youtube from './components/Youtube.svelte'
|
|
11
|
+
|
|
12
|
+
export const components = {
|
|
13
|
+
Callout,
|
|
14
|
+
Codepen,
|
|
15
|
+
FancyList,
|
|
16
|
+
Image,
|
|
17
|
+
SVG,
|
|
18
|
+
Video,
|
|
19
|
+
Vimeo,
|
|
20
|
+
Youtube,
|
|
21
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { transit } from '../_shared/transitions.js'
|
|
4
|
+
import SVG from '../SVG/SVG.svelte'
|
|
5
|
+
|
|
6
|
+
let klass = ''
|
|
7
|
+
export { klass as class }
|
|
8
|
+
export let buttonClass = ''
|
|
9
|
+
export let svgClass = null
|
|
10
|
+
export let contentClass = ''
|
|
11
|
+
|
|
12
|
+
export let options = {}
|
|
13
|
+
|
|
14
|
+
const DEFAULT_OPTIONS = {
|
|
15
|
+
tag: 'h3',
|
|
16
|
+
icon: 'tabler:chevron-right',
|
|
17
|
+
iconLocation: 'end',
|
|
18
|
+
transition: 'slide',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const opts = { ...DEFAULT_OPTIONS, ...options }
|
|
22
|
+
const { tag, icon, iconLocation } = opts
|
|
23
|
+
|
|
24
|
+
let show = false
|
|
25
|
+
let hasCustomIcon = $$slots.icon
|
|
26
|
+
const id = randomString(9)
|
|
27
|
+
|
|
28
|
+
if (!$$slots.title) {
|
|
29
|
+
console.warn('Accordion: No title slot provided')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function handleClick(event) {
|
|
33
|
+
// Toggle accordion show
|
|
34
|
+
show = !show
|
|
35
|
+
|
|
36
|
+
if (show) {
|
|
37
|
+
// Close all accordions except this one
|
|
38
|
+
const closestStack = event.target.closest('.AccordionStack')
|
|
39
|
+
if (!closestStack) return
|
|
40
|
+
const accordionCloseButtons = closestStack.querySelectorAll(
|
|
41
|
+
'.AccordionCloseButton',
|
|
42
|
+
)
|
|
43
|
+
accordionCloseButtons.forEach(button => button.click())
|
|
44
|
+
show = true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleKeydown(event) {
|
|
49
|
+
const { key } = event
|
|
50
|
+
if (key === 'Escape') closeAccordion()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function closeAccordion() {
|
|
54
|
+
show = false
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div class="Accordion {klass}">
|
|
59
|
+
<svelte:element this={tag}>
|
|
60
|
+
<!-- So it doesn't inherit "Button" -->
|
|
61
|
+
<button
|
|
62
|
+
class="AccordionBtn {buttonClass}"
|
|
63
|
+
on:click={handleClick}
|
|
64
|
+
on:keydown={handleKeydown}
|
|
65
|
+
aria-expanded={show}
|
|
66
|
+
aria-controls={id}
|
|
67
|
+
>
|
|
68
|
+
<slot name="icon">
|
|
69
|
+
{#if !hasCustomIcon && iconLocation === 'start'}
|
|
70
|
+
<SVG {icon} class={svgClass} />
|
|
71
|
+
{/if}
|
|
72
|
+
</slot>
|
|
73
|
+
|
|
74
|
+
<slot name="title"></slot>
|
|
75
|
+
|
|
76
|
+
<slot name="icon">
|
|
77
|
+
{#if !hasCustomIcon && iconLocation === 'end'}
|
|
78
|
+
<SVG {icon} class={svgClass} />
|
|
79
|
+
{/if}
|
|
80
|
+
</slot>
|
|
81
|
+
</button>
|
|
82
|
+
</svelte:element>
|
|
83
|
+
|
|
84
|
+
{#if show === true}
|
|
85
|
+
<div
|
|
86
|
+
{id}
|
|
87
|
+
role="region"
|
|
88
|
+
class="AccordionContent {contentClass}"
|
|
89
|
+
transition:transit={{
|
|
90
|
+
transition: opts.transition,
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<!-- Both can work -->
|
|
94
|
+
<slot />
|
|
95
|
+
<slot name="content"></slot>
|
|
96
|
+
</div>
|
|
97
|
+
{/if}
|
|
98
|
+
<!-- Hidden button, only accessible via JS. -->
|
|
99
|
+
<!-- For closing multiple accordions only -->
|
|
100
|
+
<button
|
|
101
|
+
on:click={closeAccordion}
|
|
102
|
+
class="AccordionCloseButton"
|
|
103
|
+
hidden
|
|
104
|
+
tabindex="-1"
|
|
105
|
+
></button>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<!-- IF ICON BEFORE, need to put flex-start on the accordion title. Because that's the default value -->
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import Crumb from './Crumb.svelte'
|
|
4
|
+
|
|
5
|
+
let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
export let pathname = ''
|
|
8
|
+
export let options = {
|
|
9
|
+
crumbs: [],
|
|
10
|
+
labelCase: 'title',
|
|
11
|
+
divider: 'tabler:chevron-right',
|
|
12
|
+
ariaCurrentType: 'page',
|
|
13
|
+
startingDepth: 0,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { startingDepth, ariaCurrentType, labelCase } = options
|
|
17
|
+
const trailingSlash = hasTrailingSlash(pathname)
|
|
18
|
+
let crumbs = constructCrumbs(getURLArray(pathname), { trailingSlash })
|
|
19
|
+
|
|
20
|
+
onMount(_ => {
|
|
21
|
+
if (typeof window === 'undefined') return
|
|
22
|
+
if (!pathname) {
|
|
23
|
+
const { pathname } = window.location
|
|
24
|
+
const trailingSlash = hasTrailingSlash(pathname)
|
|
25
|
+
crumbs = constructCrumbs(getURLArray(pathname), { trailingSlash })
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Supporting functions
|
|
30
|
+
function hasTrailingSlash(pathname) {
|
|
31
|
+
return pathname.endsWith('/')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getURLArray(pathname) {
|
|
35
|
+
return pathname
|
|
36
|
+
.split('/')
|
|
37
|
+
.filter(str => str)
|
|
38
|
+
.slice(startingDepth)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function constructCrumbs(urlArray, { trailingSlash = true } = {}) {
|
|
42
|
+
return urlArray.map((crumb, index) => {
|
|
43
|
+
return {
|
|
44
|
+
label: crumb,
|
|
45
|
+
labelCase,
|
|
46
|
+
href:
|
|
47
|
+
urlArray.slice(0, index + 1).join('/') + (trailingSlash ? '/' : ''),
|
|
48
|
+
isLast: index === urlArray.length - 1,
|
|
49
|
+
ariaCurrentType,
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<nav class={`Breadcrumbs ${klass}`} aria-label="Breadcrumbs">
|
|
56
|
+
<ul>
|
|
57
|
+
<slot name="before" />
|
|
58
|
+
<slot>
|
|
59
|
+
{#each crumbs as crumb, index}
|
|
60
|
+
<Crumb
|
|
61
|
+
{...crumb}
|
|
62
|
+
divider={options.divider}
|
|
63
|
+
isLast={index === crumbs.length - 1}
|
|
64
|
+
/>
|
|
65
|
+
{/each}
|
|
66
|
+
</slot>
|
|
67
|
+
<slot name="after" />
|
|
68
|
+
</ul>
|
|
69
|
+
</nav>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { toLower, toSentence, toTitle, toUpper } from '@splendidlabz/utils'
|
|
3
|
+
import SVG from '../SVG/SVG.svelte'
|
|
4
|
+
|
|
5
|
+
let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
export let aClass = null
|
|
8
|
+
export let currentClass = null
|
|
9
|
+
export let ariaCurrentType = 'page'
|
|
10
|
+
export let isLast = null
|
|
11
|
+
export let divider = 'tabler:chevron-right'
|
|
12
|
+
export let label
|
|
13
|
+
export let href = ''
|
|
14
|
+
export let labelCase = 'title'
|
|
15
|
+
|
|
16
|
+
// Case conversion
|
|
17
|
+
if (labelCase === 'title') label = toTitle(label)
|
|
18
|
+
if (labelCase === 'sentence') label = toSentence(label)
|
|
19
|
+
if (labelCase === 'upper') label = toUpper(label)
|
|
20
|
+
if (labelCase === 'lower') label = toLower(label)
|
|
21
|
+
|
|
22
|
+
const current = isLast && ariaCurrentType
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- Before slots are for custom icons -->
|
|
26
|
+
<li class="Crumb {klass}">
|
|
27
|
+
{#if isLast}
|
|
28
|
+
<slot name="before" />
|
|
29
|
+
<span class={currentClass} aria-current={current}>{label}</span>
|
|
30
|
+
{:else}
|
|
31
|
+
<slot name="before" />
|
|
32
|
+
<a class={aClass} {href}>{label}</a>
|
|
33
|
+
<div class="CrumbDivider">
|
|
34
|
+
<SVG icon={divider} />
|
|
35
|
+
</div>
|
|
36
|
+
{/if}
|
|
37
|
+
</li>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import SVG from '../SVG/SVG.svelte'
|
|
3
|
+
|
|
4
|
+
let klass = ''
|
|
5
|
+
export { klass as class }
|
|
6
|
+
export let divider = 'tabler:chevron-right'
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<li class="Crumb {klass}">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
<div class="CrumbDivider">
|
|
12
|
+
<SVG icon={divider} />
|
|
13
|
+
</div>
|
|
14
|
+
</li>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Resizer } from './Resizer/index.js'
|
|
3
|
+
|
|
4
|
+
let klass = ''
|
|
5
|
+
export { klass as class }
|
|
6
|
+
export let frameContentClass = ''
|
|
7
|
+
export let contentClass = ''
|
|
8
|
+
export let options = {}
|
|
9
|
+
export let elem = null
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div class="BrowserFrame {klass}" bind:this={elem}>
|
|
13
|
+
<div class="Vertical gap-0">
|
|
14
|
+
<div class="FrameHeader">
|
|
15
|
+
<div class="FrameHeaderDots">
|
|
16
|
+
<div class="FrameHeaderDot"></div>
|
|
17
|
+
<div class="FrameHeaderDot"></div>
|
|
18
|
+
<div class="FrameHeaderDot"></div>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="FrameHeaderTabs">
|
|
21
|
+
<slot name="tablist" />
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="FrameContent Stack {frameContentClass}">
|
|
25
|
+
<div class="Background">
|
|
26
|
+
<slot name="background" />
|
|
27
|
+
</div>
|
|
28
|
+
<div class="Content Vertical {contentClass}">
|
|
29
|
+
<slot name="tabpanels" />
|
|
30
|
+
<slot />
|
|
31
|
+
</div>
|
|
32
|
+
{#if options.resize}
|
|
33
|
+
<Resizer options={{ target: '.BrowserFrame', ...options.resize }} />
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let klass = ''
|
|
3
|
+
export { klass as class }
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div class="BrowserFrame {klass}">
|
|
7
|
+
<div class="Vertical gap-0">
|
|
8
|
+
<div class="FrameHeader">
|
|
9
|
+
<div class="FrameHeaderDots">
|
|
10
|
+
<div class="FrameHeaderDot"></div>
|
|
11
|
+
<div class="FrameHeaderDot"></div>
|
|
12
|
+
<div class="FrameHeaderDot"></div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="FrameHeaderTabs">
|
|
15
|
+
<slot name="tablist" />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="FrameContent Stack">
|
|
19
|
+
<div class="Background">
|
|
20
|
+
<slot name="background" />
|
|
21
|
+
</div>
|
|
22
|
+
<div class="Content Vertical">
|
|
23
|
+
<slot name="tabpanels" />
|
|
24
|
+
<slot />
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
let { containers, increment, startAt } = Astro.props
|
|
3
|
+
containers = containers || 10
|
|
4
|
+
increment = increment || 25 // px
|
|
5
|
+
startAt = startAt || 300 // px
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<div class="CQCheckerGrid">
|
|
9
|
+
{
|
|
10
|
+
[...Array(containers)].map((_, i) => {
|
|
11
|
+
const width = i * increment + startAt + 'px'
|
|
12
|
+
return (
|
|
13
|
+
<div class="Container" style={`width: ${width}`}>
|
|
14
|
+
<div class="size">{width}</div>
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
</div>
|