sveltacular 0.0.9 → 0.0.11

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.
@@ -0,0 +1,15 @@
1
+ <svg
2
+ class="w-6 h-6 text-gray-800 dark:text-white"
3
+ aria-hidden="true"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ fill="none"
6
+ viewBox="0 0 17 14"
7
+ >
8
+ <path
9
+ stroke="currentColor"
10
+ stroke-linecap="round"
11
+ stroke-linejoin="round"
12
+ stroke-width="2"
13
+ d="M1 1h15M1 7h15M1 13h15"
14
+ />
15
+ </svg>
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} HamburgerIconProps */
2
+ /** @typedef {typeof __propDef.events} HamburgerIconEvents */
3
+ /** @typedef {typeof __propDef.slots} HamburgerIconSlots */
4
+ export default class HamburgerIcon extends SvelteComponent<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type HamburgerIconProps = typeof __propDef.props;
11
+ export type HamburgerIconEvents = typeof __propDef.events;
12
+ export type HamburgerIconSlots = typeof __propDef.slots;
13
+ import { SvelteComponent } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ [x: string]: never;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
@@ -0,0 +1,28 @@
1
+ <script>export let href;
2
+ export let color = "rgb(0, 0, 0)";
3
+ </script>
4
+
5
+ <span style={`--icon-path: url("${href}"); --icon-color: ${color};`} />
6
+
7
+ <style>span {
8
+ display: block;
9
+ background-color: var(--icon-color, rgb(0, 0, 0));
10
+ width: 100%;
11
+ height: 100%;
12
+ -moz-mask-size: contain;
13
+ -moz-mask-image: var(--icon-path);
14
+ -moz-mask-repeat: no-repeat;
15
+ -moz-mask-position: center;
16
+ -ms-mask-size: contain;
17
+ -ms-mask-image: var(--icon-path);
18
+ -ms-mask-repeat: no-repeat;
19
+ -ms-mask-position: center;
20
+ -webkit-mask-size: contain;
21
+ -webkit-mask-image: var(--icon-path);
22
+ -webkit-mask-repeat: no-repeat;
23
+ -webkit-mask-position: center;
24
+ mask-size: contain;
25
+ mask-image: var(--icon-path);
26
+ mask-repeat: no-repeat;
27
+ mask-position: center;
28
+ }</style>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ href: string;
5
+ color?: string | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type IconProps = typeof __propDef.props;
13
+ export type IconEvents = typeof __propDef.events;
14
+ export type IconSlots = typeof __propDef.slots;
15
+ export default class Icon extends SvelteComponent<IconProps, IconEvents, IconSlots> {
16
+ }
17
+ export {};
@@ -1,16 +1,31 @@
1
- <script>export let sources;
1
+ <script>export let src = "";
2
2
  export let alt = "";
3
+ export let href = void 0;
4
+ export let align = "center";
5
+ $:
6
+ sources = Array.isArray(src) ? src : typeof src === "string" ? [{ url: src }] : [src];
3
7
  $:
4
8
  finalSource = sources[sources.length - 1];
5
9
  </script>
6
10
 
