smorks-svelte-ui 0.0.1-alpha.1

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 ADDED
@@ -0,0 +1,58 @@
1
+ # create-svelte
2
+
3
+ Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
4
+
5
+ Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging).
6
+
7
+ ## Creating a project
8
+
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
+
11
+ ```bash
12
+ # create a new project in the current directory
13
+ npm create svelte@latest
14
+
15
+ # create a new project in my-app
16
+ npm create svelte@latest my-app
17
+ ```
18
+
19
+ ## Developing
20
+
21
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
+
23
+ ```bash
24
+ npm run dev
25
+
26
+ # or start the server and open the app in a new browser tab
27
+ npm run dev -- --open
28
+ ```
29
+
30
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
+
32
+ ## Building
33
+
34
+ To build your library:
35
+
36
+ ```bash
37
+ npm run package
38
+ ```
39
+
40
+ To create a production version of your showcase app:
41
+
42
+ ```bash
43
+ npm run build
44
+ ```
45
+
46
+ You can preview the production build with `npm run preview`.
47
+
48
+ > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
49
+
50
+ ## Publishing
51
+
52
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
+
54
+ To publish your library to [npm](https://www.npmjs.com):
55
+
56
+ ```bash
57
+ npm publish
58
+ ```
@@ -0,0 +1,88 @@
1
+ <script>import IconBase from "./icons/IconBase.svelte";
2
+ import Spinner from "./Spinner.svelte";
3
+ export let label = void 0;
4
+ export let color = void 0;
5
+ export let onClick = void 0;
6
+ export let icon = void 0;
7
+ let working = false;
8
+ export async function buttonClick() {
9
+ if (working) {
10
+ return;
11
+ }
12
+ working = true;
13
+ if (onClick) {
14
+ await onClick();
15
+ }
16
+ working = false;
17
+ }
18
+ </script>
19
+
20
+ <div class="container">
21
+ <button class="button{color ? ' ' + color : ''}" on:click={buttonClick}>
22
+ <div class="outer">
23
+ {#if working}
24
+ <div class="spinner">
25
+ <Spinner />
26
+ </div>
27
+ {/if}
28
+ <div class="content" class:hidden={working}>
29
+ {#if icon}
30
+ <div class="icon">
31
+ <IconBase name={label} {icon} />
32
+ </div>
33
+ {/if}
34
+ {#if label}
35
+ <div class="label">{label}</div>
36
+ {/if}
37
+ <div class="inner">
38
+ <slot />
39
+ </div>
40
+ </div>
41
+ </div>
42
+ </button>
43
+ </div>
44
+
45
+ <style>
46
+ .container {
47
+ display: inline-block;
48
+ }
49
+ .button {
50
+ cursor: pointer;
51
+ }
52
+ .outer {
53
+ position: relative;
54
+ }
55
+ .content {
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ }
60
+ .icon {
61
+ padding-right: 4px;
62
+ }
63
+ .button .spinner {
64
+ position: absolute;
65
+ top: 0;
66
+ bottom: 0;
67
+ left: 0;
68
+ right: 0;
69
+ display: flex;
70
+ justify-content: center;
71
+ align-items: center;
72
+ overflow: hidden;
73
+ }
74
+ .button .spinner .inner {
75
+ width: 1.2em;
76
+ height: 1.2em;
77
+ }
78
+ .button .label {
79
+ min-height: 1.2em;
80
+ }
81
+ .inner {
82
+ display: flex;
83
+ align-items: center;
84
+ }
85
+ .hidden {
86
+ visibility: hidden;
87
+ }
88
+ </style>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ label?: string | undefined;
5
+ color?: string | undefined;
6
+ onClick?: (() => Promise<void>) | undefined;
7
+ icon?: string | undefined;
8
+ buttonClick?: (() => Promise<void>) | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {
14
+ default: {};
15
+ };
16
+ };
17
+ export type ButtonSpinnerProps = typeof __propDef.props;
18
+ export type ButtonSpinnerEvents = typeof __propDef.events;
19
+ export type ButtonSpinnerSlots = typeof __propDef.slots;
20
+ export default class ButtonSpinner extends SvelteComponent<ButtonSpinnerProps, ButtonSpinnerEvents, ButtonSpinnerSlots> {
21
+ get buttonClick(): () => Promise<void>;
22
+ }
23
+ export {};
@@ -0,0 +1,15 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ let dispatch = createEventDispatcher();
3
+ function handleKeyUp(e) {
4
+ if (e.key === "Enter") {
5
+ dispatch("keyup-enter");
6
+ } else if (e.key === "Escape") {
7
+ dispatch("keyup-esc");
8
+ }
9
+ }
10
+ </script>
11
+
12
+ <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
13
+ <div role="group" on:keyup={handleKeyUp}>
14
+ <slot />
15
+ </div>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ 'keyup-enter': CustomEvent<any>;
6
+ 'keyup-esc': CustomEvent<any>;
7
+ } & {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type FormProps = typeof __propDef.props;
15
+ export type FormEvents = typeof __propDef.events;
16
+ export type FormSlots = typeof __propDef.slots;
17
+ export default class Form extends SvelteComponent<FormProps, FormEvents, FormSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,52 @@
1
+ <div class="container">
2
+ <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" role="presentation">
3
+ <ellipse cx="50" cy="50" rx="45" ry="45" />
4
+ </svg>
5
+ </div>
6
+
7
+ <style>
8
+ .container {
9
+ width: 100%;
10
+ height: 100%;
11
+ }
12
+ .container svg {
13
+ animation: 2s linear infinite spinner-svg;
14
+ width: 100%;
15
+ height: 100%;
16
+ }
17
+ .container ellipse {
18
+ animation: 1.4s ease-in-out infinite both spinner-circle;
19
+ display: block;
20
+ fill: transparent;
21
+ stroke: currentColor;
22
+ stroke-linecap: round;
23
+ stroke-dasharray: 283;
24
+ stroke-dashoffset: 280;
25
+ stroke-width: 10px;
26
+ transform-origin: 50% 50%;
27
+ }
28
+ @keyframes spinner-svg {
29
+ 0% {
30
+ transform: rotateZ(0deg);
31
+ }
32
+ 100% {
33
+ transform: rotateZ(360deg);
34
+ }
35
+ }
36
+ @keyframes spinner-circle {
37
+ 0%,
38
+ 25% {
39
+ stroke-dashoffset: 280;
40
+ transform: rotate(0);
41
+ }
42
+ 50%,
43
+ 75% {
44
+ stroke-dashoffset: 75;
45
+ transform: rotate(45deg);
46
+ }
47
+ 100% {
48
+ stroke-dashoffset: 280;
49
+ transform: rotate(360deg);
50
+ }
51
+ }
52
+ </style>
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} SpinnerProps */
2
+ /** @typedef {typeof __propDef.events} SpinnerEvents */
3
+ /** @typedef {typeof __propDef.slots} SpinnerSlots */
4
+ export default class Spinner extends SvelteComponent<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type SpinnerProps = typeof __propDef.props;
11
+ export type SpinnerEvents = typeof __propDef.events;
12
+ export type SpinnerSlots = 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,103 @@
1
+ <script>import { onMount, createEventDispatcher } from "svelte";
2
+ export let label;
3
+ export let readonly = false;
4
+ export let type = "text";
5
+ export let value = void 0;
6
+ export let num = void 0;
7
+ export let focus = false;
8
+ export let items = void 0;
9
+ const dispatch = createEventDispatcher();
10
+ let inputEl;
11
+ let selectEl;
12
+ onMount(() => {
13
+ if (focus) {
14
+ inputEl.focus();
15
+ }
16
+ });
17
+ function numericKeyDown(e) {
18
+ let valid = false;
19
+ if (e.key.length == 1) {
20
+ const keyCode = e.key.charCodeAt(0);
21
+ valid = keyCode >= 48 && keyCode <= 57;
22
+ } else {
23
+ valid = e.key === "Backspace" || e.key === "Tab";
24
+ }
25
+ if (!valid) {
26
+ e.preventDefault();
27
+ }
28
+ return true;
29
+ }
30
+ function dropdownChange() {
31
+ dispatch("dropdown-change", { value: selectEl.value });
32
+ }
33
+ </script>
34
+
35
+ <div class="field-container" class:readonly>
36
+ <div class="field">
37
+ <div class="label">{label}</div>
38
+ {#if type === 'password'}
39
+ <input class="input" type="password" bind:value bind:this={inputEl} />
40
+ {:else if type === 'numeric'}
41
+ <input
42
+ class="input number"
43
+ type="number"
44
+ bind:value={num}
45
+ bind:this={inputEl}
46
+ on:keydown={numericKeyDown}
47
+ />
48
+ {:else if type === 'dropdown'}
49
+ <select class="input select" bind:value bind:this={selectEl} on:change={dropdownChange}>
50
+ {#if items}
51
+ {#each items as item}
52
+ <option>{item}</option>
53
+ {/each}
54
+ {/if}
55
+ </select>
56
+ {:else}
57
+ <input class="input" type="text" bind:value bind:this={inputEl} />
58
+ {/if}
59
+ </div>
60
+ </div>
61
+
62
+ <style>
63
+ .field-container {
64
+ text-align: left;
65
+ background-color: var(--field-bg);
66
+ border-radius: 4px;
67
+ margin: 2px 0;
68
+ border: 1px solid transparent;
69
+ }
70
+ .field-container:focus-within {
71
+ border-color: var(--highlight);
72
+ box-shadow: 0 0 5px var(--highlight);
73
+ }
74
+ .field-container.readonly:focus-within {
75
+ border-color: transparent;
76
+ box-shadow: none;
77
+ }
78
+ .field {
79
+ padding: 2px;
80
+ width: 100%;
81
+ min-width: 16rem;
82
+ }
83
+ .field .label {
84
+ font-size: 0.7em;
85
+ font-weight: bold;
86
+ color: var(--field-label);
87
+ }
88
+ .field .input {
89
+ color: var(--fg);
90
+ background-color: transparent;
91
+ border: 0;
92
+ width: 100%;
93
+ }
94
+ .field .input.number {
95
+ appearance: textfield;
96
+ }
97
+ .field .input.select {
98
+ background-color: var(--field-bg);
99
+ }
100
+ .field .input:focus {
101
+ outline: none !important;
102
+ }
103
+ </style>
@@ -0,0 +1,24 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ label: string;
5
+ readonly?: boolean | undefined;
6
+ type?: "text" | "password" | "numeric" | "dropdown" | undefined;
7
+ value?: string | undefined;
8
+ num?: number | undefined;
9
+ focus?: boolean | undefined;
10
+ items?: string[] | undefined;
11
+ };
12
+ events: {
13
+ 'dropdown-change': CustomEvent<any>;
14
+ } & {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {};
18
+ };
19
+ export type TextFieldProps = typeof __propDef.props;
20
+ export type TextFieldEvents = typeof __propDef.events;
21
+ export type TextFieldSlots = typeof __propDef.slots;
22
+ export default class TextField extends SvelteComponent<TextFieldProps, TextFieldEvents, TextFieldSlots> {
23
+ }
24
+ export {};
@@ -0,0 +1,19 @@
1
+ <script>import ToastSingle from "./ToastSingle.svelte";
2
+ import { toastList } from "../store/toast-list";
3
+ import { slide } from "svelte/transition";
4
+ function onToastHide(t) {
5
+ toastList.remove(t.id);
6
+ }
7
+ </script>
8
+
9
+ {#each $toastList.toasts as toast (toast.id)}
10
+ <div class="toast" transition:slide={{ axis: 'y' }}>
11
+ <ToastSingle {toast} on:toast-hide={() => onToastHide(toast)} />
12
+ </div>
13
+ {/each}
14
+
15
+ <style>
16
+ .toast {
17
+ padding-bottom: 4px;
18
+ }
19
+ </style>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: Record<string, never>;
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export type ToastListProps = typeof __propDef.props;
10
+ export type ToastListEvents = typeof __propDef.events;
11
+ export type ToastListSlots = typeof __propDef.slots;
12
+ export default class ToastList extends SvelteComponent<ToastListProps, ToastListEvents, ToastListSlots> {
13
+ }
14
+ export {};
@@ -0,0 +1,46 @@
1
+ <script>import { createEventDispatcher, onMount } from "svelte";
2
+ import { fade } from "svelte/transition";
3
+ export let toast;
4
+ export let timeout = 2e3;
5
+ let show = true;
6
+ let dispatch = createEventDispatcher();
7
+ let id = void 0;
8
+ onMount(() => {
9
+ id = setTimeout(() => {
10
+ id = void 0;
11
+ show = false;
12
+ }, timeout);
13
+ });
14
+ function fadeOutEnd() {
15
+ dispatch("toast-hide");
16
+ }
17
+ </script>
18
+
19
+ {#if show}
20
+ <div
21
+ class="toast"
22
+ class:normal={toast.type == 'normal'}
23
+ class:error={toast.type == 'error'}
24
+ class:success={toast.type == 'success'}
25
+ transition:fade={{ duration: 500 }}
26
+ on:outroend={fadeOutEnd}
27
+ >
28
+ {toast.text}
29
+ </div>
30
+ {/if}
31
+
32
+ <style>
33
+ .toast {
34
+ padding: 4px;
35
+ border-radius: 4px;
36
+ }
37
+ .normal {
38
+ background-color: lightgray;
39
+ }
40
+ .error {
41
+ background-color: lightpink;
42
+ }
43
+ .success {
44
+ background-color: lightgreen;
45
+ }
46
+ </style>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Toast } from '../store/toast-list';
3
+ declare const __propDef: {
4
+ props: {
5
+ toast: Toast;
6
+ timeout?: number | undefined;
7
+ };
8
+ events: {
9
+ 'toast-hide': CustomEvent<any>;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type ToastSingleProps = typeof __propDef.props;
16
+ export type ToastSingleEvents = typeof __propDef.events;
17
+ export type ToastSingleSlots = typeof __propDef.slots;
18
+ export default class ToastSingle extends SvelteComponent<ToastSingleProps, ToastSingleEvents, ToastSingleSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,238 @@
1
+ <slot />
2
+
3
+ <style global>@media screen and (prefers-color-scheme: light) {
4
+ :root {
5
+ --bg: white;
6
+ --fg: black;
7
+ --fgf: #666;
8
+ --highlight: #d79921;
9
+ --link: #458588;
10
+ --hdr: #ccc;
11
+ --hdr-link: #3383a6;
12
+ --field-bg: #ddd;
13
+ --field-label: #3c3836;
14
+ --red1: #9d0006;
15
+ --red2: #cc241d;
16
+ --red3: #fb4934;
17
+ --red4: #fa897d;
18
+ --blue1: #073c78;
19
+ --blue2: #456888;
20
+ --blue3: #8393a5;
21
+ --blue4: #aac0d6;
22
+ --green1: #2c790e;
23
+ --green2: #4c981a;
24
+ --green3: #6ebb26;
25
+ --green4: #92dc51;
26
+ --overlay: #0007;
27
+ --popup-bg: #666;
28
+ --popup-hdr-bg: #777;
29
+ }
30
+ :root.dark-mode {
31
+ --bg: black;
32
+ --fg: white;
33
+ --fgf: #666;
34
+ --highlight: #d79921;
35
+ --link: #57a7ab;
36
+ --hdr: #333;
37
+ --hdr-link: #1b4557;
38
+ --field-bg: #222;
39
+ --field-label: #8f8681;
40
+ --red4: #9d0006;
41
+ --red3: #cc241d;
42
+ --red2: #fb4934;
43
+ --red1: #fa897d;
44
+ --blue4: #073c78;
45
+ --blue3: #456888;
46
+ --blue2: #8393a5;
47
+ --blue1: #aac0d6;
48
+ --green4: #2c790e;
49
+ --green3: #4c981a;
50
+ --green2: #6ebb26;
51
+ --green1: #92dc51;
52
+ --overlay: #0007;
53
+ --popup-bg: #555;
54
+ --popup-hdr-bg: #666;
55
+ }
56
+ }
57
+ @media screen and (prefers-color-scheme: dark) {
58
+ :root {
59
+ --bg: black;
60
+ --fg: white;
61
+ --fgf: #666;
62
+ --highlight: #d79921;
63
+ --link: #57a7ab;
64
+ --hdr: #333;
65
+ --hdr-link: #1b4557;
66
+ --field-bg: #222;
67
+ --field-label: #8f8681;
68
+ --red4: #9d0006;
69
+ --red3: #cc241d;
70
+ --red2: #fb4934;
71
+ --red1: #fa897d;
72
+ --blue4: #073c78;
73
+ --blue3: #456888;
74
+ --blue2: #8393a5;
75
+ --blue1: #aac0d6;
76
+ --green4: #2c790e;
77
+ --green3: #4c981a;
78
+ --green2: #6ebb26;
79
+ --green1: #92dc51;
80
+ --overlay: #0007;
81
+ --popup-bg: #555;
82
+ --popup-hdr-bg: #666;
83
+ }
84
+ :root.light-mode {
85
+ --bg: white;
86
+ --fg: black;
87
+ --fgf: #666;
88
+ --highlight: #d79921;
89
+ --link: #458588;
90
+ --hdr: #ccc;
91
+ --hdr-link: #3383a6;
92
+ --field-bg: #ddd;
93
+ --field-label: #3c3836;
94
+ --red1: #9d0006;
95
+ --red2: #cc241d;
96
+ --red3: #fb4934;
97
+ --red4: #fa897d;
98
+ --blue1: #073c78;
99
+ --blue2: #456888;
100
+ --blue3: #8393a5;
101
+ --blue4: #aac0d6;
102
+ --green1: #2c790e;
103
+ --green2: #4c981a;
104
+ --green3: #6ebb26;
105
+ --green4: #92dc51;
106
+ --overlay: #0007;
107
+ --popup-bg: #666;
108
+ --popup-hdr-bg: #777;
109
+ }
110
+ }
111
+ body {
112
+ font-family: sans-serif;
113
+ margin: 0;
114
+ background-color: var(--bg);
115
+ color: var(--fg);
116
+ }
117
+ a {
118
+ color: var(--link);
119
+ transition: filter 0.25s;
120
+ }
121
+ a:visited {
122
+ color: var(--link);
123
+ }
124
+ a:hover {
125
+ filter: brightness(1.3);
126
+ }
127
+ .small {
128
+ font-size: 0.75rem;
129
+ color: var(--fgf);
130
+ }
131
+ .flex-v {
132
+ display: inline-flex;
133
+ flex-direction: column;
134
+ align-items: center;
135
+ }
136
+ .button {
137
+ color: var(--bg);
138
+ cursor: pointer;
139
+ padding: 6px;
140
+ margin-right: 6px;
141
+ border: 1px solid transparent;
142
+ border-radius: 3px;
143
+ background-color: var(--blue3);
144
+ min-width: 60px;
145
+ transition: filter 0.25s, transform 0.1s;
146
+ }
147
+ .button:hover {
148
+ filter: brightness(0.8);
149
+ border-color: var(--highlight);
150
+ box-shadow: 0 0 5px var(--highlight);
151
+ }
152
+ .button:active {
153
+ transform: scale(0.95);
154
+ }
155
+ .button.red {
156
+ background-color: var(--red3);
157
+ }
158
+ .button.green {
159
+ background-color: var(--green3);
160
+ }
161
+ .button.blue {
162
+ background-color: var(--blue3);
163
+ }
164
+ .buttons-flex-h {
165
+ display: flex;
166
+ }
167
+ /* popup classes */
168
+ .popup.container {
169
+ display: flex;
170
+ background-color: var(--overlay);
171
+ position: fixed;
172
+ top: 0;
173
+ left: 0;
174
+ right: 0;
175
+ bottom: 0;
176
+ z-index: 2000;
177
+ justify-content: center;
178
+ align-items: center;
179
+ color: var(--bg);
180
+ }
181
+ .popup.main {
182
+ background-color: var(--popup-bg);
183
+ padding-bottom: 6px;
184
+ max-width: 85%;
185
+ }
186
+ .popup.main .header {
187
+ background-color: var(--popup-hdr-bg);
188
+ padding: 8px;
189
+ font-weight: bold;
190
+ }
191
+ .popup.main .item {
192
+ padding-left: 12px;
193
+ padding-right: 12px;
194
+ }
195
+ .popup.main .body {
196
+ padding-top: 12px;
197
+ padding-bottom: 12px;
198
+ }
199
+ .table {
200
+ text-align: left;
201
+ border: 1px solid var(--fg);
202
+ border-spacing: 0;
203
+ border-collapse: collapse;
204
+ margin: 10px auto;
205
+ }
206
+ .table th,
207
+ .table td {
208
+ border: 1px solid var(--fg);
209
+ padding: 2px 4px;
210
+ }
211
+ .table th {
212
+ background-color: var(--blue3);
213
+ color: var(--bg);
214
+ }
215
+ .table td.center {
216
+ text-align: center;
217
+ }
218
+ .table td.name,
219
+ .table th.name {
220
+ width: 10rem;
221
+ }
222
+ .table td.actions,
223
+ .table th.actions {
224
+ width: 36px;
225
+ }
226
+ .table td.actions > div {
227
+ display: flex;
228
+ justify-content: center;
229
+ }
230
+ @media only screen and (max-width: 768px) {
231
+ .flex-v {
232
+ width: 100%;
233
+ padding: 0 8px;
234
+ }
235
+ .flex-v.nopad {
236
+ padding: 0;
237
+ }
238
+ }</style>
@@ -0,0 +1,27 @@
1
+ /** @typedef {typeof __propDef.props} UiStyleProps */
2
+ /** @typedef {typeof __propDef.events} UiStyleEvents */
3
+ /** @typedef {typeof __propDef.slots} UiStyleSlots */
4
+ export default class UiStyle extends SvelteComponent<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {
9
+ default: {};
10
+ }> {
11
+ }
12
+ export type UiStyleProps = typeof __propDef.props;
13
+ export type UiStyleEvents = typeof __propDef.events;
14
+ export type UiStyleSlots = typeof __propDef.slots;
15
+ import { SvelteComponent } from "svelte";
16
+ declare const __propDef: {
17
+ props: {
18
+ [x: string]: never;
19
+ };
20
+ events: {
21
+ [evt: string]: CustomEvent<any>;
22
+ };
23
+ slots: {
24
+ default: {};
25
+ };
26
+ };
27
+ export {};
@@ -0,0 +1,20 @@
1
+ <script>export let name;
2
+ export let width = 18;
3
+ export let height = 18;
4
+ export let fill = "currentColor";
5
+ export let icon;
6
+ </script>
7
+
8
+ <svg
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {width}
11
+ {height}
12
+ viewBox="0 0 24 24"
13
+ aria-labelledby={name}
14
+ role="presentation"
15
+ >
16
+ <title id={name} lang="en">{name}</title>
17
+ <g {fill}>
18
+ {@html icon}
19
+ </g>
20
+ </svg>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ name: string | undefined;
5
+ width?: number | undefined;
6
+ height?: number | undefined;
7
+ fill?: string | undefined;
8
+ icon: string;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type IconBaseProps = typeof __propDef.props;
16
+ export type IconBaseEvents = typeof __propDef.events;
17
+ export type IconBaseSlots = typeof __propDef.slots;
18
+ export default class IconBase extends SvelteComponent<IconBaseProps, IconBaseEvents, IconBaseSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,253 @@
1
+ @media screen and (prefers-color-scheme: light) {
2
+ :root {
3
+ --bg: white;
4
+ --fg: black;
5
+ --fgf: #666;
6
+ --highlight: #d79921;
7
+ --link: #458588;
8
+ --hdr: #ccc;
9
+ --hdr-link: #3383a6;
10
+ --field-bg: #ddd;
11
+ --field-label: #3c3836;
12
+ --red1: #9d0006;
13
+ --red2: #cc241d;
14
+ --red3: #fb4934;
15
+ --red4: #fa897d;
16
+ --blue1: #073c78;
17
+ --blue2: #456888;
18
+ --blue3: #8393a5;
19
+ --blue4: #aac0d6;
20
+ --green1: #2c790e;
21
+ --green2: #4c981a;
22
+ --green3: #6ebb26;
23
+ --green4: #92dc51;
24
+ --overlay: #0007;
25
+ --popup-bg: #666;
26
+ --popup-hdr-bg: #777;
27
+ }
28
+
29
+ :root.dark-mode {
30
+ --bg: black;
31
+ --fg: white;
32
+ --fgf: #666;
33
+ --highlight: #d79921;
34
+ --link: #57a7ab;
35
+ --hdr: #333;
36
+ --hdr-link: #1b4557;
37
+ --field-bg: #222;
38
+ --field-label: #8f8681;
39
+ --red4: #9d0006;
40
+ --red3: #cc241d;
41
+ --red2: #fb4934;
42
+ --red1: #fa897d;
43
+ --blue4: #073c78;
44
+ --blue3: #456888;
45
+ --blue2: #8393a5;
46
+ --blue1: #aac0d6;
47
+ --green4: #2c790e;
48
+ --green3: #4c981a;
49
+ --green2: #6ebb26;
50
+ --green1: #92dc51;
51
+ --overlay: #0007;
52
+ --popup-bg: #555;
53
+ --popup-hdr-bg: #666;
54
+ }
55
+ }
56
+
57
+ @media screen and (prefers-color-scheme: dark) {
58
+ :root {
59
+ --bg: black;
60
+ --fg: white;
61
+ --fgf: #666;
62
+ --highlight: #d79921;
63
+ --link: #57a7ab;
64
+ --hdr: #333;
65
+ --hdr-link: #1b4557;
66
+ --field-bg: #222;
67
+ --field-label: #8f8681;
68
+ --red4: #9d0006;
69
+ --red3: #cc241d;
70
+ --red2: #fb4934;
71
+ --red1: #fa897d;
72
+ --blue4: #073c78;
73
+ --blue3: #456888;
74
+ --blue2: #8393a5;
75
+ --blue1: #aac0d6;
76
+ --green4: #2c790e;
77
+ --green3: #4c981a;
78
+ --green2: #6ebb26;
79
+ --green1: #92dc51;
80
+ --overlay: #0007;
81
+ --popup-bg: #555;
82
+ --popup-hdr-bg: #666;
83
+ }
84
+ :root.light-mode {
85
+ --bg: white;
86
+ --fg: black;
87
+ --fgf: #666;
88
+ --highlight: #d79921;
89
+ --link: #458588;
90
+ --hdr: #ccc;
91
+ --hdr-link: #3383a6;
92
+ --field-bg: #ddd;
93
+ --field-label: #3c3836;
94
+ --red1: #9d0006;
95
+ --red2: #cc241d;
96
+ --red3: #fb4934;
97
+ --red4: #fa897d;
98
+ --blue1: #073c78;
99
+ --blue2: #456888;
100
+ --blue3: #8393a5;
101
+ --blue4: #aac0d6;
102
+ --green1: #2c790e;
103
+ --green2: #4c981a;
104
+ --green3: #6ebb26;
105
+ --green4: #92dc51;
106
+ --overlay: #0007;
107
+ --popup-bg: #666;
108
+ --popup-hdr-bg: #777;
109
+ }
110
+ }
111
+
112
+ body {
113
+ font-family: sans-serif;
114
+ margin: 0;
115
+ background-color: var(--bg);
116
+ color: var(--fg);
117
+ }
118
+
119
+ a {
120
+ color: var(--link);
121
+ transition: filter 0.25s;
122
+ }
123
+
124
+ a:visited {
125
+ color: var(--link);
126
+ }
127
+
128
+ a:hover {
129
+ filter: brightness(1.3);
130
+ }
131
+
132
+ .small {
133
+ font-size: 0.75rem;
134
+ color: var(--fgf);
135
+ }
136
+
137
+ .flex-v {
138
+ display: inline-flex;
139
+ flex-direction: column;
140
+ align-items: center;
141
+ }
142
+
143
+ .button {
144
+ color: var(--bg);
145
+ cursor: pointer;
146
+ padding: 6px;
147
+ margin-right: 6px;
148
+ border: 1px solid transparent;
149
+ border-radius: 3px;
150
+ background-color: var(--blue3);
151
+ min-width: 60px;
152
+ transition: filter 0.25s, transform 0.1s;
153
+ }
154
+
155
+ .button:hover {
156
+ filter: brightness(0.8);
157
+ border-color: var(--highlight);
158
+ box-shadow: 0 0 5px var(--highlight);
159
+ }
160
+
161
+ .button:active {
162
+ transform: scale(0.95);
163
+ }
164
+
165
+ .button.red {
166
+ background-color: var(--red3);
167
+ }
168
+
169
+ .button.green {
170
+ background-color: var(--green3);
171
+ }
172
+
173
+ .button.blue {
174
+ background-color: var(--blue3);
175
+ }
176
+
177
+ .buttons-flex-h {
178
+ display: flex;
179
+ }
180
+
181
+ /* popup classes */
182
+ .popup.container {
183
+ display: flex;
184
+ background-color: var(--overlay);
185
+ position: fixed;
186
+ top: 0;
187
+ left: 0;
188
+ right: 0;
189
+ bottom: 0;
190
+ z-index: 2000;
191
+ justify-content: center;
192
+ align-items: center;
193
+ color: var(--bg);
194
+ }
195
+ .popup.main {
196
+ background-color: var(--popup-bg);
197
+ padding-bottom: 6px;
198
+ max-width: 85%;
199
+ }
200
+ .popup.main .header {
201
+ background-color: var(--popup-hdr-bg);
202
+ padding: 8px;
203
+ font-weight: bold;
204
+ }
205
+ .popup.main .item {
206
+ padding-left: 12px;
207
+ padding-right: 12px;
208
+ }
209
+ .popup.main .body {
210
+ padding-top: 12px;
211
+ padding-bottom: 12px;
212
+ }
213
+ .table {
214
+ text-align: left;
215
+ border: 1px solid var(--fg);
216
+ border-spacing: 0;
217
+ border-collapse: collapse;
218
+ margin: 10px auto;
219
+ }
220
+ .table th,
221
+ .table td {
222
+ border: 1px solid var(--fg);
223
+ padding: 2px 4px;
224
+ }
225
+ .table th {
226
+ background-color: var(--blue3);
227
+ color: var(--bg);
228
+ }
229
+ .table td.center {
230
+ text-align: center;
231
+ }
232
+ .table td.name,
233
+ .table th.name {
234
+ width: 10rem;
235
+ }
236
+ .table td.actions,
237
+ .table th.actions {
238
+ width: 36px;
239
+ }
240
+ .table td.actions > div {
241
+ display: flex;
242
+ justify-content: center;
243
+ }
244
+
245
+ @media only screen and (max-width: 768px) {
246
+ .flex-v {
247
+ width: 100%;
248
+ padding: 0 8px;
249
+ }
250
+ .flex-v.nopad {
251
+ padding: 0;
252
+ }
253
+ }
File without changes
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ // Reexport your entry components here
@@ -0,0 +1 @@
1
+ export { toastList } from './toast-list.js';
@@ -0,0 +1 @@
1
+ export { toastList } from './toast-list.js';
@@ -0,0 +1,18 @@
1
+ /// <reference types="svelte" />
2
+ export interface ToastBase {
3
+ text: string;
4
+ type: 'normal' | 'error' | 'success';
5
+ }
6
+ export interface Toast extends ToastBase {
7
+ id: number;
8
+ }
9
+ export interface ToastListStore {
10
+ toasts: Toast[];
11
+ }
12
+ export declare const toastList: {
13
+ subscribe: (this: void, run: import("svelte/store").Subscriber<ToastListStore>, invalidate?: import("svelte/store").Invalidator<ToastListStore> | undefined) => import("svelte/store").Unsubscriber;
14
+ addText: (text: string) => void;
15
+ addError: (text: string) => void;
16
+ addSuccess: (text: string) => void;
17
+ remove: (id: number) => void;
18
+ };
@@ -0,0 +1,19 @@
1
+ import { writable } from 'svelte/store';
2
+ let lastId = 0;
3
+ function createStore() {
4
+ const defaultState = { toasts: [] };
5
+ const { subscribe, update } = writable(defaultState);
6
+ const add = (toast) => update((u) => ({ toasts: [...u.toasts, { ...toast, id: lastId++ }] }));
7
+ return {
8
+ subscribe,
9
+ addText: (text) => add({ text, type: 'normal' }),
10
+ addError: (text) => add({ text, type: 'error' }),
11
+ addSuccess: (text) => add({ text, type: 'success' }),
12
+ remove: (id) => update((u) => {
13
+ const idx = u.toasts.findIndex((t) => t.id === id);
14
+ u.toasts.splice(idx, 1);
15
+ return { toasts: u.toasts };
16
+ }),
17
+ };
18
+ }
19
+ export const toastList = createStore();
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "smorks-svelte-ui",
3
+ "version": "0.0.1-alpha.1",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "svelte": "./dist/index.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "!dist/**/*.test.*",
14
+ "!dist/**/*.spec.*"
15
+ ],
16
+ "dependencies": {
17
+ "normalize.css": "^8.0.1"
18
+ },
19
+ "peerDependencies": {
20
+ "svelte": "^4.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@sveltejs/adapter-auto": "^2.1.0",
24
+ "@sveltejs/kit": "^1.22.5",
25
+ "@sveltejs/package": "^2.2.1",
26
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
27
+ "@typescript-eslint/parser": "^5.62.0",
28
+ "@types/sass-loader": "^8.0.5",
29
+ "eslint": "^8.46.0",
30
+ "eslint-config-prettier": "^8.10.0",
31
+ "eslint-plugin-svelte": "^2.32.4",
32
+ "prettier": "^2.8.8",
33
+ "prettier-plugin-svelte": "^2.10.1",
34
+ "publint": "^0.1.16",
35
+ "sass": "^1.65.1",
36
+ "svelte": "^4.1.2",
37
+ "svelte-check": "^3.4.6",
38
+ "tslib": "^2.6.1",
39
+ "typescript": "^5.1.6",
40
+ "vite": "^4.4.9"
41
+ },
42
+ "svelte": "./dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "type": "module",
45
+ "scripts": {
46
+ "dev": "vite dev",
47
+ "build": "vite build && npm run package",
48
+ "preview": "vite preview",
49
+ "package": "svelte-kit sync && svelte-package && publint",
50
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
51
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
52
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
53
+ "format": "prettier --plugin-search-dir . --write ."
54
+ }
55
+ }