@axel669/zephyr 0.1.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/LICENSE +21 -0
- package/package.json +32 -0
- package/readme.md +44 -0
- package/src/avatar.svelte +54 -0
- package/src/badge.svelte +40 -0
- package/src/button.svelte +80 -0
- package/src/chip.svelte +53 -0
- package/src/composed/data-table.svelte +150 -0
- package/src/composed/entry-button.svelte +66 -0
- package/src/composed/toast/message.svelte +44 -0
- package/src/composed/toast.svelte +108 -0
- package/src/dialog.svelte +53 -0
- package/src/drawer.svelte +121 -0
- package/src/flex.svelte +57 -0
- package/src/grid.svelte +66 -0
- package/src/handler$.mjs +68 -0
- package/src/icon.svelte +34 -0
- package/src/index.mjs +85 -0
- package/src/inline-dialog.svelte +23 -0
- package/src/input/area.svelte +97 -0
- package/src/input/elems.mjs +7 -0
- package/src/input/email.svelte +102 -0
- package/src/input/file.svelte +81 -0
- package/src/input/number.svelte +102 -0
- package/src/input/password.svelte +99 -0
- package/src/input/search.svelte +102 -0
- package/src/input/text.svelte +102 -0
- package/src/link.svelte +62 -0
- package/src/modal.svelte +68 -0
- package/src/notification.svelte +57 -0
- package/src/paper.svelte +114 -0
- package/src/popover.svelte +60 -0
- package/src/progress.svelte +60 -0
- package/src/radio.svelte +82 -0
- package/src/screen.svelte +69 -0
- package/src/select.svelte +121 -0
- package/src/table.svelte +69 -0
- package/src/tabs.svelte +77 -0
- package/src/text.svelte +49 -0
- package/src/titlebar.svelte +69 -0
- package/src/toaster.svelte +42 -0
- package/src/toggle.svelte +90 -0
- package/src/tooltip.svelte +45 -0
- package/src/vars.mjs +61 -0
- package/src/wsx.mjs +45 -0
package/src/tabs.svelte
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Tabs
|
|
4
|
+
|
|
5
|
+
# Tabs
|
|
6
|
+
|
|
7
|
+
It's tabs, everyone knows what tabs are at this point.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Tabs](https://axel669.github.io/lib.windstorm/#components-tabs)
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
+
are supported.
|
|
15
|
+
|
|
16
|
+
- ### color `string`
|
|
17
|
+
Sets `$color`
|
|
18
|
+
- ### options `Array[Object]`
|
|
19
|
+
An array of options where each item is `{ label, value }`. `label`
|
|
20
|
+
should be a string, `value` can be of any type.
|
|
21
|
+
- ### vertical `bool`
|
|
22
|
+
Sets `$vert`
|
|
23
|
+
- ### solid `bool`
|
|
24
|
+
Sets `$solid`
|
|
25
|
+
- ### value `any`
|
|
26
|
+
The value of the currently selected tab. Can be bound to react to
|
|
27
|
+
changes and set to control which tab is selected.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
```js
|
|
31
|
+
const options = [
|
|
32
|
+
{ label: "Left", value: "left" },
|
|
33
|
+
{ label: "Right", value: 2 },
|
|
34
|
+
]
|
|
35
|
+
```
|
|
36
|
+
```svelte
|
|
37
|
+
<Tab {options} bind:value color="primary" />
|
|
38
|
+
<Tab {options} bind:value color="secondary" solid vertical />
|
|
39
|
+
```
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
import wsx from "./wsx.mjs"
|
|
43
|
+
import { handler$ } from "./handler$.mjs"
|
|
44
|
+
|
|
45
|
+
export let color = "primary"
|
|
46
|
+
export let options = []
|
|
47
|
+
export let vertical = false
|
|
48
|
+
export let solid = false
|
|
49
|
+
export let value
|
|
50
|
+
|
|
51
|
+
$: index = options.findIndex(item => item.value === value)
|
|
52
|
+
|
|
53
|
+
const set = handler$(
|
|
54
|
+
(next) => {
|
|
55
|
+
if (value === next) {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
value = next
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
$: wind = {
|
|
63
|
+
"@solid": solid,
|
|
64
|
+
$color: color,
|
|
65
|
+
$vert: vertical,
|
|
66
|
+
...$$restProps,
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
71
|
+
<ws-tabs use:wsx={wind}>
|
|
72
|
+
{#each options as tab, i}
|
|
73
|
+
<ws-tab tab-selected={index === i || null} on:click={set(tab.value)}>
|
|
74
|
+
{tab.label}
|
|
75
|
+
</ws-tab>
|
|
76
|
+
{/each}
|
|
77
|
+
</ws-tabs>
|
package/src/text.svelte
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Text
|
|
4
|
+
|
|
5
|
+
# Text
|
|
6
|
+
|
|
7
|
+
Simple component with some common props for types of text.
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
11
|
+
are supported.
|
|
12
|
+
|
|
13
|
+
- ### adorn `bool`
|
|
14
|
+
Sets `$adorn`
|
|
15
|
+
- ### block `bool`
|
|
16
|
+
Sets `block`
|
|
17
|
+
- ### subtitle `bool`
|
|
18
|
+
Sets `$subtitle`
|
|
19
|
+
- ### title `bool`
|
|
20
|
+
Sets `$title`
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
```svelte
|
|
24
|
+
<Text>Some text</Text>
|
|
25
|
+
<Text title>Bigger text</Text>
|
|
26
|
+
<Text subtitle>Smaller text</Text>
|
|
27
|
+
<Text block>Text on its own line</Text>
|
|
28
|
+
```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import wsx from "./wsx.mjs"
|
|
32
|
+
|
|
33
|
+
export let title = false
|
|
34
|
+
export let subtitle = false
|
|
35
|
+
export let block = false
|
|
36
|
+
export let adorn = false
|
|
37
|
+
|
|
38
|
+
$: wind = {
|
|
39
|
+
"$title": title,
|
|
40
|
+
"$subtitle": subtitle,
|
|
41
|
+
"$adorn": adorn,
|
|
42
|
+
block,
|
|
43
|
+
...$$restProps
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<span use:wsx={wind}>
|
|
48
|
+
<slot />
|
|
49
|
+
</span>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Titlebar
|
|
4
|
+
|
|
5
|
+
# Titlebar
|
|
6
|
+
|
|
7
|
+
The titlebar is used to set section titles with some style, and provides
|
|
8
|
+
slots for buttons on either side of the title text. Works well as a header
|
|
9
|
+
for Paper components.
|
|
10
|
+
|
|
11
|
+
## Base
|
|
12
|
+
[Windstorm Titlebar](https://axel669.github.io/lib.windstorm/#components-titlebar)
|
|
13
|
+
|
|
14
|
+
## Props
|
|
15
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
16
|
+
are supported.
|
|
17
|
+
|
|
18
|
+
- ### color `string`
|
|
19
|
+
Sets `$color`
|
|
20
|
+
- ### fill `bool`
|
|
21
|
+
Sets `@fill`
|
|
22
|
+
|
|
23
|
+
## Slots
|
|
24
|
+
- title\\
|
|
25
|
+
The center of the titlebar, where the text usually goes
|
|
26
|
+
- menu\\
|
|
27
|
+
The area on the left of the titlebar (where drawer menus tend to open)
|
|
28
|
+
- action\\
|
|
29
|
+
The area on the right of the titlebar
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
```svelte
|
|
33
|
+
<Titlebar color="primary" fill>
|
|
34
|
+
<Text title slot="title">
|
|
35
|
+
Some Title
|
|
36
|
+
</Text>
|
|
37
|
+
|
|
38
|
+
<Button slot="menu" color={false}>
|
|
39
|
+
<Icon name="menu" />
|
|
40
|
+
</Button>
|
|
41
|
+
</Titlebar>
|
|
42
|
+
|
|
43
|
+
<Paper>
|
|
44
|
+
<Titlebar color="secondary" slot="header">
|
|
45
|
+
<Text title slot="title">
|
|
46
|
+
Paper Title
|
|
47
|
+
</Text>
|
|
48
|
+
</Titlebar>
|
|
49
|
+
</Paper>
|
|
50
|
+
```
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
import wsx from "./wsx.mjs"
|
|
54
|
+
|
|
55
|
+
export let color
|
|
56
|
+
export let fill = false
|
|
57
|
+
|
|
58
|
+
$: wind = {
|
|
59
|
+
$color: color,
|
|
60
|
+
"@fill": fill,
|
|
61
|
+
...$$restProps
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<ws-titlebar use:wsx={wind}>
|
|
66
|
+
<slot name="menu" />
|
|
67
|
+
<slot name="title" />
|
|
68
|
+
<slot name="action" />
|
|
69
|
+
</ws-titlebar>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Containers/Toaster
|
|
4
|
+
|
|
5
|
+
# Toaster
|
|
6
|
+
|
|
7
|
+
The Toaster component is used for building popup notifications along the
|
|
8
|
+
edges of the window.
|
|
9
|
+
|
|
10
|
+
## Base
|
|
11
|
+
[Windstorm Toaster](https://axel669.github.io/lib.windstorm/#components-toaster)
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
+
are supported, but probably not very meaningful for this container.
|
|
16
|
+
|
|
17
|
+
- ### position
|
|
18
|
+
Sets position of the toaster. See the windstorm base for values.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
<Toaster position="$tc">
|
|
22
|
+
<Notification>
|
|
23
|
+
<Icon name="info">
|
|
24
|
+
Some kind of notification of things
|
|
25
|
+
</Icon>
|
|
26
|
+
</Notification>
|
|
27
|
+
</Toaster>
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import wsx from "./wsx.mjs"
|
|
31
|
+
|
|
32
|
+
export let position = "tc"
|
|
33
|
+
|
|
34
|
+
$: wind = {
|
|
35
|
+
[`$${position}`]: true,
|
|
36
|
+
...$$restProps,
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<ws-toaster use:wsx={wind}>
|
|
41
|
+
<slot />
|
|
42
|
+
</ws-toaster>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Input/Toggle
|
|
4
|
+
|
|
5
|
+
# Toggle
|
|
6
|
+
|
|
7
|
+
The Toggle component is used to display checkboxes and switches.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Labeled Toggle](https://axel669.github.io/lib.windstorm/#components-labeled-toggle)
|
|
11
|
+
using a checkbox input
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
+
are supported.
|
|
16
|
+
|
|
17
|
+
- ### color `string`
|
|
18
|
+
Sets `$color`
|
|
19
|
+
- ### checkbox `bool`
|
|
20
|
+
If true, the toggle is displayed as a checkbox. Default is false
|
|
21
|
+
(shown as a switch)
|
|
22
|
+
- ### checked `bool`
|
|
23
|
+
Controls if the toggle is checked or not. Can be bound
|
|
24
|
+
- ### group
|
|
25
|
+
Used for binding, see the Svelte bind:group for details
|
|
26
|
+
- ### label `string`
|
|
27
|
+
The text to use for the label
|
|
28
|
+
- ### outline `bool`
|
|
29
|
+
Sets `$outline`
|
|
30
|
+
- ### reverse `bool`
|
|
31
|
+
If true, the input being toggled will be on the left instead of the
|
|
32
|
+
right. Default is false (label is on the left)
|
|
33
|
+
- ### value
|
|
34
|
+
Only used in conjunction with bind:group, see Svelte docs
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
```svelte
|
|
38
|
+
<Toggle label="Active" bind:checked />
|
|
39
|
+
<Toggle label="Active" checkbox bind:checked />
|
|
40
|
+
<Toggle label="Active" checkbox reverse bind:checked />
|
|
41
|
+
<Toggle label="Active" checkbox outline color="danger" bind:checked />
|
|
42
|
+
```
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
import wsx from "./wsx.mjs"
|
|
46
|
+
|
|
47
|
+
export let label = ""
|
|
48
|
+
export let color = "default"
|
|
49
|
+
export let checked = false
|
|
50
|
+
export let outline = false
|
|
51
|
+
export let value
|
|
52
|
+
export let group = []
|
|
53
|
+
export let checkbox = false
|
|
54
|
+
export let reverse = false
|
|
55
|
+
|
|
56
|
+
$: container = {
|
|
57
|
+
"@toggle": true,
|
|
58
|
+
"@outline": outline,
|
|
59
|
+
$color: color,
|
|
60
|
+
...$$restProps,
|
|
61
|
+
}
|
|
62
|
+
$: input = {
|
|
63
|
+
"$switch": checkbox === false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const updateGroup = (checked) => {
|
|
67
|
+
if (checked === true) {
|
|
68
|
+
if (group.includes(value) === true) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
group = [...group, value]
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
if (group.includes(value) === false) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
group = group.filter(item => item !== value)
|
|
78
|
+
}
|
|
79
|
+
$: updateGroup(checked)
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<label use:wsx={container}>
|
|
83
|
+
{#if reverse !== true}
|
|
84
|
+
<span>{label}</span>
|
|
85
|
+
{/if}
|
|
86
|
+
<input type="checkbox" bind:checked use:wsx={input} />
|
|
87
|
+
{#if reverse === true}
|
|
88
|
+
<span>{label}</span>
|
|
89
|
+
{/if}
|
|
90
|
+
</label>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Data Display/Tooltip
|
|
4
|
+
|
|
5
|
+
# Tooltip
|
|
6
|
+
|
|
7
|
+
Displays a tooltip above (or below) some content when it's hovered.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Tooltip](https://axel669.github.io/lib.windstorm/#components-tooltip)
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
+
are supported.
|
|
15
|
+
|
|
16
|
+
- ### text `string`
|
|
17
|
+
The text to display in the tooltip.
|
|
18
|
+
- ### bottom `bool`
|
|
19
|
+
If true, the tooltip will be shown under the content instead of over.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
```svelte
|
|
23
|
+
<Tooltip text="This is a button">
|
|
24
|
+
<Button>Do Thing</Button>
|
|
25
|
+
</Tooltip>
|
|
26
|
+
<Tooltip text="This shows under" bottom>
|
|
27
|
+
Just some text content
|
|
28
|
+
</Tooltip>
|
|
29
|
+
```
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import wsx from "./wsx.mjs"
|
|
33
|
+
|
|
34
|
+
export let text = ""
|
|
35
|
+
export let bottom = false
|
|
36
|
+
|
|
37
|
+
$: wind = {
|
|
38
|
+
$bottom: bottom,
|
|
39
|
+
...$$restProps,
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<ws-tooltip ws-text={text} use:wsx={wind}>
|
|
44
|
+
<slot />
|
|
45
|
+
</ws-tooltip>
|
package/src/vars.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*md
|
|
2
|
+
[@] Actions/vars
|
|
3
|
+
|
|
4
|
+
# vars Action
|
|
5
|
+
|
|
6
|
+
The vars action is used to set css variables on dom elements using a simple
|
|
7
|
+
object to maintain the values instead of needing to do string interpolation and
|
|
8
|
+
falsey checks manually.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
```js
|
|
12
|
+
// Sets --screen-widt to 100% and unsets --other-thing
|
|
13
|
+
$: settings = {
|
|
14
|
+
"screen-width": "100%",
|
|
15
|
+
"other-thing": null,
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
```svelte
|
|
19
|
+
<ws-screen use:vars={settings}>
|
|
20
|
+
</ws-screen>
|
|
21
|
+
```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const calcValue = value => {
|
|
25
|
+
if (Array.isArray(value) === false) {
|
|
26
|
+
return value
|
|
27
|
+
}
|
|
28
|
+
if (value[0] === null || value[0] === undefined) {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
return value.join("")
|
|
32
|
+
}
|
|
33
|
+
const udpateVars = (node, current, next) => {
|
|
34
|
+
const keys = new Set([
|
|
35
|
+
...Object.keys(current),
|
|
36
|
+
...Object.keys(next),
|
|
37
|
+
])
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const varName = `--${key}`
|
|
40
|
+
const currentValue = calcValue(current[key])
|
|
41
|
+
const nextValue = calcValue(next[key])
|
|
42
|
+
if (nextValue === undefined || nextValue === null) {
|
|
43
|
+
node.style.removeProperty(varName)
|
|
44
|
+
}
|
|
45
|
+
if (currentValue !== nextValue) {
|
|
46
|
+
node.style.setProperty(varName, nextValue)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const vars = (node, vars) => {
|
|
51
|
+
let currentVars = vars
|
|
52
|
+
udpateVars(node, {}, currentVars)
|
|
53
|
+
return {
|
|
54
|
+
update(newVars) {
|
|
55
|
+
udpateVars(node, currentVars, newVars)
|
|
56
|
+
currentVars = newVars
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default vars
|
package/src/wsx.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import wind from "@axel669/windstorm"
|
|
2
|
+
const { wsx } = wind
|
|
3
|
+
|
|
4
|
+
/*md
|
|
5
|
+
[@] Actions/wsx
|
|
6
|
+
|
|
7
|
+
# wsx Action
|
|
8
|
+
|
|
9
|
+
The wsx action can be used to set the `ws-x` attribute on a DOM element by using
|
|
10
|
+
an object as the source rather than trying to do the string manipulation
|
|
11
|
+
directly.
|
|
12
|
+
- `null`, `undefined`, and `false` will not insert the wind function
|
|
13
|
+
- `true` will insert the wind function with no args
|
|
14
|
+
- any string value will insert the wind function with the arguments formatted
|
|
15
|
+
for the parser (replace spaces and underscores as needed).
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
```js
|
|
19
|
+
// will generate ws-x="grid gr-col[1fr_1fr]"
|
|
20
|
+
$: windStff = {
|
|
21
|
+
grid: true,
|
|
22
|
+
gr-col: "1fr 1fr",
|
|
23
|
+
p: false
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
```svelte
|
|
27
|
+
<div use:wsx={windStuff}>
|
|
28
|
+
</div>
|
|
29
|
+
```
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export default (node, props) => {
|
|
33
|
+
const update = (props) => {
|
|
34
|
+
if (props === null || props === undefined) {
|
|
35
|
+
node.setAttribute("ws-x", null)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
node.setAttribute(
|
|
39
|
+
"ws-x",
|
|
40
|
+
wsx(props)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
update(props)
|
|
44
|
+
return { update }
|
|
45
|
+
}
|