7
- <div>
8
- <picture>
9
- {#each sources as source}
10
- <source srcset={source.url} media={source.media} />
11
- {/each}
12
- <img src={finalSource.url} {alt} />
13
- </picture>
11
+ <div class={align}>
12
+ {#if href}
13
+ <a {href}>
14
+ <picture>
15
+ {#each sources as source}
16
+ <source srcset={source.url} media={source.media} />
17
+ {/each}
18
+ <img src={finalSource.url} {alt} />
19
+ </picture>
20
+ </a>
21
+ {:else}
22
+ <picture>
23
+ {#each sources as source}
24
+ <source srcset={source.url} media={source.media} />
25
+ {/each}
26
+ <img src={finalSource.url} {alt} />
27
+ </picture>
28
+ {/if}
14
29
  {#if $$slots.default}
15
30
  <div class="caption">
16
31
  <slot />
@@ -18,31 +33,43 @@ $:
18
33
  {/if}
19
34
  </div>
20
35
 
21
- <style>
22
- div {
23
- position: relative;
24
- }
25
-
26
- .caption {
27
- position: absolute;
28
- bottom: 0;
29
- left: 0;
30
- right: 0;
31
- padding: 1rem;
32
- background: rgba(0, 0, 0, 0.5);
33
- color: white;
34
- }
35
-
36
- picture {
37
- display: block;
38
- width: 100%;
39
- height: 100%;
40
- }
41
-
42
- img {
43
- display: block;
44
- width: 100%;
45
- height: 100%;
46
- object-fit: cover;
47
- }
48
- </style>
36
+ <style>div {
37
+ position: relative;
38
+ width: 100%;
39
+ height: 100%;
40
+ }
41
+ div .caption {
42
+ position: absolute;
43
+ bottom: 0;
44
+ left: 0;
45
+ right: 0;
46
+ padding: 1rem;
47
+ background: rgba(0, 0, 0, 0.5);
48
+ color: white;
49
+ }
50
+ div picture {
51
+ display: block;
52
+ width: 100%;
53
+ height: 100%;
54
+ max-width: 100%;
55
+ max-height: 100%;
56
+ object-fit: contain;
57
+ object-position: center;
58
+ }
59
+ div img {
60
+ display: block;
61
+ width: 100%;
62
+ height: 100%;
63
+ max-width: 100%;
64
+ max-height: 100%;
65
+ object-fit: contain;
66
+ object-position: center;
67
+ }
68
+ div.left picture,
69
+ div.left img {
70
+ object-position: left;
71
+ }
72
+ div.right picture,
73
+ div.right img {
74
+ object-position: right;
75
+ }</style>
@@ -1,11 +1,16 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- sources: Array<{
4
+ src?: string | {
5
5
  url: string;
6
- media?: string;
7
- }>;
6
+ media?: string | undefined;
7
+ } | {
8
+ url: string;
9
+ media?: string | undefined;
10
+ }[] | undefined;
8
11
  alt?: string | undefined;
12
+ href?: string | undefined;
13
+ align?: "center" | "left" | "right" | undefined;
9
14
  };
10
15
  events: {
11
16
  [evt: string]: CustomEvent<any>;
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export { default as Pill } from './generic/pill/pill.svelte';
21
21
  export { default as Scorecard } from './generic/scorecard/scorecard.svelte';
22
22
  export { default as Overlay } from './generic/overlay.svelte';
23
23
  export { default as Image } from './images/image.svelte';
24
+ export { default as Icon } from './images/icon.svelte';
24
25
  export { default as Menu } from './generic/menu/menu.svelte';
25
26
  export { default as Date } from './generic/date/date.svelte';
26
27
  export { default as Panel } from './generic/panel/panel.svelte';
@@ -43,6 +44,9 @@ export { default as Breadcrumbs } from './navigation/breadcrumbs/breadcrumbs.sve
43
44
  export { default as SideBar } from './navigation/side-bar/side-bar.svelte';
44
45
  export { default as TabGroup } from './navigation/tabs/tab-group.svelte';
45
46
  export { default as Tab } from './navigation/tabs/tab.svelte';
47
+ export { default as AppLogo } from './navigation/app-bar/app-logo.svelte';
48
+ export { default as AppNav } from './navigation/app-bar/app-nav.svelte';
49
+ export { default as AppNavItem } from './navigation/app-bar/app-nav-item.svelte';
46
50
  export { default as DataGrid } from './tables/data-grid.svelte';
47
51
  export { default as Table } from './tables/table.svelte';
48
52
  export { default as TableBody } from './tables/table-body.svelte';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export { default as Pill } from './generic/pill/pill.svelte';
23
23
  export { default as Scorecard } from './generic/scorecard/scorecard.svelte';
24
24
  export { default as Overlay } from './generic/overlay.svelte';
25
25
  export { default as Image } from './images/image.svelte';
26
+ export { default as Icon } from './images/icon.svelte';
26
27
  export { default as Menu } from './generic/menu/menu.svelte';
27
28
  export { default as Date } from './generic/date/date.svelte';
28
29
  export { default as Panel } from './generic/panel/panel.svelte';
@@ -48,6 +49,9 @@ export { default as Breadcrumbs } from './navigation/breadcrumbs/breadcrumbs.sve
48
49
  export { default as SideBar } from './navigation/side-bar/side-bar.svelte';
49
50
  export { default as TabGroup } from './navigation/tabs/tab-group.svelte';
50
51
  export { default as Tab } from './navigation/tabs/tab.svelte';
52
+ export { default as AppLogo } from './navigation/app-bar/app-logo.svelte';
53
+ export { default as AppNav } from './navigation/app-bar/app-nav.svelte';
54
+ export { default as AppNavItem } from './navigation/app-bar/app-nav-item.svelte';
51
55
  // Tables
52
56
  export { default as DataGrid } from './tables/data-grid.svelte';
53
57
  export { default as Table } from './tables/table.svelte';
@@ -1,7 +1,14 @@
1
- <script>export let isFixed = true;
1
+ <script>import { setContext } from "svelte";
2
+ export let isFixed = true;
2
3
  export let position = "top";
3
4
  export let size = "md";
4
5
  export let padding = "md";
6
+ setContext("app-bar", {
7
+ isFixed,
8
+ position,
9
+ size,
10
+ padding
11
+ });
5
12
  </script>
6
13
 
7
14
  <header class="{position} {size} padding-{padding} {isFixed ? 'fixed' : 'absolute'}">
@@ -9,10 +16,12 @@ export let padding = "md";
9
16
  </header>
10
17
 
11
18
  <style>header {
12
- display: block;
13
- background: #fff;
14
- color: #000;
15
- padding: 0.5rem;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: space-between;
22
+ width: 100%;
23
+ background: var(--nav-bg, #fff);
24
+ color: var(--nav-fg, #000);
16
25
  position: absolute;
17
26
  top: 0;
18
27
  left: 0;
@@ -50,4 +59,8 @@ header.padding-lg {
50
59
  }
51
60
  header.padding-xl {
52
61
  padding: 1.5rem;
62
+ }
63
+ header.isTransparent {
64
+ background: transparent;
65
+ color: inherit;
53
66
  }</style>
@@ -0,0 +1,7 @@
1
+ <script>import Image from "../../images/image.svelte";
2
+ export let src;
3
+ export let alt;
4
+ export let href;
5
+ </script>
6
+
7
+ <Image {src} {alt} {href} align="left" />
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ src: string;
5
+ alt: string;
6
+ href: string;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type AppLogoProps = typeof __propDef.props;
14
+ export type AppLogoEvents = typeof __propDef.events;
15
+ export type AppLogoSlots = typeof __propDef.slots;
16
+ export default class AppLogo extends SvelteComponent<AppLogoProps, AppLogoEvents, AppLogoSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,51 @@
1
+ <script>import { getContext } from "svelte";
2
+ export let href;
3
+ export let title;
4
+ const open = getContext("app-nav-state");
5
+ </script>
6
+
7
+ <a {href} class={$open ? 'open' : 'closed'}>
8
+ {#if $$slots.default}
9
+ <div class="icon">
10
+ <slot />
11
+ </div>
12
+ {/if}
13
+ <div class="title">{title}</div>
14
+ </a>
15
+
16
+ <style>a {
17
+ display: flex;
18
+ flex-direction: column;
19
+ gap: 0.2rem;
20
+ align-items: center;
21
+ height: 100%;
22
+ color: var(--nav-link-color, black);
23
+ text-decoration: none;
24
+ }
25
+ a:hover {
26
+ color: var(--nav-link-hover-color, black);
27
+ text-decoration: underline;
28
+ }
29
+ a .icon {
30
+ width: 100%;
31
+ height: 1.5rem;
32
+ }
33
+
34
+ @media (max-width: 640px) {
35
+ a.open {
36
+ flex-direction: row;
37
+ gap: 1rem;
38
+ width: 100%;
39
+ padding: 1rem;
40
+ }
41
+ a.open:hover {
42
+ text-decoration: none;
43
+ background-color: #bbb;
44
+ }
45
+ a.open .title {
46
+ flex-grow: 1;
47
+ }
48
+ a.open .icon {
49
+ width: 1.5rem;
50
+ }
51
+ }</style>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ href: string;
5
+ title: string;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type AppNavItemProps = typeof __propDef.props;
15
+ export type AppNavItemEvents = typeof __propDef.events;
16
+ export type AppNavItemSlots = typeof __propDef.slots;
17
+ export default class AppNavItem extends SvelteComponent<AppNavItemProps, AppNavItemEvents, AppNavItemSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,110 @@
1
+ <script>import HamburgerIcon from "../../icons/hamburger-icon.svelte";
2
+ import { getContext, setContext } from "svelte";
3
+ import { get, writable } from "svelte/store";
4
+ export let align = "right";
5
+ export let spacing = "medium";
6
+ const open = writable(false);
7
+ setContext("app-nav-state", open);
8
+ const toggle = () => open.set(!get(open));
9
+ const context = getContext("app-bar");
10
+ const collapse = context.position !== "bottom" ? "collapse" : "";
11
+ </script>
12
+
13
+ <div class="icon {$open ? 'open' : 'closed'} {collapse}">
14
+ <button on:click={toggle}>
15
+ <HamburgerIcon />
16
+ </button>
17
+ </div>
18
+ <nav class="{align} {spacing} {collapse} {$open ? 'open' : 'closed'}">
19
+ <slot />
20
+ </nav>
21
+
22
+ <style>.icon {
23
+ display: none;
24
+ }
25
+
26
+ nav {
27
+ display: flex;
28
+ flex-direction: row;
29
+ flex-grow: 0;
30
+ gap: 1rem;
31
+ margin: 1rem;
32
+ width: 100%;
33
+ align-items: center;
34
+ justify-content: center;
35
+ }
36
+ nav.left, nav.start {
37
+ justify-content: flex-start;
38
+ }
39
+ nav.center {
40
+ justify-content: center;
41
+ }
42
+ nav.right {
43
+ justify-content: flex-end;
44
+ }
45
+ nav.none {
46
+ gap: 0;
47
+ }
48
+ nav.tight {
49
+ gap: 0.5rem;
50
+ }
51
+ nav.medium {
52
+ gap: 1rem;
53
+ }
54
+ nav.loose {
55
+ gap: 2rem;
56
+ }
57
+ nav.space-evenly {
58
+ justify-content: space-evenly;
59
+ }
60
+ nav.space-between {
61
+ justify-content: space-between;
62
+ }
63
+ nav.space-around {
64
+ justify-content: space-around;
65
+ }
66
+
67
+ /* Small screens */
68
+ @media (max-width: 640px) {
69
+ .icon.collapse {
70
+ display: block;
71
+ justify-content: flex-end;
72
+ align-content: center;
73
+ width: 30%;
74
+ height: 100%;
75
+ text-align: right;
76
+ padding-right: 0.5rem;
77
+ padding-left: 0.5rem;
78
+ }
79
+ .icon.collapse button {
80
+ appearance: none;
81
+ border: none;
82
+ background-color: transparent;
83
+ width: 100%;
84
+ height: 100%;
85
+ max-width: 2.5rem;
86
+ cursor: pointer;
87
+ }
88
+ .icon.collapse.open {
89
+ opacity: 0.3;
90
+ }
91
+ nav.collapse {
92
+ display: none;
93
+ }
94
+ nav.collapse.open {
95
+ display: flex;
96
+ flex-direction: column;
97
+ align-items: flex-end;
98
+ position: absolute;
99
+ top: 100%;
100
+ right: 0;
101
+ width: auto;
102
+ min-width: 50%;
103
+ box-shadow: -2px 4px 3px 0px black;
104
+ background: var(--nav-bg, #fff);
105
+ color: var(--nav-fg, #000);
106
+ margin: 0;
107
+ padding: 0;
108
+ gap: 0;
109
+ }
110
+ }</style>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ align?: "center" | "end" | "start" | "left" | "right" | undefined;
5
+ spacing?: "none" | "medium" | "tight" | "loose" | "space-evenly" | "space-around" | "space-between" | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type AppNavProps = typeof __propDef.props;
15
+ export type AppNavEvents = typeof __propDef.events;
16
+ export type AppNavSlots = typeof __propDef.slots;
17
+ export default class AppNav extends SvelteComponent<AppNavProps, AppNavEvents, AppNavSlots> {
18
+ }
19
+ export {};
@@ -3,9 +3,15 @@ import AngleRightIcon from "../../icons/angle-right-icon.svelte";
3
3
  import HomeIcon from "../../icons/home-icon.svelte";
4
4
  export let homeUrl = null;
5
5
  export let crumbs = [];
6
+ export let size = "md";
7
+ const getCrumLabel = (crumb) => {
8
+ if (typeof crumb === "string")
9
+ return crumb;
10
+ return crumb.label;
11
+ };
6
12
  </script>
7
13
 
8
- <nav>
14
+ <nav class={size}>
9
15
  {#if homeUrl}
10
16
  <li class="icon">
11
17
  <Link href={homeUrl} display="block">
@@ -14,8 +20,8 @@ export let crumbs = [];
14
20
  </li>
15
21
  {/if}
16
22
  {#each crumbs as crumb, i}
17
- {#if typeof crumb === 'string'}
18
- <li>{crumb}</li>
23
+ {#if typeof crumb === 'string' || !crumb.href}
24
+ <li>{getCrumLabel(crumb)}</li>
19
25
  {:else}
20
26
  <li>
21
27
  <Link href={crumb.href}>
@@ -44,13 +50,23 @@ nav li {
44
50
  align-items: center;
45
51
  vertical-align: middle;
46
52
  margin-left: 0.5rem;
47
- font-size: 0.75rem;
48
53
  color: rgba(255, 255, 255, 0.5);
49
- min-width: 12px;
50
54
  }
51
55
  nav li:first-child {
52
56
  margin-left: 0;
53
57
  }
54
58
  nav li.icon {
55
59
  padding-top: 2px;
60
+ }
61
+ nav.sm li {
62
+ font-size: 0.75rem;
63
+ min-width: 12px;
64
+ }
65
+ nav.md li {
66
+ font-size: 0.875rem;
67
+ min-width: 14px;
68
+ }
69
+ nav.lg li {
70
+ font-size: 1rem;
71
+ min-width: 16px;
56
72
  }</style>
@@ -4,8 +4,9 @@ declare const __propDef: {
4
4
  homeUrl?: string | null | undefined;
5
5
  crumbs?: (string | {
6
6
  label: string;
7
- href: string;
7
+ href?: string | undefined;
8
8
  })[] | undefined;
9
+ size?: "sm" | "md" | "lg" | undefined;
9
10
  };
10
11
  events: {
11
12
  [evt: string]: CustomEvent<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltacular",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "scripts": {
5
5
  "watch": "npm run dev -- --open",
6
6
  "dev": "vite dev",