drab 2.8.7 → 3.0.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/README.md +11 -9
- package/dist/components/Breakpoint.svelte +1 -1
- package/dist/components/Breakpoint.svelte.d.ts +1 -1
- package/dist/components/ContextMenu.svelte +1 -2
- package/dist/components/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/DataTable.svelte +16 -10
- package/dist/components/DataTable.svelte.d.ts +15 -9
- package/dist/components/Details.svelte +2 -2
- package/dist/components/Details.svelte.d.ts +2 -2
- package/dist/components/Editor.svelte +9 -9
- package/dist/components/Editor.svelte.d.ts +6 -6
- package/dist/components/{Chord.svelte → FrettedChord.svelte} +9 -7
- package/dist/components/{Chord.svelte.d.ts → FrettedChord.svelte.d.ts} +13 -11
- package/dist/components/FullscreenButton.svelte +8 -3
- package/dist/components/FullscreenButton.svelte.d.ts +1 -1
- package/dist/components/Popover.svelte +8 -5
- package/dist/components/Popover.svelte.d.ts +5 -2
- package/dist/components/Sheet.svelte +9 -9
- package/dist/components/Sheet.svelte.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# An Unstyled Svelte Component Library
|
2
2
|
|
3
|
+
- [Docs](https://drab.robino.dev)
|
3
4
|
- [GitHub](https://github.com/rossrobino/drab)
|
4
5
|
- [npm](https://www.npmjs.com/package/drab)
|
5
6
|
- [MIT License](https://github.com/rossrobino/drab/blob/main/LICENSE.md)
|
6
|
-
- One dependency - [Svelte](https://svelte.dev)
|
7
7
|
|
8
8
|
## About
|
9
9
|
|
10
|
-
**drab** focuses on providing JavaScript functionality where it's most useful. Whenever possible, components are [progressively enhanced](/docs/ShareButton) or provide a fallback [noscript](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript) message. Additionally, transitions are disabled for users who prefer reduced motion.
|
10
|
+
**drab** focuses on providing JavaScript functionality where it's most useful. Many of the components are helpful wrappers around browser APIs. Whenever possible, components are [progressively enhanced](/docs/ShareButton) or provide a fallback [noscript](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript) message. Additionally, transitions are disabled for users who prefer reduced motion.
|
11
11
|
|
12
|
-
This library takes a more opinionated approach compared to some headless UI libraries by providing the basic HTML structure for every component, as well as default positioning for elements like the [sheet](/docs/Sheet)
|
12
|
+
This library takes a more opinionated approach compared to some headless UI libraries by providing the basic HTML structure for every component, as well as default positioning for elements like the [sheet](/docs/Sheet). However, these components can still be further customized using styles, [slots](https://svelte.dev/tutorial/slots), and [slot props](https://svelte.dev/tutorial/slot-props).
|
13
13
|
|
14
14
|
Components without styles can appear rather drab. You have the freedom to bring your own styles to these components! Using unstyled components allows you to selectively choose what you need, seamlessly integrate with existing designs, and avoid being tied to any specific library.
|
15
15
|
|
16
|
-
To style the components, you can make use of [global styles](https://joyofcode.xyz/global-styles-in-sveltekit). This process can be expedited by utilizing CSS frameworks like [TailwindCSS](https://tailwindcss.com/).
|
16
|
+
To style the components, you can make use of [global styles](https://joyofcode.xyz/global-styles-in-sveltekit). Each component exports `class` and `id` props that can be leveraged for this purpose. This process can be expedited by utilizing CSS frameworks like [TailwindCSS](https://tailwindcss.com/). Tailwind generates a global stylesheet based on the utility classes used in your project. The examples in this documentation are styled with Tailwind classes, but Tailwind does not have to be used with this library.
|
17
17
|
|
18
18
|
## Install
|
19
19
|
|
20
|
-
If you haven't used Svelte before, start with the [tutorial](https://svelte.dev/tutorial/basics).
|
20
|
+
If you haven't used Svelte before, start with the [tutorial](https://svelte.dev/tutorial/basics). **drab** works anywhere Svelte does.
|
21
21
|
|
22
22
|
- [SvelteKit](https://kit.svelte.dev)
|
23
23
|
- [Astro](https://docs.astro.build/en/tutorial/1-setup/2/)
|
@@ -44,7 +44,9 @@ If **drab** isn't what you are looking for, here are some other Svelte UI librar
|
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
Find an bug or have an idea? Feel free to create an issue on [GitHub](https://github.com/rossrobino/drab).
|
47
|
+
Find an bug or have an idea? Feel free to create an issue on [GitHub](https://github.com/rossrobino/drab). **drab** is meant to house all kinds of components including ones outside of the standard UI elements.
|
48
|
+
|
49
|
+
Currently, **drab** has only one dependency - Svelte. Not to say it will never have another, but please consider this when adding in additional functionality. **drab** is meant to make the web platform easier to use with Svelte.
|
48
50
|
|
49
51
|
Since this is an unstyled library, simple components like a badge that can be easily created with HTML and CSS are not included.
|
50
52
|
|
@@ -60,8 +62,8 @@ Contribute to the project, or use **drab** as a template for another component l
|
|
60
62
|
|
61
63
|
#### Add or edit a component
|
62
64
|
|
63
|
-
1. Add
|
64
|
-
2. Add
|
65
|
-
3. Document the component with an `@component` comment, include a description, and the `@slots` available. Add a placeholder `@props` and `@example` to the comment. These sections will be generated based on the JSDoc comment above each prop and the example route
|
65
|
+
1. Add or edit the component in `src/lib/components/Component.svelte` - if you're adding a new one, copy and paste an existing one to get started with the conventions
|
66
|
+
2. Add or edit the example in `src/routes/docs/Component/+page.svelte`
|
67
|
+
3. Document the component with an `@component` comment, include a description, and the `@slots` available. Add a placeholder `@props` and `@example` to the comment. These sections will be generated based on the JSDoc comment above each prop and the example route upon running `npm run doc`
|
66
68
|
4. If new, add the link to `src/site/components/NavItems.svelte`
|
67
69
|
5. Run `npm run build` to verify your build
|
@@ -21,7 +21,7 @@ With SvelteKit, this component can be wrapped in an `{#if dev}` block that check
|
|
21
21
|
</script>
|
22
22
|
|
23
23
|
<Breakpoint
|
24
|
-
class="inline-block rounded border px-2 py-1 font-mono tabular-nums shadow"
|
24
|
+
class="inline-block rounded border bg-white px-2 py-1 font-mono tabular-nums shadow"
|
25
25
|
/>
|
26
26
|
```
|
27
27
|
-->
|
@@ -37,7 +37,7 @@ export type BreakpointSlots = typeof __propDef.slots;
|
|
37
37
|
* </script>
|
38
38
|
*
|
39
39
|
* <Breakpoint
|
40
|
-
* class="inline-block rounded border px-2 py-1 font-mono tabular-nums shadow"
|
40
|
+
* class="inline-block rounded border bg-white px-2 py-1 font-mono tabular-nums shadow"
|
41
41
|
* />
|
42
42
|
* ```
|
43
43
|
*/
|
@@ -43,7 +43,7 @@ Displays when the `target` element is right clicked, or long pressed on mobile.
|
|
43
43
|
<button type="button" class="btn" bind:this={target}>Target Right Click</button>
|
44
44
|
<ContextMenu {target}>
|
45
45
|
<div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
|
46
|
-
<div class="font-bold">
|
46
|
+
<div class="font-bold">Target</div>
|
47
47
|
<button role="menuitem" class="btn">Button</button>
|
48
48
|
<button role="menuitem" class="btn">Button</button>
|
49
49
|
<button role="menuitem" class="btn">Button</button>
|
@@ -144,6 +144,5 @@ onMount(async () => {
|
|
144
144
|
}
|
145
145
|
div {
|
146
146
|
position: absolute;
|
147
|
-
z-index: 10;
|
148
147
|
}
|
149
148
|
</style>
|
@@ -61,7 +61,7 @@ export type ContextMenuSlots = typeof __propDef.slots;
|
|
61
61
|
* <button type="button" class="btn" bind:this={target}>Target Right Click</button>
|
62
62
|
* <ContextMenu {target}>
|
63
63
|
* <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
|
64
|
-
* <div class="font-bold">
|
64
|
+
* <div class="font-bold">Target</div>
|
65
65
|
* <button role="menuitem" class="btn">Button</button>
|
66
66
|
* <button role="menuitem" class="btn">Button</button>
|
67
67
|
* <button role="menuitem" class="btn">Button</button>
|
@@ -3,7 +3,13 @@
|
|
3
3
|
|
4
4
|
### DataTable
|
5
5
|
|
6
|
-
Data table to display an array of
|
6
|
+
Data table to display an array of objects. Works with zero configuration, just pass an array of objects into the `data` prop.
|
7
|
+
|
8
|
+
- Set the `maxRows` prop to enable pagination, bind to `currentPage` to navigate (see second example below)
|
9
|
+
- Provides sorting for `number`, `string`, `boolean`, and `Date`
|
10
|
+
- Strings are sorted using `Intl.Collator`
|
11
|
+
- Style or modify the rendering of data with slot props
|
12
|
+
- `numberOfPages` is calculated and sent back through the `controls` slot
|
7
13
|
|
8
14
|
@props
|
9
15
|
|
@@ -25,11 +31,11 @@ Data table to display an array of JS objects. Provides pagination and sorting fo
|
|
25
31
|
|
26
32
|
@slots
|
27
33
|
|
28
|
-
| name | purpose
|
29
|
-
| ---------- |
|
30
|
-
| `controls` | helper that passes back `maxRows` and `numberOfPages` |
|
31
|
-
| `td` | td contents
|
32
|
-
| `th` | th contents
|
34
|
+
| name | purpose | default value | slot props |
|
35
|
+
| ---------- | ---------------------------------------------------------------- | ------------- | ------------------------------- |
|
36
|
+
| `controls` | helper that passes back `maxRows` and calculated `numberOfPages` | empty | `maxRows`, `numberOfPages` |
|
37
|
+
| `td` | td contents | `value` | `item`, `key`, `sortBy` `value` |
|
38
|
+
| `th` | th contents | `key` | `key`, `sortBy` |
|
33
39
|
|
34
40
|
@example
|
35
41
|
|
@@ -78,9 +84,9 @@ Data table to display an array of JS objects. Provides pagination and sorting fo
|
|
78
84
|
</svelte:fragment>
|
79
85
|
<svelte:fragment slot="controls" let:maxRows let:numberOfPages>
|
80
86
|
{#if maxRows}
|
81
|
-
<div class="flex items-center justify-between">
|
82
|
-
<div>{currentPage + 1} / {numberOfPages}</div>
|
83
|
-
<div>
|
87
|
+
<div class="flex items-center justify-between gap-4">
|
88
|
+
<div class="min-w-fit">{currentPage + 1} / {numberOfPages}</div>
|
89
|
+
<div class="flex gap-2">
|
84
90
|
<button
|
85
91
|
type="button"
|
86
92
|
class="btn"
|
@@ -129,6 +135,7 @@ const sort = (key, toggleAscending = true) => {
|
|
129
135
|
} else {
|
130
136
|
ascending = true;
|
131
137
|
}
|
138
|
+
const collator = new Intl.Collator();
|
132
139
|
data.sort((a, b) => {
|
133
140
|
const aVal = a[key];
|
134
141
|
const bVal = b[key];
|
@@ -139,7 +146,6 @@ const sort = (key, toggleAscending = true) => {
|
|
139
146
|
return bVal - aVal;
|
140
147
|
}
|
141
148
|
} else if (typeof aVal === "string" && typeof bVal === "string") {
|
142
|
-
const collator = new Intl.Collator();
|
143
149
|
if (ascending) {
|
144
150
|
return collator.compare(aVal, bVal);
|
145
151
|
} else {
|
@@ -43,7 +43,13 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
43
43
|
/**
|
44
44
|
* ### DataTable
|
45
45
|
*
|
46
|
-
* Data table to display an array of
|
46
|
+
* Data table to display an array of objects. Works with zero configuration, just pass an array of objects into the `data` prop.
|
47
|
+
*
|
48
|
+
* - Set the `maxRows` prop to enable pagination, bind to `currentPage` to navigate (see second example below)
|
49
|
+
* - Provides sorting for `number`, `string`, `boolean`, and `Date`
|
50
|
+
* - Strings are sorted using `Intl.Collator`
|
51
|
+
* - Style or modify the rendering of data with slot props
|
52
|
+
* - `numberOfPages` is calculated and sent back through the `controls` slot
|
47
53
|
*
|
48
54
|
* @props
|
49
55
|
*
|
@@ -65,11 +71,11 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
65
71
|
*
|
66
72
|
* @slots
|
67
73
|
*
|
68
|
-
* | name | purpose
|
69
|
-
* | ---------- |
|
70
|
-
* | `controls` | helper that passes back `maxRows` and `numberOfPages` |
|
71
|
-
* | `td` | td contents
|
72
|
-
* | `th` | th contents
|
74
|
+
* | name | purpose | default value | slot props |
|
75
|
+
* | ---------- | ---------------------------------------------------------------- | ------------- | ------------------------------- |
|
76
|
+
* | `controls` | helper that passes back `maxRows` and calculated `numberOfPages` | empty | `maxRows`, `numberOfPages` |
|
77
|
+
* | `td` | td contents | `value` | `item`, `key`, `sortBy` `value` |
|
78
|
+
* | `th` | th contents | `key` | `key`, `sortBy` |
|
73
79
|
*
|
74
80
|
* @example
|
75
81
|
*
|
@@ -118,9 +124,9 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
118
124
|
* </svelte:fragment>
|
119
125
|
* <svelte:fragment slot="controls" let:maxRows let:numberOfPages>
|
120
126
|
* {#if maxRows}
|
121
|
-
* <div class="flex items-center justify-between">
|
122
|
-
* <div>{currentPage + 1} / {numberOfPages}</div>
|
123
|
-
* <div>
|
127
|
+
* <div class="flex items-center justify-between gap-4">
|
128
|
+
* <div class="min-w-fit">{currentPage + 1} / {numberOfPages}</div>
|
129
|
+
* <div class="flex gap-2">
|
124
130
|
* <button
|
125
131
|
* type="button"
|
126
132
|
* class="btn"
|
@@ -16,8 +16,8 @@ Displays a `details` element with helpful defaults and transitions. Can be used
|
|
16
16
|
|
17
17
|
| name | purpose | default value | slot props |
|
18
18
|
| --------- | ------------------------------- | -------------- | ---------- |
|
19
|
-
| `summary` | `summary` element contents |
|
20
|
-
| `content` | contents when details is `open` |
|
19
|
+
| `summary` | `summary` element contents | empty | `open` |
|
20
|
+
| `content` | contents when details is `open` | empty | none |
|
21
21
|
|
22
22
|
@example
|
23
23
|
|
@@ -36,8 +36,8 @@ export type DetailsSlots = typeof __propDef.slots;
|
|
36
36
|
*
|
37
37
|
* | name | purpose | default value | slot props |
|
38
38
|
* | --------- | ------------------------------- | -------------- | ---------- |
|
39
|
-
* | `summary` | `summary` element contents |
|
40
|
-
* | `content` | contents when details is `open` |
|
39
|
+
* | `summary` | `summary` element contents | empty | `open` |
|
40
|
+
* | `content` | contents when details is `open` | empty | none |
|
41
41
|
*
|
42
42
|
* @example
|
43
43
|
*
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
### Editor
|
5
5
|
|
6
|
-
`textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors,
|
6
|
+
`textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors, the `valueTextarea` is just a `string`, so you can easily store it in a database or manipulate it without learning a separate API.
|
7
7
|
|
8
8
|
- This component is used to create [Typo](https://typo.robino.dev)
|
9
9
|
|
@@ -35,13 +35,13 @@
|
|
35
35
|
placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
|
36
36
|
contentElements={[
|
37
37
|
{
|
38
|
-
|
38
|
+
title: "Bullet",
|
39
39
|
text: "- ",
|
40
40
|
display: "block",
|
41
41
|
icon: "Bullet",
|
42
42
|
},
|
43
43
|
{
|
44
|
-
|
44
|
+
title: "Italic",
|
45
45
|
text: "*",
|
46
46
|
display: "wrap",
|
47
47
|
icon: "Italic",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
class: "italic",
|
50
50
|
},
|
51
51
|
{
|
52
|
-
|
52
|
+
title: "Anchor",
|
53
53
|
text: "[text](href)",
|
54
54
|
display: "inline",
|
55
55
|
icon: "Anchor",
|
@@ -177,7 +177,7 @@ const onKeyDown = async (e) => {
|
|
177
177
|
display: "inline",
|
178
178
|
text: " ",
|
179
179
|
icon: "tab",
|
180
|
-
|
180
|
+
title: "tab"
|
181
181
|
});
|
182
182
|
}
|
183
183
|
} else if (e.key === "Enter") {
|
@@ -197,7 +197,7 @@ const onKeyDown = async (e) => {
|
|
197
197
|
text: `
|
198
198
|
${repeat}`,
|
199
199
|
icon: "",
|
200
|
-
|
200
|
+
title: ""
|
201
201
|
});
|
202
202
|
} else if (repeat && original.length === columnNumber) {
|
203
203
|
e.preventDefault();
|
@@ -217,7 +217,7 @@ ${repeat}`,
|
|
217
217
|
text: `
|
218
218
|
`,
|
219
219
|
icon: "",
|
220
|
-
|
220
|
+
title: ""
|
221
221
|
});
|
222
222
|
}, 0);
|
223
223
|
}
|
@@ -241,7 +241,7 @@ ${repeat}`,
|
|
241
241
|
display: "wrap",
|
242
242
|
text: e.key,
|
243
243
|
icon: "",
|
244
|
-
|
244
|
+
title: ""
|
245
245
|
});
|
246
246
|
openChars.push(e.key);
|
247
247
|
}
|
@@ -363,7 +363,7 @@ onMount(() => clientJs = true);
|
|
363
363
|
type="button"
|
364
364
|
class={el.class ? `${classButton} ${el.class}` : classButton}
|
365
365
|
on:click={() => addContent(el)}
|
366
|
-
title={el.
|
366
|
+
title={el.title}
|
367
367
|
disabled={!clientJs}
|
368
368
|
>
|
369
369
|
{#if typeof el.icon !== "string"}
|
@@ -3,8 +3,8 @@ import { type ComponentType } from "svelte";
|
|
3
3
|
declare const __propDef: {
|
4
4
|
props: {
|
5
5
|
/** an array of `EditorContentElement`s for the controls */ contentElements?: {
|
6
|
-
/**
|
7
|
-
|
6
|
+
/** title of element and it's corresponding button */
|
7
|
+
title: string;
|
8
8
|
/** text to add */
|
9
9
|
text: string;
|
10
10
|
/** controls how the text is added */
|
@@ -42,7 +42,7 @@ export type EditorSlots = typeof __propDef.slots;
|
|
42
42
|
/**
|
43
43
|
* ### Editor
|
44
44
|
*
|
45
|
-
* `textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors,
|
45
|
+
* `textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors, the `valueTextarea` is just a `string`, so you can easily store it in a database or manipulate it without learning a separate API.
|
46
46
|
*
|
47
47
|
* - This component is used to create [Typo](https://typo.robino.dev)
|
48
48
|
*
|
@@ -74,13 +74,13 @@ export type EditorSlots = typeof __propDef.slots;
|
|
74
74
|
* placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
|
75
75
|
* contentElements={[
|
76
76
|
* {
|
77
|
-
*
|
77
|
+
* title: "Bullet",
|
78
78
|
* text: "- ",
|
79
79
|
* display: "block",
|
80
80
|
* icon: "Bullet",
|
81
81
|
* },
|
82
82
|
* {
|
83
|
-
*
|
83
|
+
* title: "Italic",
|
84
84
|
* text: "*",
|
85
85
|
* display: "wrap",
|
86
86
|
* icon: "Italic",
|
@@ -88,7 +88,7 @@ export type EditorSlots = typeof __propDef.slots;
|
|
88
88
|
* class: "italic",
|
89
89
|
* },
|
90
90
|
* {
|
91
|
-
*
|
91
|
+
* title: "Anchor",
|
92
92
|
* text: "[text](href)",
|
93
93
|
* display: "inline",
|
94
94
|
* icon: "Anchor",
|
@@ -1,9 +1,11 @@
|
|
1
1
|
<!--
|
2
2
|
@component
|
3
3
|
|
4
|
-
###
|
4
|
+
### FrettedChord
|
5
5
|
|
6
|
-
Generates a
|
6
|
+
Generates a fretted chord `svg` for instruments like guitar and ukulele.
|
7
|
+
|
8
|
+
Try it out and generate code: [FrettedChord Creator](https://svelte.dev/repl/5771d5c3f3c34137a174c8c402ca0b2d?version=4.2.0)
|
7
9
|
|
8
10
|
@props
|
9
11
|
|
@@ -11,18 +13,18 @@ Generates a guitar chord `svg`.
|
|
11
13
|
- `id`
|
12
14
|
- `name` - name of chord
|
13
15
|
- `notes` - list of the positioning of the notes required for the chord
|
14
|
-
- `size` - total size of chord square
|
16
|
+
- `size` - total size of chord square in pixels, defaults to `150`
|
15
17
|
- `strings` - total number of strings for the instrument
|
16
18
|
|
17
19
|
@example
|
18
20
|
|
19
21
|
```svelte
|
20
22
|
<script lang="ts">
|
21
|
-
import {
|
23
|
+
import { FrettedChord } from "drab";
|
22
24
|
</script>
|
23
25
|
|
24
|
-
<
|
25
|
-
class="text-neutral-950"
|
26
|
+
<FrettedChord
|
27
|
+
class="font-mono text-neutral-950"
|
26
28
|
name="D"
|
27
29
|
notes={[
|
28
30
|
{
|
@@ -55,7 +57,7 @@ export { className as class };
|
|
55
57
|
export let id = "";
|
56
58
|
export let strings = 6;
|
57
59
|
export let name = "";
|
58
|
-
export let size =
|
60
|
+
export let size = 150;
|
59
61
|
const boxSize = size * 0.61;
|
60
62
|
const offset = (size - boxSize) / 2;
|
61
63
|
const strokeWidth = size / 60;
|
@@ -5,7 +5,7 @@ declare const __propDef: {
|
|
5
5
|
id?: string | undefined;
|
6
6
|
/** total number of strings for the instrument */ strings?: number | undefined;
|
7
7
|
/** name of chord */ name?: string | undefined;
|
8
|
-
/** total size of chord square */ size?: number | undefined;
|
8
|
+
/** total size of chord square in pixels, defaults to `150` */ size?: number | undefined;
|
9
9
|
/** list of the positioning of the notes required for the chord */ notes?: {
|
10
10
|
/** recommended finger to use */
|
11
11
|
finger: number | string;
|
@@ -20,13 +20,15 @@ declare const __propDef: {
|
|
20
20
|
};
|
21
21
|
slots: {};
|
22
22
|
};
|
23
|
-
export type
|
24
|
-
export type
|
25
|
-
export type
|
23
|
+
export type FrettedChordProps = typeof __propDef.props;
|
24
|
+
export type FrettedChordEvents = typeof __propDef.events;
|
25
|
+
export type FrettedChordSlots = typeof __propDef.slots;
|
26
26
|
/**
|
27
|
-
* ###
|
27
|
+
* ### FrettedChord
|
28
28
|
*
|
29
|
-
* Generates a
|
29
|
+
* Generates a fretted chord `svg` for instruments like guitar and ukulele.
|
30
|
+
*
|
31
|
+
* Try it out and generate code: [FrettedChord Creator](https://svelte.dev/repl/5771d5c3f3c34137a174c8c402ca0b2d?version=4.2.0)
|
30
32
|
*
|
31
33
|
* @props
|
32
34
|
*
|
@@ -34,18 +36,18 @@ export type ChordSlots = typeof __propDef.slots;
|
|
34
36
|
* - `id`
|
35
37
|
* - `name` - name of chord
|
36
38
|
* - `notes` - list of the positioning of the notes required for the chord
|
37
|
-
* - `size` - total size of chord square
|
39
|
+
* - `size` - total size of chord square in pixels, defaults to `150`
|
38
40
|
* - `strings` - total number of strings for the instrument
|
39
41
|
*
|
40
42
|
* @example
|
41
43
|
*
|
42
44
|
* ```svelte
|
43
45
|
* <script lang="ts">
|
44
|
-
* import {
|
46
|
+
* import { FrettedChord } from "drab";
|
45
47
|
* </script>
|
46
48
|
*
|
47
|
-
* <
|
48
|
-
* class="text-neutral-950"
|
49
|
+
* <FrettedChord
|
50
|
+
* class="font-mono text-neutral-950"
|
49
51
|
* name="D"
|
50
52
|
* notes={[
|
51
53
|
* {
|
@@ -72,6 +74,6 @@ export type ChordSlots = typeof __propDef.slots;
|
|
72
74
|
* />
|
73
75
|
* ```
|
74
76
|
*/
|
75
|
-
export default class
|
77
|
+
export default class FrettedChord extends SvelteComponent<FrettedChordProps, FrettedChordEvents, FrettedChordSlots> {
|
76
78
|
}
|
77
79
|
export {};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
### FullscreenButton
|
5
5
|
|
6
|
-
Make the document or a
|
6
|
+
Make the document or a `target` element fullscreen.
|
7
7
|
|
8
8
|
@props
|
9
9
|
|
@@ -64,15 +64,20 @@ const onClick = () => {
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
};
|
67
|
+
const syncFullscreen = () => {
|
68
|
+
fullscreen = document.fullscreenElement !== null;
|
69
|
+
};
|
67
70
|
onMount(() => {
|
68
|
-
if (document.documentElement.requestFullscreen)
|
71
|
+
if (document.documentElement.requestFullscreen) {
|
72
|
+
syncFullscreen();
|
69
73
|
disabled = false;
|
74
|
+
}
|
70
75
|
if (!target)
|
71
76
|
target = document.documentElement;
|
72
77
|
});
|
73
78
|
</script>
|
74
79
|
|
75
|
-
<svelte:window on:fullscreenchange={
|
80
|
+
<svelte:window on:fullscreenchange={syncFullscreen} />
|
76
81
|
|
77
82
|
<button
|
78
83
|
type="button"
|
@@ -3,7 +3,10 @@
|
|
3
3
|
|
4
4
|
### Popover
|
5
5
|
|
6
|
-
Displays a popover
|
6
|
+
Displays a popover in relation to the `target`.
|
7
|
+
|
8
|
+
- Does not require the target to be `position: relative;`
|
9
|
+
- Adjusts position in case the popover renders outside of the viewport
|
7
10
|
|
8
11
|
@props
|
9
12
|
|
@@ -57,22 +60,22 @@ let className = "";
|
|
57
60
|
export { className as class };
|
58
61
|
export let id = "";
|
59
62
|
export let display = true;
|
60
|
-
export let position = "
|
63
|
+
export let position = "b";
|
61
64
|
export let target;
|
62
65
|
export let transition = { duration, start };
|
63
66
|
let popover;
|
64
67
|
let coordinates = { x: 0, y: 0 };
|
65
68
|
const setPosition = async () => {
|
66
|
-
if (position === "
|
69
|
+
if (position === "t" || position === "b") {
|
67
70
|
coordinates.x = target.offsetWidth / 2 - popover.offsetWidth / 2;
|
68
|
-
if (position === "
|
71
|
+
if (position === "t") {
|
69
72
|
coordinates.y = -popover.offsetHeight;
|
70
73
|
} else {
|
71
74
|
coordinates.y = target.offsetHeight;
|
72
75
|
}
|
73
76
|
} else {
|
74
77
|
coordinates.y = target.offsetHeight / 2 - popover.offsetHeight / 2;
|
75
|
-
if (position === "
|
78
|
+
if (position === "l") {
|
76
79
|
coordinates.x = -popover.offsetWidth;
|
77
80
|
} else {
|
78
81
|
coordinates.x = target.offsetWidth;
|
@@ -5,7 +5,7 @@ declare const __propDef: {
|
|
5
5
|
class?: string | undefined;
|
6
6
|
id?: string | undefined;
|
7
7
|
/** shows / hides the popover */ display?: boolean | undefined;
|
8
|
-
/** where the popover is displayed in relation to the `target` */ position?: "
|
8
|
+
/** where the popover is displayed in relation to the `target` */ position?: "t" | "b" | "l" | "r" | undefined;
|
9
9
|
/** target element to position the popover in relation to */ target: HTMLElement;
|
10
10
|
/** scales the popover, set to `false` to disable */ transition?: false | ScaleParams | undefined;
|
11
11
|
};
|
@@ -22,7 +22,10 @@ export type PopoverSlots = typeof __propDef.slots;
|
|
22
22
|
/**
|
23
23
|
* ### Popover
|
24
24
|
*
|
25
|
-
* Displays a popover
|
25
|
+
* Displays a popover in relation to the `target`.
|
26
|
+
*
|
27
|
+
* - Does not require the target to be `position: relative;`
|
28
|
+
* - Adjusts position in case the popover renders outside of the viewport
|
26
29
|
*
|
27
30
|
* @props
|
28
31
|
*
|
@@ -39,7 +39,7 @@ Creates a sheet element based on the `position` provided. `maxSize` is set to wi
|
|
39
39
|
bind:display
|
40
40
|
class="backdrop-blur"
|
41
41
|
classSheet="p-4 shadow bg-white"
|
42
|
-
position="
|
42
|
+
position="r"
|
43
43
|
>
|
44
44
|
<div class="mb-4 flex items-center justify-between">
|
45
45
|
<h2 class="my-0">Sheet</h2>
|
@@ -71,7 +71,7 @@ export let id = "";
|
|
71
71
|
export let classSheet = "";
|
72
72
|
export let display = false;
|
73
73
|
export let transition = { duration };
|
74
|
-
export let position = "
|
74
|
+
export let position = "l";
|
75
75
|
export let maxSize = 488;
|
76
76
|
export let transitionSheet = { duration };
|
77
77
|
let sheet;
|
@@ -85,11 +85,11 @@ const focusElement = (node) => {
|
|
85
85
|
node.focus();
|
86
86
|
};
|
87
87
|
if (transitionSheet && !transitionSheet.x && !transitionSheet.y) {
|
88
|
-
if (position === "
|
88
|
+
if (position === "b") {
|
89
89
|
transitionSheet.y = maxSize;
|
90
|
-
} else if (position === "
|
90
|
+
} else if (position === "t") {
|
91
91
|
transitionSheet.y = -maxSize;
|
92
|
-
} else if (position === "
|
92
|
+
} else if (position === "r") {
|
93
93
|
transitionSheet.x = maxSize;
|
94
94
|
} else {
|
95
95
|
transitionSheet.x = -maxSize;
|
@@ -110,9 +110,9 @@ onMount(() => {
|
|
110
110
|
transition:blur={transition ? transition : { duration: 0 }}
|
111
111
|
use:focusElement
|
112
112
|
class="d-backdrop {className}"
|
113
|
-
class:d-backdrop-bottom={position === "
|
114
|
-
class:d-backdrop-top={position === "
|
115
|
-
class:d-backdrop-right={position === "
|
113
|
+
class:d-backdrop-bottom={position === "b"}
|
114
|
+
class:d-backdrop-top={position === "t"}
|
115
|
+
class:d-backdrop-right={position === "r"}
|
116
116
|
{id}
|
117
117
|
tabindex="-1"
|
118
118
|
>
|
@@ -120,7 +120,7 @@ onMount(() => {
|
|
120
120
|
role="dialog"
|
121
121
|
bind:this={sheet}
|
122
122
|
transition:fly={transitionSheet ? transitionSheet : { duration: 0 }}
|
123
|
-
style={position === "
|
123
|
+
style={position === "t" || position === "b"
|
124
124
|
? `max-height: ${maxSize}px;`
|
125
125
|
: `max-width: ${maxSize}px`}
|
126
126
|
class={classSheet}
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
7
7
|
/** sheet class - not the backdrop */ classSheet?: string | undefined;
|
8
8
|
/** controls whether the sheet is displayed*/ display?: boolean | undefined;
|
9
9
|
/** blurs the entire component, set to `false` to remove */ transition?: false | BlurParams | undefined;
|
10
|
-
/** determines the position of sheet */ position?: "
|
10
|
+
/** determines the position of sheet */ position?: "t" | "b" | "l" | "r" | undefined;
|
11
11
|
/** max width/height of sheet based on the `side` - can also use css instead */ maxSize?: number | undefined;
|
12
12
|
/** flies the sheet, set to `false` to remove */ transitionSheet?: false | FlyParams | undefined;
|
13
13
|
};
|
@@ -60,7 +60,7 @@ export type SheetSlots = typeof __propDef.slots;
|
|
60
60
|
* bind:display
|
61
61
|
* class="backdrop-blur"
|
62
62
|
* classSheet="p-4 shadow bg-white"
|
63
|
-
* position="
|
63
|
+
* position="r"
|
64
64
|
* >
|
65
65
|
* <div class="mb-4 flex items-center justify-between">
|
66
66
|
* <h2 class="my-0">Sheet</h2>
|
package/dist/index.d.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import Breakpoint from "./components/Breakpoint.svelte";
|
2
|
-
import Chord from "./components/Chord.svelte";
|
3
2
|
import ContextMenu from "./components/ContextMenu.svelte";
|
4
3
|
import CopyButton from "./components/CopyButton.svelte";
|
5
4
|
import DataTable from "./components/DataTable.svelte";
|
6
5
|
import Details from "./components/Details.svelte";
|
7
6
|
import Editor from "./components/Editor.svelte";
|
7
|
+
import FrettedChord from "./components/FrettedChord.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
12
|
import YouTube from "./components/YouTube.svelte";
|
13
|
-
export { Breakpoint,
|
13
|
+
export { Breakpoint, ContextMenu, CopyButton, DataTable, Details, Editor, FrettedChord, FullscreenButton, Popover, ShareButton, Sheet, YouTube, };
|
package/dist/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import Breakpoint from "./components/Breakpoint.svelte";
|
2
|
-
import Chord from "./components/Chord.svelte";
|
3
2
|
import ContextMenu from "./components/ContextMenu.svelte";
|
4
3
|
import CopyButton from "./components/CopyButton.svelte";
|
5
4
|
import DataTable from "./components/DataTable.svelte";
|
6
5
|
import Details from "./components/Details.svelte";
|
7
6
|
import Editor from "./components/Editor.svelte";
|
7
|
+
import FrettedChord from "./components/FrettedChord.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
12
|
import YouTube from "./components/YouTube.svelte";
|
13
|
-
export { Breakpoint,
|
13
|
+
export { Breakpoint, ContextMenu, CopyButton, DataTable, Details, Editor, FrettedChord, FullscreenButton, Popover, ShareButton, Sheet, YouTube, };
|
package/package.json
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "drab",
|
3
|
-
"version": "
|
4
|
-
"description": "An
|
3
|
+
"version": "3.0.0",
|
4
|
+
"description": "An Unstyled Svelte Component Library",
|
5
5
|
"keywords": [
|
6
6
|
"components",
|
7
7
|
"Svelte",
|
8
8
|
"SvelteKit",
|
9
9
|
"Breakpoint",
|
10
|
-
"Chord",
|
11
10
|
"ContextMenu",
|
12
11
|
"Copy",
|
13
12
|
"DataTable",
|
14
13
|
"Details",
|
15
14
|
"Editor",
|
15
|
+
"FrettedChord",
|
16
16
|
"Fullscreen",
|
17
17
|
"Popover",
|
18
18
|
"Share",
|