drab 2.8.4 → 2.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -67
- package/dist/components/Breakpoint.svelte +9 -13
- package/dist/components/Chord.svelte +30 -32
- package/dist/components/Chord.svelte.d.ts +8 -9
- package/dist/components/ContextMenu.svelte +75 -75
- package/dist/components/CopyButton.svelte +5 -5
- package/dist/components/DataTable.svelte +123 -150
- package/dist/components/DataTable.svelte.d.ts +47 -40
- package/dist/components/Details.svelte +103 -0
- package/dist/components/Details.svelte.d.ts +69 -0
- package/dist/components/Editor.svelte +33 -44
- package/dist/components/Editor.svelte.d.ts +18 -26
- package/dist/components/FullscreenButton.svelte +14 -19
- package/dist/components/FullscreenButton.svelte.d.ts +0 -2
- package/dist/components/Popover.svelte +63 -63
- package/dist/components/ShareButton.svelte +41 -44
- package/dist/components/Sheet.svelte +100 -100
- package/dist/components/Sheet.svelte.d.ts +1 -1
- package/dist/components/YouTube.svelte +9 -9
- package/dist/index.d.ts +5 -6
- package/dist/index.js +5 -6
- package/package.json +81 -82
- package/dist/components/Accordion.svelte +0 -189
- package/dist/components/Accordion.svelte.d.ts +0 -135
- package/dist/components/Tabs.svelte +0 -126
- package/dist/components/Tabs.svelte.d.ts +0 -115
- package/dist/util/messages.d.ts +0 -1
- package/dist/util/messages.js +0 -1
@@ -1,11 +1,11 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### Sheet
|
5
|
-
|
6
|
-
Creates a sheet element based on the `position` provided. `maxSize` is set to width or height of the sheet depending on the `position` provided. The `transition` is calculated based on the `position` and `maxSize` of the sheet.
|
7
|
-
|
8
|
-
@props
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### Sheet
|
5
|
+
|
6
|
+
Creates a sheet element based on the `position` provided. `maxSize` is set to width or height of the sheet depending on the `position` provided. The `transition` is calculated based on the `position` and `maxSize` of the sheet.
|
7
|
+
|
8
|
+
@props
|
9
9
|
|
10
10
|
- `classSheet` - sheet class - not the backdrop
|
11
11
|
- `class`
|
@@ -16,48 +16,48 @@ Creates a sheet element based on the `position` provided. `maxSize` is set to wi
|
|
16
16
|
- `transitionSheet` - flies the sheet, set to `false` to remove
|
17
17
|
- `transition` - blurs the entire component, set to `false` to remove
|
18
18
|
|
19
|
-
@slots
|
20
|
-
|
21
|
-
| name | purpose | default value |
|
22
|
-
| ---------- | ------------------------------- | ------------- |
|
23
|
-
| `default` | content | `Content` |
|
24
|
-
|
25
|
-
@example
|
19
|
+
@slots
|
20
|
+
|
21
|
+
| name | purpose | default value |
|
22
|
+
| ---------- | ------------------------------- | ------------- |
|
23
|
+
| `default` | content | `Content` |
|
24
|
+
|
25
|
+
@example
|
26
26
|
|
27
27
|
```svelte
|
28
|
-
<script lang="ts">
|
29
|
-
import { Sheet } from "drab";
|
30
|
-
|
31
|
-
let display = false;
|
32
|
-
</script>
|
33
|
-
|
34
|
-
<button type="button" class="btn" on:click={() => (display = true)}>
|
35
|
-
Open
|
36
|
-
</button>
|
37
|
-
|
38
|
-
<Sheet
|
39
|
-
bind:display
|
40
|
-
class="
|
41
|
-
classSheet="p-4 shadow bg-white"
|
42
|
-
position="right"
|
43
|
-
>
|
44
|
-
<div class="mb-4 flex items-center justify-between">
|
45
|
-
<h2 class="my-0">Sheet</h2>
|
46
|
-
<button type="button" class="btn btn-s" on:click={() => (display = false)}>
|
47
|
-
Close
|
48
|
-
</button>
|
49
|
-
</div>
|
50
|
-
<div>
|
51
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
52
|
-
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
53
|
-
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
54
|
-
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
55
|
-
cillum dolore eu fugiat nulla pariatur.
|
56
|
-
</div>
|
57
|
-
</Sheet>
|
28
|
+
<script lang="ts">
|
29
|
+
import { Sheet } from "drab";
|
30
|
+
|
31
|
+
let display = false;
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<button type="button" class="btn" on:click={() => (display = true)}>
|
35
|
+
Open
|
36
|
+
</button>
|
37
|
+
|
38
|
+
<Sheet
|
39
|
+
bind:display
|
40
|
+
class="backdrop-blur"
|
41
|
+
classSheet="p-4 shadow bg-white"
|
42
|
+
position="right"
|
43
|
+
>
|
44
|
+
<div class="mb-4 flex items-center justify-between">
|
45
|
+
<h2 class="my-0">Sheet</h2>
|
46
|
+
<button type="button" class="btn btn-s" on:click={() => (display = false)}>
|
47
|
+
Close
|
48
|
+
</button>
|
49
|
+
</div>
|
50
|
+
<div>
|
51
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
52
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
53
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
54
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
55
|
+
cillum dolore eu fugiat nulla pariatur.
|
56
|
+
</div>
|
57
|
+
</Sheet>
|
58
58
|
```
|
59
|
-
-->
|
60
|
-
|
59
|
+
-->
|
60
|
+
|
61
61
|
<script>import { onMount } from "svelte";
|
62
62
|
import {
|
63
63
|
blur,
|
@@ -101,56 +101,56 @@ onMount(() => {
|
|
101
101
|
transitionSheet = false;
|
102
102
|
}
|
103
103
|
});
|
104
|
-
</script>
|
105
|
-
|
106
|
-
<svelte:body on:keydown={onKeyDown} />
|
107
|
-
|
108
|
-
{#if display}
|
109
|
-
<div
|
110
|
-
transition:blur={transition ? transition : { duration: 0 }}
|
111
|
-
use:focusElement
|
112
|
-
class="d-backdrop {className}"
|
113
|
-
class:d-backdrop-bottom={position === "bottom"}
|
114
|
-
class:d-backdrop-top={position === "top"}
|
115
|
-
class:d-backdrop-right={position === "right"}
|
116
|
-
{id}
|
117
|
-
tabindex="-1"
|
118
|
-
>
|
119
|
-
<div
|
120
|
-
role="dialog"
|
121
|
-
bind:this={sheet}
|
122
|
-
transition:fly={transitionSheet ? transitionSheet : { duration: 0 }}
|
123
|
-
style={position === "top" || position === "bottom"
|
124
|
-
? `max-height: ${maxSize}px;`
|
125
|
-
: `max-width: ${maxSize}px`}
|
126
|
-
class={classSheet}
|
127
|
-
>
|
128
|
-
<slot>Content</slot>
|
129
|
-
</div>
|
130
|
-
<button title="Close" on:click={() => (display = false)}></button>
|
131
|
-
</div>
|
132
|
-
{/if}
|
133
|
-
|
134
|
-
<style>
|
135
|
-
button {
|
136
|
-
flex-grow: 1;
|
137
|
-
}
|
138
|
-
.d-backdrop {
|
139
|
-
position: fixed;
|
140
|
-
display: flex;
|
141
|
-
top: 0;
|
142
|
-
bottom: 0;
|
143
|
-
left: 0;
|
144
|
-
right: 0;
|
145
|
-
overflow: hidden;
|
146
|
-
}
|
147
|
-
.d-backdrop-bottom {
|
148
|
-
flex-direction: column-reverse;
|
149
|
-
}
|
150
|
-
.d-backdrop-top {
|
151
|
-
flex-direction: column;
|
152
|
-
}
|
153
|
-
.d-backdrop-right {
|
154
|
-
flex-direction: row-reverse;
|
155
|
-
}
|
156
|
-
</style>
|
104
|
+
</script>
|
105
|
+
|
106
|
+
<svelte:body on:keydown={onKeyDown} />
|
107
|
+
|
108
|
+
{#if display}
|
109
|
+
<div
|
110
|
+
transition:blur={transition ? transition : { duration: 0 }}
|
111
|
+
use:focusElement
|
112
|
+
class="d-backdrop {className}"
|
113
|
+
class:d-backdrop-bottom={position === "bottom"}
|
114
|
+
class:d-backdrop-top={position === "top"}
|
115
|
+
class:d-backdrop-right={position === "right"}
|
116
|
+
{id}
|
117
|
+
tabindex="-1"
|
118
|
+
>
|
119
|
+
<div
|
120
|
+
role="dialog"
|
121
|
+
bind:this={sheet}
|
122
|
+
transition:fly={transitionSheet ? transitionSheet : { duration: 0 }}
|
123
|
+
style={position === "top" || position === "bottom"
|
124
|
+
? `max-height: ${maxSize}px;`
|
125
|
+
: `max-width: ${maxSize}px`}
|
126
|
+
class={classSheet}
|
127
|
+
>
|
128
|
+
<slot>Content</slot>
|
129
|
+
</div>
|
130
|
+
<button title="Close" on:click={() => (display = false)}></button>
|
131
|
+
</div>
|
132
|
+
{/if}
|
133
|
+
|
134
|
+
<style>
|
135
|
+
button {
|
136
|
+
flex-grow: 1;
|
137
|
+
}
|
138
|
+
.d-backdrop {
|
139
|
+
position: fixed;
|
140
|
+
display: flex;
|
141
|
+
top: 0;
|
142
|
+
bottom: 0;
|
143
|
+
left: 0;
|
144
|
+
right: 0;
|
145
|
+
overflow: hidden;
|
146
|
+
}
|
147
|
+
.d-backdrop-bottom {
|
148
|
+
flex-direction: column-reverse;
|
149
|
+
}
|
150
|
+
.d-backdrop-top {
|
151
|
+
flex-direction: column;
|
152
|
+
}
|
153
|
+
.d-backdrop-right {
|
154
|
+
flex-direction: row-reverse;
|
155
|
+
}
|
156
|
+
</style>
|
@@ -17,15 +17,15 @@ Embeds a YouTube video `iframe` into a website with the video `uid`, using [www.
|
|
17
17
|
@example
|
18
18
|
|
19
19
|
```svelte
|
20
|
-
<script lang="ts">
|
21
|
-
import { YouTube } from "drab";
|
22
|
-
</script>
|
23
|
-
|
24
|
-
<YouTube
|
25
|
-
class="aspect-video w-full rounded"
|
26
|
-
title="Renegade - Kevin Olusola"
|
27
|
-
uid="gouiY85kD2o"
|
28
|
-
/>
|
20
|
+
<script lang="ts">
|
21
|
+
import { YouTube } from "drab";
|
22
|
+
</script>
|
23
|
+
|
24
|
+
<YouTube
|
25
|
+
class="aspect-video w-full rounded"
|
26
|
+
title="Renegade - Kevin Olusola"
|
27
|
+
uid="gouiY85kD2o"
|
28
|
+
/>
|
29
29
|
```
|
30
30
|
-->
|
31
31
|
|
package/dist/index.d.ts
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
import Accordion, { type AccordionItem } from "./components/Accordion.svelte";
|
2
1
|
import Breakpoint from "./components/Breakpoint.svelte";
|
3
|
-
import Chord
|
2
|
+
import Chord from "./components/Chord.svelte";
|
4
3
|
import ContextMenu from "./components/ContextMenu.svelte";
|
5
4
|
import CopyButton from "./components/CopyButton.svelte";
|
6
|
-
import DataTable
|
7
|
-
import
|
5
|
+
import DataTable from "./components/DataTable.svelte";
|
6
|
+
import Details from "./components/Details.svelte";
|
7
|
+
import Editor from "./components/Editor.svelte";
|
8
8
|
import FullscreenButton from "./components/FullscreenButton.svelte";
|
9
9
|
import Popover from "./components/Popover.svelte";
|
10
10
|
import ShareButton from "./components/ShareButton.svelte";
|
11
11
|
import Sheet from "./components/Sheet.svelte";
|
12
|
-
import Tabs, { type TabsItem } from "./components/Tabs.svelte";
|
13
12
|
import YouTube from "./components/YouTube.svelte";
|
14
|
-
export {
|
13
|
+
export { Breakpoint, Chord, ContextMenu, CopyButton, DataTable, Details, Editor, FullscreenButton, Popover, ShareButton, Sheet, YouTube, };
|
package/dist/index.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
import Accordion, {} from "./components/Accordion.svelte";
|
2
1
|
import Breakpoint from "./components/Breakpoint.svelte";
|
3
|
-
import Chord
|
2
|
+
import Chord from "./components/Chord.svelte";
|
4
3
|
import ContextMenu from "./components/ContextMenu.svelte";
|
5
4
|
import CopyButton from "./components/CopyButton.svelte";
|
6
|
-
import DataTable
|
7
|
-
import
|
5
|
+
import DataTable from "./components/DataTable.svelte";
|
6
|
+
import Details from "./components/Details.svelte";
|
7
|
+
import Editor from "./components/Editor.svelte";
|
8
8
|
import FullscreenButton from "./components/FullscreenButton.svelte";
|
9
9
|
import Popover from "./components/Popover.svelte";
|
10
10
|
import ShareButton from "./components/ShareButton.svelte";
|
11
11
|
import Sheet from "./components/Sheet.svelte";
|
12
|
-
import Tabs, {} from "./components/Tabs.svelte";
|
13
12
|
import YouTube from "./components/YouTube.svelte";
|
14
|
-
export {
|
13
|
+
export { Breakpoint, Chord, ContextMenu, CopyButton, DataTable, Details, Editor, FullscreenButton, Popover, ShareButton, Sheet, YouTube, };
|
package/package.json
CHANGED
@@ -1,82 +1,81 @@
|
|
1
|
-
{
|
2
|
-
"name": "drab",
|
3
|
-
"version": "2.8.
|
4
|
-
"description": "An unstyled Svelte component library",
|
5
|
-
"keywords": [
|
6
|
-
"components",
|
7
|
-
"Svelte",
|
8
|
-
"SvelteKit",
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"Editor",
|
16
|
-
"Fullscreen",
|
17
|
-
"Popover",
|
18
|
-
"Share",
|
19
|
-
"Sheet",
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
"
|
25
|
-
|
26
|
-
"
|
27
|
-
|
28
|
-
|
29
|
-
"
|
30
|
-
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"
|
40
|
-
"
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
"
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
"@sveltejs/
|
57
|
-
"@sveltejs/
|
58
|
-
"@
|
59
|
-
"@
|
60
|
-
"@
|
61
|
-
"@typescript-eslint/
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"eslint": "^
|
65
|
-
"eslint-
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"prettier": "^3.0.
|
70
|
-
"prettier-plugin-
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
|
78
|
-
|
79
|
-
"
|
80
|
-
"
|
81
|
-
|
82
|
-
}
|
1
|
+
{
|
2
|
+
"name": "drab",
|
3
|
+
"version": "2.8.6",
|
4
|
+
"description": "An unstyled Svelte component library",
|
5
|
+
"keywords": [
|
6
|
+
"components",
|
7
|
+
"Svelte",
|
8
|
+
"SvelteKit",
|
9
|
+
"Breakpoint",
|
10
|
+
"Chord",
|
11
|
+
"ContextMenu",
|
12
|
+
"Copy",
|
13
|
+
"DataTable",
|
14
|
+
"Details",
|
15
|
+
"Editor",
|
16
|
+
"Fullscreen",
|
17
|
+
"Popover",
|
18
|
+
"Share",
|
19
|
+
"Sheet",
|
20
|
+
"YouTube"
|
21
|
+
],
|
22
|
+
"homepage": "https://drab.robino.dev",
|
23
|
+
"license": "MIT",
|
24
|
+
"author": {
|
25
|
+
"name": "Ross Robino",
|
26
|
+
"url": "https://robino.dev"
|
27
|
+
},
|
28
|
+
"repository": "github:rossrobino/drab",
|
29
|
+
"scripts": {
|
30
|
+
"dev": "vite dev",
|
31
|
+
"build": "vite build && npm run package",
|
32
|
+
"preview": "vite preview",
|
33
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
34
|
+
"prepublishOnly": "npm run package",
|
35
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
36
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
37
|
+
"lint": "prettier --check . && eslint .",
|
38
|
+
"format": "prettier --write . --plugin=prettier-plugin-svelte --plugin=prettier-plugin-tailwindcss",
|
39
|
+
"pub": "npm publish --access public",
|
40
|
+
"doc": "node src/scripts/documentProps.js && node src/scripts/documentExamples.js && node src/scripts/copyReadMe.js"
|
41
|
+
},
|
42
|
+
"exports": {
|
43
|
+
".": {
|
44
|
+
"types": "./dist/index.d.ts",
|
45
|
+
"svelte": "./dist/index.js"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"files": [
|
49
|
+
"dist"
|
50
|
+
],
|
51
|
+
"dependencies": {
|
52
|
+
"svelte": "^4.2.0"
|
53
|
+
},
|
54
|
+
"devDependencies": {
|
55
|
+
"@sveltejs/adapter-vercel": "^3.0.3",
|
56
|
+
"@sveltejs/kit": "^1.22.6",
|
57
|
+
"@sveltejs/package": "^2.2.1",
|
58
|
+
"@tailwindcss/typography": "^0.5.9",
|
59
|
+
"@types/node": "^20.5.1",
|
60
|
+
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
61
|
+
"@typescript-eslint/parser": "^6.4.0",
|
62
|
+
"autoprefixer": "^10.4.15",
|
63
|
+
"eslint": "^8.47.0",
|
64
|
+
"eslint-config-prettier": "^9.0.0",
|
65
|
+
"eslint-plugin-svelte": "^2.32.4",
|
66
|
+
"marked": "^7.0.4",
|
67
|
+
"postcss": "^8.4.28",
|
68
|
+
"prettier": "^3.0.2",
|
69
|
+
"prettier-plugin-svelte": "^3.0.3",
|
70
|
+
"prettier-plugin-tailwindcss": "^0.5.3",
|
71
|
+
"publint": "^0.2.1",
|
72
|
+
"svelte-check": "^3.5.0",
|
73
|
+
"tailwindcss": "^3.3.3",
|
74
|
+
"tslib": "^2.6.2",
|
75
|
+
"typescript": "^5.1.6",
|
76
|
+
"vite": "^4.4.9"
|
77
|
+
},
|
78
|
+
"svelte": "./dist/index.js",
|
79
|
+
"types": "./dist/index.d.ts",
|
80
|
+
"type": "module"
|
81
|
+
}
|
@@ -1,189 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### Accordion
|
5
|
-
|
6
|
-
Displays a list of `details` elements with helpful defaults and transitions.
|
7
|
-
|
8
|
-
@props
|
9
|
-
|
10
|
-
- `autoClose` - if `true`, other items close when a new one is opened
|
11
|
-
- `classContent` - class of all the `div`s that wrap the `content` slot
|
12
|
-
- `classDetails` - class of the `div` around each `details` element
|
13
|
-
- `classIcon` - class of the `div` that wraps the icon if displayed
|
14
|
-
- `classSummary` - class of all the `summary` elements
|
15
|
-
- `class`
|
16
|
-
- `data` - data to display in the accordion
|
17
|
-
- `icon`
|
18
|
-
- `id`
|
19
|
-
- `transition` - rotates the icon, slides the content, set to `false` to remove
|
20
|
-
|
21
|
-
@slots
|
22
|
-
|
23
|
-
| name | purpose | default value | slot props |
|
24
|
-
| --------- | ----------------------------- | -------------- | --------------- |
|
25
|
-
| `summary` | summary element | `item.summary` | `item`, `index` |
|
26
|
-
| `icon` | icon element | `icon` prop | `item`, `index` |
|
27
|
-
| `content` | content of the accordion item | `item.content` | `item`, `index` |
|
28
|
-
|
29
|
-
@example
|
30
|
-
|
31
|
-
```svelte
|
32
|
-
<script lang="ts">
|
33
|
-
import { Accordion, type AccordionItem, FullscreenButton } from "drab";
|
34
|
-
import Chevron from "../../site/svg/Chevron.svelte";
|
35
|
-
|
36
|
-
const data: AccordionItem[] = [
|
37
|
-
{ summary: "Is it accessible?", content: "Yes." },
|
38
|
-
{
|
39
|
-
summary: "Is it styled?",
|
40
|
-
content: "Nope, style with global styles.",
|
41
|
-
},
|
42
|
-
{
|
43
|
-
summary: "Is it animated?",
|
44
|
-
content: "Yes, with the transition prop.",
|
45
|
-
},
|
46
|
-
{
|
47
|
-
summary: "Is it customizable?",
|
48
|
-
content: "Yes, customize with slots.",
|
49
|
-
class: "uppercase",
|
50
|
-
component: FullscreenButton,
|
51
|
-
},
|
52
|
-
{ summary: "Does it work without JavaScript?", content: "Yes." },
|
53
|
-
];
|
54
|
-
</script>
|
55
|
-
|
56
|
-
<Accordion
|
57
|
-
{data}
|
58
|
-
icon={Chevron}
|
59
|
-
class="mb-12"
|
60
|
-
classDetails="border-b"
|
61
|
-
classSummary="flex gap-8 cursor-pointer items-center justify-between p-4 font-bold underline hover:decoration-dotted"
|
62
|
-
classContent="pb-4 px-4"
|
63
|
-
/>
|
64
|
-
|
65
|
-
<Accordion
|
66
|
-
{data}
|
67
|
-
icon={Chevron}
|
68
|
-
classDetails="border-b"
|
69
|
-
classSummary="flex gap-8 cursor-pointer items-center justify-between p-4 font-bold underline hover:decoration-dotted"
|
70
|
-
classContent="pb-4 px-4"
|
71
|
-
autoClose={false}
|
72
|
-
>
|
73
|
-
<svelte:fragment slot="summary" let:item let:index>
|
74
|
-
<span class={item.class ? item.class : ""}>
|
75
|
-
{index + 1}.
|
76
|
-
{item.summary}
|
77
|
-
</span>
|
78
|
-
</svelte:fragment>
|
79
|
-
<svelte:fragment slot="content" let:item>
|
80
|
-
<span>{item.content}</span>
|
81
|
-
{#if item.component === FullscreenButton}
|
82
|
-
<div><svelte:component this={FullscreenButton} class="btn mt-4" /></div>
|
83
|
-
{/if}
|
84
|
-
</svelte:fragment>
|
85
|
-
</Accordion>
|
86
|
-
```
|
87
|
-
-->
|
88
|
-
|
89
|
-
<script context="module"></script>
|
90
|
-
|
91
|
-
<script>import { onMount } from "svelte";
|
92
|
-
import { slide } from "svelte/transition";
|
93
|
-
import { prefersReducedMotion } from "../util/accessibility";
|
94
|
-
import { duration } from "../util/transition";
|
95
|
-
let className = "";
|
96
|
-
export { className as class };
|
97
|
-
export let id = "";
|
98
|
-
export let data;
|
99
|
-
export let icon = "";
|
100
|
-
export let classDetails = "";
|
101
|
-
export let classSummary = "";
|
102
|
-
export let classContent = "";
|
103
|
-
export let classIcon = "";
|
104
|
-
export let transition = { duration };
|
105
|
-
export let autoClose = true;
|
106
|
-
let clientJs = false;
|
107
|
-
const toggleOpen = (i) => {
|
108
|
-
data[i].open = !data[i].open;
|
109
|
-
if (autoClose) {
|
110
|
-
for (let j = 0; j < data.length; j++) {
|
111
|
-
if (j !== i)
|
112
|
-
data[j].open = false;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
};
|
116
|
-
onMount(() => {
|
117
|
-
clientJs = true;
|
118
|
-
if (prefersReducedMotion())
|
119
|
-
transition = false;
|
120
|
-
});
|
121
|
-
</script>
|
122
|
-
|
123
|
-
<div class={className} {id}>
|
124
|
-
{#each data as item, index}
|
125
|
-
<div class={classDetails}>
|
126
|
-
<details bind:open={item.open}>
|
127
|
-
<!-- svelte-ignore a11y-no-redundant-roles -->
|
128
|
-
<summary
|
129
|
-
role="button"
|
130
|
-
tabindex="0"
|
131
|
-
class={classSummary}
|
132
|
-
on:click|preventDefault={() => toggleOpen(index)}
|
133
|
-
on:keydown={(e) => {
|
134
|
-
if (e.key === "Enter") {
|
135
|
-
e.preventDefault();
|
136
|
-
toggleOpen(index);
|
137
|
-
}
|
138
|
-
}}
|
139
|
-
>
|
140
|
-
<slot name="summary" {item} {index}>{item.summary}</slot>
|
141
|
-
<slot name="icon" {item} {index}>
|
142
|
-
{#if icon}
|
143
|
-
<div
|
144
|
-
class={classIcon}
|
145
|
-
class:d-rotate-180={item.open}
|
146
|
-
class:d-transition={transition}
|
147
|
-
style="--duration: {transition ? transition.duration : 0}ms;"
|
148
|
-
>
|
149
|
-
{#if typeof icon !== "string"}
|
150
|
-
<svelte:component this={icon} />
|
151
|
-
{:else}
|
152
|
-
<span>{icon}</span>
|
153
|
-
{/if}
|
154
|
-
</div>
|
155
|
-
{/if}
|
156
|
-
</slot>
|
157
|
-
</summary>
|
158
|
-
{#if !clientJs || !transition}
|
159
|
-
<div class={classContent}>
|
160
|
-
<slot name="content" {item} {index}>{item.content}</slot>
|
161
|
-
</div>
|
162
|
-
{/if}
|
163
|
-
</details>
|
164
|
-
{#if clientJs && item.open && transition}
|
165
|
-
<!-- outside the details for the transition -->
|
166
|
-
<div class={classContent} transition:slide={transition}>
|
167
|
-
<slot name="content" {item} {index}>{item.content}</slot>
|
168
|
-
</div>
|
169
|
-
{/if}
|
170
|
-
</div>
|
171
|
-
{/each}
|
172
|
-
</div>
|
173
|
-
|
174
|
-
<style>
|
175
|
-
summary {
|
176
|
-
list-style: none;
|
177
|
-
}
|
178
|
-
summary::-webkit-details-marker {
|
179
|
-
display: none;
|
180
|
-
}
|
181
|
-
.d-rotate-180 {
|
182
|
-
transform: rotate(180deg);
|
183
|
-
}
|
184
|
-
.d-transition {
|
185
|
-
transition-property: transform;
|
186
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
187
|
-
transition-duration: var(--duration);
|
188
|
-
}
|
189
|
-
</style>
|