drab 3.0.0 → 3.0.2

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,57 +1,57 @@
1
- <!--
2
- @component
3
-
4
- ### FrettedChord
5
-
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)
9
-
10
- @props
11
-
12
- - `class`
13
- - `id`
14
- - `name` - name of chord
15
- - `notes` - list of the positioning of the notes required for the chord
16
- - `size` - total size of chord square in pixels, defaults to `150`
17
- - `strings` - total number of strings for the instrument
18
-
19
- @example
20
-
21
- ```svelte
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
- />
52
- ```
53
- -->
54
-
1
+ <!--
2
+ @component
3
+
4
+ ### FrettedChord
5
+
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)
9
+
10
+ @props
11
+
12
+ - `class`
13
+ - `id`
14
+ - `name` - name of chord
15
+ - `notes` - list of the positioning of the notes required for the chord
16
+ - `size` - total size of chord square in pixels, defaults to `150`
17
+ - `strings` - total number of strings for the instrument
18
+
19
+ @example
20
+
21
+ ```svelte
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
+ />
52
+ ```
53
+ -->
54
+
55
55
  <script>let className = "";
56
56
  export { className as class };
57
57
  export let id = "";
@@ -111,103 +111,103 @@ const noteX = (string) => {
111
111
  const noteY = (fret) => {
112
112
  return boxSize / fretRange * fret + offset / 2 - boxSize / fretRange / 2;
113
113
  };
114
- </script>
115
-
116
- {#if notes.length}
117
- <svg
118
- width={size}
119
- height={size}
120
- stroke="currentColor"
121
- fill="currentColor"
122
- class={className}
123
- {id}
124
- >
125
- <title>{name}</title>
126
-
127
- <!-- BACKGROUND -->
128
- <rect
129
- width={boxSize}
130
- height={boxSize}
131
- fill="transparent"
132
- x={offset}
133
- y={offset / 2}
134
- stroke-width={strokeWidth}
135
- />
136
- <line
137
- x1={offset - strokeWidth / 2}
138
- y1={offset / 2 - strokeWidth / 2}
139
- x2={boxSize + offset + strokeWidth / 2}
140
- y2={offset / 2 - strokeWidth / 2}
141
- stroke-width={strokeWidth * 2}
142
- />
143
-
144
- <!-- FRETS -->
145
- {#each Array.from(Array(fretRange).keys()) as fret}
146
- <line
147
- x1={offset}
148
- y1={fretY(fret) - offset / 2}
149
- x2={boxSize + offset}
150
- y2={fretY(fret) - offset / 2}
151
- stroke-width={strokeWidth}
152
- opacity="0.2"
153
- />
154
- {/each}
155
-
156
- <!-- STRINGS -->
157
- {#each stringList as string}
158
- <line
159
- x1={stringX(string)}
160
- y1={offset / 2}
161
- x2={stringX(string)}
162
- y2={boxSize + offset / 2}
163
- stroke-width={strokeWidth}
164
- />
165
- {/each}
166
-
167
- <!-- NOTES -->
168
- {#each notesList as note}
169
- {#if note.fret !== 0}
170
- <circle
171
- cx={noteX(note.string)}
172
- cy={noteY(note.fret)}
173
- r={circleRadius}
174
- />
175
- {/if}
176
- {#if note.finger !== 0}
177
- <!-- RECOMMENDED FINGER -->
178
- <text
179
- x={noteX(note.string) - size / 50}
180
- y={note.fret === 0
181
- ? offset / 2 - strokeWidth * 2.4
182
- : size - offset * 1.1}
183
- color="currentColor"
184
- fill="currentColor"
185
- font-size={size / 13}
186
- >
187
- {note.finger}
188
- </text>
189
- {/if}
190
- {/each}
191
-
192
- <!-- CHORD NAME -->
193
- <text
194
- x={offset}
195
- y={size - offset / 2.5}
196
- font-size={boxSize / 6}
197
- font-weight="600"
198
- >
199
- {name}
200
- </text>
201
-
202
- <!-- STARTING FRET -->
203
- {#if firstFret > 1}
204
- <text
205
- x={size - offset / 1.8}
206
- y={offset / 2 + boxSize / 7}
207
- font-size={size / 13}
208
- >
209
- {firstFret}f
210
- </text>
211
- {/if}
212
- </svg>
213
- {/if}
114
+ </script>
115
+
116
+ {#if notes.length}
117
+ <svg
118
+ width={size}
119
+ height={size}
120
+ stroke="currentColor"
121
+ fill="currentColor"
122
+ class={className}
123
+ {id}
124
+ >
125
+ <title>{name}</title>
126
+
127
+ <!-- BACKGROUND -->
128
+ <rect
129
+ width={boxSize}
130
+ height={boxSize}
131
+ fill="transparent"
132
+ x={offset}
133
+ y={offset / 2}
134
+ stroke-width={strokeWidth}
135
+ />
136
+ <line
137
+ x1={offset - strokeWidth / 2}
138
+ y1={offset / 2 - strokeWidth / 2}
139
+ x2={boxSize + offset + strokeWidth / 2}
140
+ y2={offset / 2 - strokeWidth / 2}
141
+ stroke-width={strokeWidth * 2}
142
+ />
143
+
144
+ <!-- FRETS -->
145
+ {#each Array.from(Array(fretRange).keys()) as fret}
146
+ <line
147
+ x1={offset}
148
+ y1={fretY(fret) - offset / 2}
149
+ x2={boxSize + offset}
150
+ y2={fretY(fret) - offset / 2}
151
+ stroke-width={strokeWidth}
152
+ opacity="0.2"
153
+ />
154
+ {/each}
155
+
156
+ <!-- STRINGS -->
157
+ {#each stringList as string}
158
+ <line
159
+ x1={stringX(string)}
160
+ y1={offset / 2}
161
+ x2={stringX(string)}
162
+ y2={boxSize + offset / 2}
163
+ stroke-width={strokeWidth}
164
+ />
165
+ {/each}
166
+
167
+ <!-- NOTES -->
168
+ {#each notesList as note}
169
+ {#if note.fret !== 0}
170
+ <circle
171
+ cx={noteX(note.string)}
172
+ cy={noteY(note.fret)}
173
+ r={circleRadius}
174
+ />
175
+ {/if}
176
+ {#if note.finger !== 0}
177
+ <!-- RECOMMENDED FINGER -->
178
+ <text
179
+ x={noteX(note.string) - size / 50}
180
+ y={note.fret === 0
181
+ ? offset / 2 - strokeWidth * 2.4
182
+ : size - offset * 1.1}
183
+ color="currentColor"
184
+ fill="currentColor"
185
+ font-size={size / 13}
186
+ >
187
+ {note.finger}
188
+ </text>
189
+ {/if}
190
+ {/each}
191
+
192
+ <!-- CHORD NAME -->
193
+ <text
194
+ x={offset}
195
+ y={size - offset / 2.5}
196
+ font-size={boxSize / 6}
197
+ font-weight="600"
198
+ >
199
+ {name}
200
+ </text>
201
+
202
+ <!-- STARTING FRET -->
203
+ {#if firstFret > 1}
204
+ <text
205
+ x={size - offset / 1.8}
206
+ y={offset / 2 + boxSize / 7}
207
+ font-size={size / 13}
208
+ >
209
+ {firstFret}f
210
+ </text>
211
+ {/if}
212
+ </svg>
213
+ {/if}
@@ -1,45 +1,45 @@
1
- <!--
2
- @component
3
-
4
- ### FullscreenButton
5
-
6
- Make the document or a `target` element fullscreen.
7
-
8
- @props
9
-
10
- - `class`
11
- - `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` -- disabled
12
- - `id`
13
- - `target` - element to make fullscreen (defaults to `document.documentElement` upon mount)
14
- - `title`
15
-
16
- @slots
17
-
18
- | name | purpose | default value |
19
- | ---------- | ---------------------------------------------- | -------------------- |
20
- | `default` | content to display when fullscreen is disabled | `Enabled Fullscreen` |
21
- | `enabled` | content to display when fullscreen is enabled | `Exit Fullscreen` |
22
-
23
- @example
24
-
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>
40
- ```
41
- -->
42
-
1
+ <!--
2
+ @component
3
+
4
+ ### FullscreenButton
5
+
6
+ Make the document or a `target` element fullscreen.
7
+
8
+ @props
9
+
10
+ - `class`
11
+ - `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` -- disabled
12
+ - `id`
13
+ - `target` - element to make fullscreen (defaults to `document.documentElement` upon mount)
14
+ - `title`
15
+
16
+ @slots
17
+
18
+ | name | purpose | default value |
19
+ | ---------- | ---------------------------------------------- | -------------------- |
20
+ | `default` | content to display when fullscreen is disabled | `Enabled Fullscreen` |
21
+ | `enabled` | content to display when fullscreen is enabled | `Exit Fullscreen` |
22
+
23
+ @example
24
+
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>
40
+ ```
41
+ -->
42
+
43
43
  <script>import { onMount } from "svelte";
44
44
  let className = "";
45
45
  export { className as class };
@@ -75,21 +75,21 @@ onMount(() => {
75
75
  if (!target)
76
76
  target = document.documentElement;
77
77
  });
78
- </script>
79
-
80
- <svelte:window on:fullscreenchange={syncFullscreen} />
81
-
82
- <button
83
- type="button"
84
- {disabled}
85
- on:click={onClick}
86
- class={className}
87
- {id}
88
- {title}
89
- >
90
- {#if fullscreen}
91
- <slot name="enabled">Exit Fullscreen</slot>
92
- {:else}
93
- <slot>Enable Fullscreen</slot>
94
- {/if}
95
- </button>
78
+ </script>
79
+
80
+ <svelte:window on:fullscreenchange={syncFullscreen} />
81
+
82
+ <button
83
+ type="button"
84
+ {disabled}
85
+ on:click={onClick}
86
+ class={className}
87
+ {id}
88
+ {title}
89
+ >
90
+ {#if fullscreen}
91
+ <slot name="enabled">Exit Fullscreen</slot>
92
+ {:else}
93
+ <slot>Enable Fullscreen</slot>
94
+ {/if}
95
+ </button>
@@ -1,57 +1,57 @@
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
12
-
13
- - `class`
14
- - `display` - shows / hides the popover
15
- - `id`
16
- - `position` - where the popover is displayed in relation to the `target`
17
- - `target` - target element to position the popover in relation to
18
- - `transition` - scales the popover, set to `false` to disable
19
-
20
- @slots
21
-
22
- | name | purpose | default value |
23
- | ---------- | ------------------------------- | ------------- |
24
- | `default` | default | Popover |
25
-
26
- @example
27
-
28
- ```svelte
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>
52
- ```
53
- -->
54
-
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
12
+
13
+ - `class`
14
+ - `display` - shows / hides the popover
15
+ - `id`
16
+ - `position` - where the popover is displayed in relation to the `target`
17
+ - `target` - target element to position the popover in relation to
18
+ - `transition` - scales the popover, set to `false` to disable
19
+
20
+ @slots
21
+
22
+ | name | purpose | default value |
23
+ | ---------- | ------------------------------- | ------------- |
24
+ | `default` | default | Popover |
25
+
26
+ @example
27
+
28
+ ```svelte
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>
52
+ ```
53
+ -->
54
+
55
55
  <script>import { prefersReducedMotion } from "../util/accessibility";
56
56
  import { duration, start } from "../util/transition";
57
57
  import { onMount, tick } from "svelte";
@@ -109,26 +109,26 @@ onMount(() => {
109
109
  if (prefersReducedMotion())
110
110
  transition = false;
111
111
  });
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>
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>