drab 2.8.6 → 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.
@@ -1,9 +1,11 @@
1
1
  <!--
2
2
  @component
3
3
 
4
- ### Chord
4
+ ### FrettedChord
5
5
 
6
- Generates a guitar chord `svg`.
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,42 +13,42 @@ 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
- <script lang="ts">
21
- import { Chord } from "drab";
22
- </script>
23
-
24
- <Chord
25
- class="text-neutral-950"
26
- name="D"
27
- notes={[
28
- {
29
- finger: 0,
30
- string: 4,
31
- fret: 0,
32
- },
33
- {
34
- finger: 1,
35
- string: 3,
36
- fret: 2,
37
- },
38
- {
39
- finger: 2,
40
- string: 1,
41
- fret: 2,
42
- },
43
- {
44
- finger: 3,
45
- string: 2,
46
- fret: 3,
47
- },
48
- ]}
49
- />
22
+ <script lang="ts">
23
+ import { FrettedChord } from "drab";
24
+ </script>
25
+
26
+ <FrettedChord
27
+ class="font-mono text-neutral-950"
28
+ name="D"
29
+ notes={[
30
+ {
31
+ finger: 0,
32
+ string: 4,
33
+ fret: 0,
34
+ },
35
+ {
36
+ finger: 1,
37
+ string: 3,
38
+ fret: 2,
39
+ },
40
+ {
41
+ finger: 2,
42
+ string: 1,
43
+ fret: 2,
44
+ },
45
+ {
46
+ finger: 3,
47
+ string: 2,
48
+ fret: 3,
49
+ },
50
+ ]}
51
+ />
50
52
  ```
51
53
  -->
52
54
 
@@ -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 = 200;
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 ChordProps = typeof __propDef.props;
24
- export type ChordEvents = typeof __propDef.events;
25
- export type ChordSlots = typeof __propDef.slots;
23
+ export type FrettedChordProps = typeof __propDef.props;
24
+ export type FrettedChordEvents = typeof __propDef.events;
25
+ export type FrettedChordSlots = typeof __propDef.slots;
26
26
  /**
27
- * ### Chord
27
+ * ### FrettedChord
28
28
  *
29
- * Generates a guitar chord `svg`.
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 { Chord } from "drab";
46
+ * import { FrettedChord } from "drab";
45
47
  * </script>
46
48
  *
47
- * <Chord
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 Chord extends SvelteComponent<ChordProps, ChordEvents, ChordSlots> {
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 specific element fullscreen.
6
+ Make the document or a `target` element fullscreen.
7
7
 
8
8
  @props
9
9
 
@@ -23,20 +23,20 @@ Make the document or a specific element fullscreen.
23
23
  @example
24
24
 
25
25
  ```svelte
26
- <script lang="ts">
27
- import { FullscreenButton } from "drab";
28
-
29
- let target: HTMLDivElement;
30
- </script>
31
-
32
- <FullscreenButton class="btn" />
33
-
34
- <div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
35
- <div class="mb-2">Target element</div>
36
- <FullscreenButton {target} class="btn btn-s bg-neutral-50">
37
- Enable Element Fullscreen
38
- </FullscreenButton>
39
- </div>
26
+ <script lang="ts">
27
+ import { FullscreenButton } from "drab";
28
+
29
+ let target: HTMLDivElement;
30
+ </script>
31
+
32
+ <FullscreenButton class="btn" />
33
+
34
+ <div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
35
+ <div class="mb-2">Target element</div>
36
+ <FullscreenButton {target} class="btn btn-s bg-neutral-50">
37
+ Enable Element Fullscreen
38
+ </FullscreenButton>
39
+ </div>
40
40
  ```
41
41
  -->
42
42
 
@@ -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={() => (fullscreen = !fullscreen)} />
80
+ <svelte:window on:fullscreenchange={syncFullscreen} />
76
81
 
77
82
  <button
78
83
  type="button"
@@ -21,7 +21,7 @@ export type FullscreenButtonSlots = typeof __propDef.slots;
21
21
  /**
22
22
  * ### FullscreenButton
23
23
  *
24
- * Make the document or a specific element fullscreen.
24
+ * Make the document or a `target` element fullscreen.
25
25
  *
26
26
  * @props
27
27
  *
@@ -1,11 +1,14 @@
1
- <!--
2
- @component
3
-
4
- ### Popover
5
-
6
- Displays a popover relatively positioned to the target. Does not require the target to be `position: relative;`.
7
-
8
- @props
1
+ <!--
2
+ @component
3
+
4
+ ### Popover
5
+
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
10
+
11
+ @props
9
12
 
10
13
  - `class`
11
14
  - `display` - shows / hides the popover
@@ -14,41 +17,41 @@ Displays a popover relatively positioned to the target. Does not require the tar
14
17
  - `target` - target element to position the popover in relation to
15
18
  - `transition` - scales the popover, set to `false` to disable
16
19
 
17
- @slots
18
-
19
- | name | purpose | default value |
20
- | ---------- | ------------------------------- | ------------- |
21
- | `default` | default | Popover |
22
-
23
- @example
20
+ @slots
21
+
22
+ | name | purpose | default value |
23
+ | ---------- | ------------------------------- | ------------- |
24
+ | `default` | default | Popover |
25
+
26
+ @example
24
27
 
25
28
  ```svelte
