drab 2.8.4 → 2.8.5

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 CHANGED
@@ -1,67 +1,67 @@
1
- # An unstyled Svelte component library
2
-
3
- - [GitHub](https://github.com/rossrobino/drab)
4
- - [npm](https://www.npmjs.com/package/drab)
5
- - [MIT License](https://github.com/rossrobino/drab/blob/main/LICENSE.md)
6
- - One dependency - [Svelte](https://svelte.dev)
7
-
8
- ## About
9
-
10
- **drab** focuses on providing JavaScript functionality where it's most useful, while leaving out components that can be easily created using HTML, such as a label or badge. 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
-
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) or [popover](/docs/Popover). 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
-
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
-
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/). TailwindCSS generates a global stylesheet based on the utility classes used in your project. Each component exports `class` and `id` props that can be leveraged for this purpose.
17
-
18
- ## Install
19
-
20
- If you haven't used Svelte before, start with the [tutorial](https://svelte.dev/tutorial/basics).
21
-
22
- - [SvelteKit](https://kit.svelte.dev)
23
- - [Astro](https://docs.astro.build/en/tutorial/1-setup/2/)
24
- - [Vite](https://vitejs.dev/guide/)
25
-
26
- ```bash
27
- npm install -D drab
28
- ```
29
-
30
- ## Documentation
31
-
32
- The library provides inline documentation for each component, allowing you to conveniently access the documentation by hovering over the component in your text editor after importing it. Additionally, every prop is documented using JSDoc and TypeScript. By hovering over a prop, you can retrieve its type and description.
33
-
34
- These docs use the [TailwindCSS Typography plugin](https://tailwindcss.com/docs/typography-plugin) for base styles along with a few custom utility classes you can find [here](https://github.com/rossrobino/drab/blob/main/src/app.postcss). Styles on this site are based on [shadcn/ui](https://ui.shadcn.com/).
35
-
36
- ## Alternatives
37
-
38
- If **drab** isn't what you are looking for, here are some other Svelte UI libraries to check out.
39
-
40
- - [Skeleton](https://skeleton.dev)
41
- - [Melt UI](https://www.melt-ui.com/)
42
- - [shadcn-svelte](https://www.shadcn-svelte.com/)
43
- - [Svelte-HeadlessUI](https://captaincodeman.github.io/svelte-headlessui/)
44
-
45
- ## Contributing
46
-
47
- Find an bug or have an idea? Feel free to create an issue on [GitHub](https://github.com/rossrobino/drab).
48
-
49
- Since this is an unstyled library, simple components like a badge that can be easily created with HTML and CSS are not included.
50
-
51
- ### Local Development
52
-
53
- Contribute to the project, or use **drab** as a template for another component library. This library is built with SvelteKit, TypeScript, and npm. The package contents are located in `src/lib`, the site is contained within `src/routes` and `src/site`. The site is deployed to Vercel using `@sveltejs/adapter-vercel`. If you are using this project as a template, be sure to [update the adapter](https://kit.svelte.dev/docs/adapters) based on how you deploy.
54
-
55
- #### Make changes
56
-
57
- 1. Clone the [repository](https://github.com/rossrobino/drab)
58
- 2. `npm install`
59
- 3. `npm run dev -- --open`
60
-
61
- #### Add or edit a component
62
-
63
- 1. Add/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
64
- 2. Add/edit the example in `src/routes/docs/Component/+page.svelte`
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 created upon running `npm run doc`
66
- 4. If new, add the link to `src/site/components/NavItems.svelte`
67
- 5. Run `npm run build` to verify your build
1
+ # An unstyled Svelte component library
2
+
3
+ - [GitHub](https://github.com/rossrobino/drab)
4
+ - [npm](https://www.npmjs.com/package/drab)
5
+ - [MIT License](https://github.com/rossrobino/drab/blob/main/LICENSE.md)
6
+ - One dependency - [Svelte](https://svelte.dev)
7
+
8
+ ## About
9
+
10
+ **drab** focuses on providing JavaScript functionality where it's most useful, while leaving out components that can be easily created using HTML, such as a label or badge. 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
+
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) or [popover](/docs/Popover). 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
+
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
+
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/). TailwindCSS generates a global stylesheet based on the utility classes used in your project. Each component exports `class` and `id` props that can be leveraged for this purpose.
17
+
18
+ ## Install
19
+
20
+ If you haven't used Svelte before, start with the [tutorial](https://svelte.dev/tutorial/basics).
21
+
22
+ - [SvelteKit](https://kit.svelte.dev)
23
+ - [Astro](https://docs.astro.build/en/tutorial/1-setup/2/)
24
+ - [Vite](https://vitejs.dev/guide/)
25
+
26
+ ```bash
27
+ npm install -D drab
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ The library provides inline documentation for each component, allowing you to conveniently access the documentation by hovering over the component in your text editor after importing it. Additionally, every prop is documented using JSDoc and TypeScript. By hovering over a prop, you can retrieve its type and description.
33
+
34
+ These docs use the [TailwindCSS Typography plugin](https://tailwindcss.com/docs/typography-plugin) for base styles along with a few custom utility classes you can find [here](https://github.com/rossrobino/drab/blob/main/src/app.postcss). Styles on this site are based on [shadcn/ui](https://ui.shadcn.com/).
35
+
36
+ ## Alternatives
37
+
38
+ If **drab** isn't what you are looking for, here are some other Svelte UI libraries to check out.
39
+
40
+ - [Skeleton](https://skeleton.dev)
41
+ - [Melt UI](https://www.melt-ui.com/)
42
+ - [shadcn-svelte](https://www.shadcn-svelte.com/)
43
+ - [Svelte-HeadlessUI](https://captaincodeman.github.io/svelte-headlessui/)
44
+
45
+ ## Contributing
46
+
47
+ Find an bug or have an idea? Feel free to create an issue on [GitHub](https://github.com/rossrobino/drab).
48
+
49
+ Since this is an unstyled library, simple components like a badge that can be easily created with HTML and CSS are not included.
50
+
51
+ ### Local Development
52
+
53
+ Contribute to the project, or use **drab** as a template for another component library. This library is built with SvelteKit, TypeScript, and npm. The package contents are located in `src/lib`, the site is contained within `src/routes` and `src/site`. The site is deployed to Vercel using `@sveltejs/adapter-vercel`. If you are using this project as a template, be sure to [update the adapter](https://kit.svelte.dev/docs/adapters) based on how you deploy.
54
+
55
+ #### Make changes
56
+
57
+ 1. Clone the [repository](https://github.com/rossrobino/drab)
58
+ 2. `npm install`
59
+ 3. `npm run dev -- --open`
60
+
61
+ #### Add or edit a component
62
+
63
+ 1. Add/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
64
+ 2. Add/edit the example in `src/routes/docs/Component/+page.svelte`
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 created upon running `npm run doc`
66
+ 4. If new, add the link to `src/site/components/NavItems.svelte`
67
+ 5. Run `npm run build` to verify your build
@@ -16,18 +16,17 @@ With SvelteKit, this component can be wrapped in an `{#if dev}` block that check
16
16
  @example
17
17
 
18
18
  ```svelte
19
- <script lang="ts">
20
- import { Breakpoint } from "drab";
21
- </script>
22
-
23
- <Breakpoint
24
- class="inline-block rounded border px-2 py-1 font-mono tabular-nums shadow"
25
- />
19
+ <script lang="ts">
20
+ import { Breakpoint } from "drab";
21
+ </script>
22
+
23
+ <Breakpoint
24
+ class="inline-block rounded border px-2 py-1 font-mono tabular-nums shadow"
25
+ />
26
26
  ```
27
27
  -->
28
28
 
29
- <script>import { messageNoScript } from "../util/messages";
30
- let className = "";
29
+ <script>let className = "";
31
30
  export { className as class };
32
31
  export let id = "";
33
32
  export let breakpoints = [
@@ -53,7 +52,4 @@ const getBreakpoint = (innerWidth2) => {
53
52
 
54
53
  <svelte:window bind:innerWidth />
55
54
 
56
- <div class={className} {id}>
57
- {breakpoint}:{innerWidth}
58
- <noscript>{messageNoScript}</noscript>
59
- </div>
55
+ <div class={className} {id}>{breakpoint}:{innerWidth}</div>
@@ -17,41 +17,39 @@ Generates a guitar chord `svg`.
17
17
  @example
18
18
 
19
19
  ```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
- />
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
+ />
50
50
  ```
51
51
  -->
52
52
 
53
- <script context="module"></script>
54
-
55
53
  <script>let className = "";
56
54
  export { className as class };
57
55
  export let id = "";
@@ -1,12 +1,4 @@
1
1
  import { SvelteComponent } from "svelte";
2
- export interface ChordNote {
3
- /** recommended finger to use */
4
- finger: number | string;
5
- /** string number */
6
- string: number;
7
- /** fret number */
8
- fret: number;
9
- }
10
2
  declare const __propDef: {
11
3
  props: {
12
4
  class?: string | undefined;
@@ -14,7 +6,14 @@ declare const __propDef: {
14
6
  /** total number of strings for the instrument */ strings?: number | undefined;
15
7
  /** name of chord */ name?: string | undefined;
16
8
  /** total size of chord square */ size?: number | undefined;
17
- /** list of the positioning of the notes required for the chord */ notes?: ChordNote[] | undefined;
9
+ /** list of the positioning of the notes required for the chord */ notes?: {
10
+ /** recommended finger to use */
11
+ finger: number | string;
12
+ /** string number */
13
+ string: number;
14
+ /** fret number */
15
+ fret: number;
16
+ }[] | undefined;
18
17
  };
19
18
  events: {
20
19
  [evt: string]: CustomEvent<any>;
@@ -1,11 +1,11 @@
1
- <!--
2
- @component
3
-
4
- ### ContextMenu
5
-
6
- Displays when the `target` element is right clicked, or long pressed on mobile.
7
-
8
- @props
1
+ <!--
2
+ @component
3
+
4
+ ### ContextMenu
5
+
6
+ Displays when the `target` element is right clicked, or long pressed on mobile.
7
+
8
+ @props
9
9
 
10
10
  - `class`
11
11
  - `display` - shows / hides the menu
@@ -13,45 +13,45 @@ Displays when the `target` element is right clicked, or long pressed on mobile.
13
13
  - `target` - target element to right click, defaults to the parent element
14
14
  - `transition` - scales the menu, set to `false` to disable
15
15
 
16
- @slots
17
-
18
- | name | purpose | default value |
19
- | ---------- | ------------------------------- | ------------- |
20
- | `default` | default | Context Menu |
21
-
22
- @example
16
+ @slots
17
+
18
+ | name | purpose | default value |
19
+ | ---------- | ------------------------------- | ------------- |
20
+ | `default` | default | Context Menu |
21
+
22
+ @example
23
23
 
24
24
  ```svelte
25
- <script lang="ts">
26
- import { ContextMenu } from "drab";
27
-
28
- let target: HTMLButtonElement;
29
- </script>
30
-
31
- <div class="mb-8 flex justify-center rounded border border-dashed p-12">
32
- <div>Parent right click</div>
33
- <ContextMenu>
34
- <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
35
- <div class="font-bold">Context Menu</div>
36
- <button role="menuitem" class="btn">Button</button>
37
- <button role="menuitem" class="btn">Button</button>
38
- <button role="menuitem" class="btn">Button</button>
39
- </div>
40
- </ContextMenu>
41
- </div>
42
-
43
- <button type="button" class="btn" bind:this={target}>Target Right Click</button>
44
- <ContextMenu {target}>
45
- <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
46
- <div class="font-bold">Context Menu</div>
47
- <button role="menuitem" class="btn">Button</button>
48
- <button role="menuitem" class="btn">Button</button>
49
- <button role="menuitem" class="btn">Button</button>
50
- </div>
51
- </ContextMenu>
25
+ <script lang="ts">
26
+ import { ContextMenu } from "drab";
27
+
28
+ let target: HTMLButtonElement;
29
+ </script>
30
+
31
+ <div class="mb-8 flex justify-center rounded border border-dashed p-12">
32
+ <div>Parent right click</div>
33
+ <ContextMenu>
34
+ <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
35
+ <div class="font-bold">Context Menu</div>
36
+ <button role="menuitem" class="btn">Button</button>
37
+ <button role="menuitem" class="btn">Button</button>
38
+ <button role="menuitem" class="btn">Button</button>
39
+ </div>
40
+ </ContextMenu>
41
+ </div>
42
+
43
+ <button type="button" class="btn" bind:this={target}>Target Right Click</button>
44
+ <ContextMenu {target}>
45
+ <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
46
+ <div class="font-bold">Context Menu</div>
47
+ <button role="menuitem" class="btn">Button</button>
48
+ <button role="menuitem" class="btn">Button</button>
49
+ <button role="menuitem" class="btn">Button</button>
50
+ </div>
51
+ </ContextMenu>
52
52
  ```
53
- -->
54
-
53
+ -->
54
+
55
55
  <script>import { onMount, tick } from "svelte";
56
56
  import { scale } from "svelte/transition";
57
57
  import { duration, start } from "../util/transition";
@@ -116,34 +116,34 @@ onMount(async () => {
116
116
  target.addEventListener("touchcancel", onTouchEnd);
117
117
  }
118
118
  });
119
- </script>
120
-
121
- <svelte:body on:click={hide} on:keydown={onKeyDown} />
122
-
123
- <span bind:this={base} role="presentation"></span>
124
-
125
- {#if display}
126
- <div
127
- role="menu"
128
- class={className}
129
- {id}
130
- bind:this={contextMenu}
131
- style:top="{coordinates.y}px"
132
- style:left="{coordinates.x}px"
133
- transition:scale={transition ? transition : { duration: 0 }}
134
- >
135
- <slot>Context Menu</slot>
136
- </div>
137
- {/if}
138
-
139
- <style>
140
- span {
141
- width: 0;
142
- height: 0;
143
- opacity: 0;
144
- }
145
- div {
146
- position: absolute;
147
- z-index: 10;
148
- }
149
- </style>
119
+ </script>
120
+
121
+ <svelte:body on:click={hide} on:keydown={onKeyDown} />
122
+
123
+ <span bind:this={base} role="presentation"></span>
124
+
125
+ {#if display}
126
+ <div
127
+ role="menu"
128
+ class={className}
129
+ {id}
130
+ bind:this={contextMenu}
131
+ style:top="{coordinates.y}px"
132
+ style:left="{coordinates.x}px"
133
+ transition:scale={transition ? transition : { duration: 0 }}
134
+ >
135
+ <slot>Context Menu</slot>
136
+ </div>
137
+ {/if}
138
+
139
+ <style>
140
+ span {
141
+ width: 0;
142
+ height: 0;
143
+ opacity: 0;
144
+ }
145
+ div {
146
+ position: absolute;
147
+ z-index: 10;
148
+ }
149
+ </style>
@@ -23,11 +23,11 @@ Uses the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipbo
23
23
  @example
24
24
 
25
25
  ```svelte
26
- <script lang="ts">
27
- import { CopyButton } from "drab";
28
- </script>
29
-
30
- <CopyButton class="btn" text="Text to copy" />
26
+ <script lang="ts">
27
+ import { CopyButton } from "drab";
28
+ </script>
29
+
30
+ <CopyButton class="btn" text="Text to copy" />
31
31
  ```
32
32
  -->
33
33