sveltacular 0.0.11 → 0.0.12

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,11 +1,31 @@
1
- # Sveltacular
1
+ ![Sveltacular](https://raw.githubusercontent.com/jasonbyrne/sveltacular/main/static/sveltacular.png)
2
2
 
3
- I got tired of creating the same components over and over, so I decided to make an open source library of Svelte components.
3
+ Sveltacular is TypeScript and SASS based component library for Svelte, with no other dependencies.
4
4
 
5
- This library is TypeScript and SASS based. It uses vanilla CSS without any frameworks to get in the way.
5
+ Why did I create it when there are other options? Well, mainly because the best options out there were based on Tailwind. And, no disrespect to those who love it, but I didn't want to use Tailwind. So since I didn't find what I was loooking for, I made my own.
6
6
 
7
7
  ## Run Storybook
8
8
 
9
- ```
9
+ I don't have great documentation for now, but you can browse all of the available components by running Storybook locally. Check out the repo and then run this command:
10
+
11
+ ```bash
10
12
  npm run storybook
11
13
  ```
14
+
15
+ ## Usage
16
+
17
+ Install it in your project
18
+
19
+ ```bash
20
+ npm i sveltacular
21
+ ```
22
+
23
+ Then use it like this:
24
+
25
+ ```svelte
26
+ <script lang="ts">
27
+ import { Button } from 'sveltacular';
28
+ </script>
29
+
30
+ <Button>Hello World</Button>
31
+ ```
@@ -1,19 +1,28 @@
1
- <script>import { getContext } from "svelte";
2
- export let href;
1
+ <script>import { navigateTo } from "../../index.js";
2
+ import { createEventDispatcher, getContext } from "svelte";
3
+ export let href = void 0;
3
4
  export let title;
5
+ const dispatch = createEventDispatcher();
4
6
  const open = getContext("app-nav-state");
7
+ const click = () => {
8
+ if (href)
9
+ navigateTo(href);
10
+ dispatch("click");
11
+ };
5
12
  </script>
6
13
 
7
- <a {href} class={$open ? 'open' : 'closed'}>
14
+ <button class={$open ? 'open' : 'closed'} on:click={click}>
8
15
  {#if $$slots.default}
9
16
  <div class="icon">
10
17
  <slot />
11
18
  </div>
12
19
  {/if}
13
- <div class="title">{title}</div>
14
- </a>
20
+ <div class="title">
21
+ {title}
22
+ </div>
23
+ </button>
15
24
 
16
- <style>a {
25
+ <style>button {
17
26
  display: flex;
18
27
  flex-direction: column;
19
28
  gap: 0.2rem;
@@ -21,31 +30,36 @@ const open = getContext("app-nav-state");
21
30
  height: 100%;
22
31
  color: var(--nav-link-color, black);
23
32
  text-decoration: none;
33
+ appearance: none;
34
+ border: none;
35
+ background-color: transparent;
36
+ cursor: pointer;
24
37
  }
25
- a:hover {
38
+ button:hover {
26
39
  color: var(--nav-link-hover-color, black);
27
40
  text-decoration: underline;
28
41
  }
29
- a .icon {
42
+ button .icon {
30
43
  width: 100%;
31
44
  height: 1.5rem;
32
45
  }
33
46
 
34
47
  @media (max-width: 640px) {
35
- a.open {
48
+ button.open {
36
49
  flex-direction: row;
37
50
  gap: 1rem;
38
51
  width: 100%;
39
52
  padding: 1rem;
53
+ text-align: left;
40
54
  }
41
- a.open:hover {
55
+ button.open:hover {
42
56
  text-decoration: none;
43
57
  background-color: #bbb;
44
58
  }
45
- a.open .title {
59
+ button.open .title {
46
60
  flex-grow: 1;
47
61
  }
48
- a.open .icon {
62
+ button.open .icon {
49
63
  width: 1.5rem;
50
64
  }
51
65
  }</style>
@@ -1,10 +1,12 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- href: string;
4
+ href?: string | undefined;
5
5
  title: string;
6
6
  };
7
7
  events: {
8
+ click: CustomEvent<void>;
9
+ } & {
8
10
  [evt: string]: CustomEvent<any>;
9
11
  };
10
12
  slots: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltacular",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "scripts": {
5
5
  "watch": "npm run dev -- --open",
6
6
  "dev": "vite dev",