26
- <script lang="ts">
27
- import { Popover } from "drab";
28
-
29
- let target: HTMLButtonElement;
30
-
31
- let display = false;
32
-
33
- const open = () => (display = true);
34
- const close = () => (display = false);
35
- </script>
36
-
37
- <button class="btn" type="button" bind:this={target} on:click={open}>
38
- Open
39
- </button>
40
-
41
- <Popover {target} bind:display class="p-2">
42
- <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
43
- <div class="font-bold">Bottom</div>
44
- <button class="btn" on:click={close}>Close</button>
45
- <button class="btn" on:click={close}>Close</button>
46
- <button class="btn" on:click={close}>Close</button>
47
- </div>
48
- </Popover>
29
+ <script lang="ts">
30
+ import { Popover } from "drab";
31
+
32
+ let target: HTMLButtonElement;
33
+
34
+ let display = false;
35
+
36
+ const open = () => (display = true);
37
+ const close = () => (display = false);
38
+ </script>
39
+
40
+ <button class="btn" type="button" bind:this={target} on:click={open}>
41
+ Open
42
+ </button>
43
+
44
+ <Popover {target} bind:display class="p-2">
45
+ <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
46
+ <div class="font-bold">Bottom</div>
47
+ <button class="btn" on:click={close}>Close</button>
48
+ <button class="btn" on:click={close}>Close</button>
49
+ <button class="btn" on:click={close}>Close</button>
50
+ </div>
51
+ </Popover>
49
52
  ```
50
- -->
51
-
53
+ -->
54
+
52
55
  <script>import { prefersReducedMotion } from "../util/accessibility";
53
56
  import { duration, start } from "../util/transition";
54
57
  import { onMount, tick } from "svelte";
@@ -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 = "bottom";
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 === "top" || position === "bottom") {
69
+ if (position === "t" || position === "b") {
67
70
  coordinates.x = target.offsetWidth / 2 - popover.offsetWidth / 2;
68
- if (position === "top") {
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 === "left") {
78
+ if (position === "l") {
76
79
  coordinates.x = -popover.offsetWidth;
77
80
  } else {
78
81
  coordinates.x = target.offsetWidth;
@@ -106,26 +109,26 @@ onMount(() => {
106
109
  if (prefersReducedMotion())
107
110
  transition = false;
108
111
  });
109
- </script>
110
-
111
- <svelte:body on:keydown={onKeyDown} />
112
-
113
- {#if display}
114
- <div
115
- role="dialog"
116
- bind:this={popover}
117
- class={className}
118
- {id}
119
- style:top="{coordinates.y}px"
120
- style:left="{coordinates.x}px"
121
- transition:scale={transition ? transition : { duration: 0 }}
122
- >
123
- <slot>Popover</slot>
124
- </div>
125
- {/if}
126
-
127
- <style>
128
- div {
129
- position: absolute;
130
- }
131
- </style>
112
+ </script>
113
+
114
+ <svelte:body on:keydown={onKeyDown} />
115
+
116
+ {#if display}
117
+ <div
118
+ role="dialog"
119
+ bind:this={popover}
120
+ class={className}
121
+ {id}
122
+ style:top="{coordinates.y}px"
123
+ style:left="{coordinates.x}px"
124
+ transition:scale={transition ? transition : { duration: 0 }}
125
+ >
126
+ <slot>Popover</slot>
127
+ </div>
128
+ {/if}
129
+
130
+ <style>
131
+ div {
132
+ position: absolute;
133
+ }
134
+ </style>
@@ -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?: "top" | "bottom" | "left" | "right" | undefined;
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 relatively positioned to the target. Does not require the target to be `position: relative;`.
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
  *
@@ -30,44 +30,44 @@ Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Naviga
30
30
  @example
31
31
 
32
32
  ```svelte
33
- <script lang="ts">
34
- import { ShareButton } from "drab";
35
-
36
- let fileInput: HTMLInputElement;
37
-
38
- let fileShareData: ShareData;
39
-
40
- const onInput = () => {
41
- if (fileInput.files) {
42
- fileShareData.files = [fileInput.files[0]];
43
- }
44
- };
45
- </script>
46
-
47
- <ShareButton
48
- class="btn mb-8"
49
- shareData={{
50
- text: "Check out this page: ",
51
- title: "drab",
52
- url: "https://drab.robino.dev",
53
- }}
54
- >
55
- Share URL
56
- </ShareButton>
57
-
58
- <div>
59
- <label class="label" for="fileInput">Upload File</label>
60
- <input
61
- type="file"
62
- id="fileInput"
63
- class="input mb-4"
64
- bind:this={fileInput}
65
- on:input={onInput}
66
- />
67
- <ShareButton class="btn" bind:shareData={fileShareData}>
68
- Share File
69
- </ShareButton>
70
- </div>
33
+ <script lang="ts">
34
+ import { ShareButton } from "drab";
35
+
36
+ let fileInput: HTMLInputElement;
37
+
38
+ let fileShareData: ShareData;
39
+
40
+ const onInput = () => {
41
+ if (fileInput.files) {
42
+ fileShareData.files = [fileInput.files[0]];
43
+ }
44
+ };
45
+ </script>
46
+
47
+ <ShareButton
48
+ class="btn mb-8"
49
+ shareData={{
50
+ text: "Check out this page: ",
51
+ title: "drab",
52
+ url: "https://drab.robino.dev",
53
+ }}
54
+ >
55
+ Share URL
56
+ </ShareButton>
57
+
58
+ <div>
59
+ <label class="label" for="fileInput">Upload File</label>
60
+ <input
61
+ type="file"
62
+ id="fileInput"
63
+ class="input mb-4"
64
+ bind:this={fileInput}
65
+ on:input={onInput}
66
+ />
67
+ <ShareButton class="btn" bind:shareData={fileShareData}>
68
+ Share File
69
+ </ShareButton>
70
+ </div>
71
71
  ```
72
72
  -->
73
73