@axel669/zephyr 0.2.0-beta.0 → 0.2.0-beta.2

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.
Files changed (42) hide show
  1. package/package.json +3 -4
  2. package/readme.md +23 -15
  3. package/src/async/button.svelte +31 -0
  4. package/src/async/load-zone.svelte +17 -0
  5. package/src/composed/data-table.md +19 -5
  6. package/src/composed/entry-button.md +1 -1
  7. package/src/composed/toast/message.svelte +16 -4
  8. package/src/composed/toast.md +1 -1
  9. package/src/control/button.md +6 -2
  10. package/src/control/label.md +49 -0
  11. package/src/control/link.md +24 -11
  12. package/src/control/link.svelte +1 -1
  13. package/src/control/radio.md +32 -23
  14. package/src/control/radio.svelte +1 -3
  15. package/src/control/select.md +41 -26
  16. package/src/control/tabs.md +38 -26
  17. package/src/control/toggle.md +50 -27
  18. package/src/data-display/avatar.md +24 -14
  19. package/src/data-display/badge.md +17 -11
  20. package/src/data-display/chip.md +19 -11
  21. package/src/data-display/details.md +3 -0
  22. package/src/data-display/popover.md +10 -10
  23. package/src/data-display/progress.md +37 -21
  24. package/src/data-display/table.md +4 -26
  25. package/src/data-display/tooltip.md +14 -10
  26. package/src/dialogs/alert.md +3 -0
  27. package/src/dialogs/confirm.md +3 -0
  28. package/src/functions.md +9 -3
  29. package/src/index.mjs +4 -7
  30. package/src/info/icon.md +9 -8
  31. package/src/info/notification.md +7 -8
  32. package/src/info/titlebar.md +47 -18
  33. package/src/info/toaster.md +11 -8
  34. package/src/layout/dialog.md +12 -2
  35. package/src/layout/drawer.md +40 -17
  36. package/src/layout/flex.md +31 -18
  37. package/src/layout/grid.md +44 -19
  38. package/src/layout/modal.md +21 -6
  39. package/src/layout/paper.md +51 -34
  40. package/src/layout/screen.md +11 -9
  41. package/src/spinner/spinners.md +3 -0
  42. package/src/text.md +22 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axel669/zephyr",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "",
5
5
  "main": "src/index.mjs",
6
6
  "type": "module",
@@ -12,11 +12,10 @@
12
12
  "author": "",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@axel669/windstorm": "0.2.3",
16
- "@labyrinthos/asuid": "^0.2.0"
15
+ "@axel669/windstorm": "0.2.3"
17
16
  },
18
17
  "devDependencies": {
19
- "@axel669/ipsen": "0.4.0-beta.3",
18
+ "@axel669/ipsen": "0.4.0-beta.7",
20
19
  "@axel669/rollup-html-input": "^0.1.2",
21
20
  "@rollup/plugin-node-resolve": "^15.0.2",
22
21
  "@rollup/plugin-terser": "^0.4.0",
package/readme.md CHANGED
@@ -1,7 +1,3 @@
1
- NOTE: add docs for dumbass svelte browser resolve bullshit
2
- https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers
3
- - form controls?
4
-
5
1
  # Zephyr
6
2
  Zephyr is a svelte binding for the [Windstorm](https://windstorm.axel669.net)
7
3
  library, with some additional parts to make it look nice in the markup.
@@ -12,44 +8,56 @@ library, with some additional parts to make it look nice in the markup.
12
8
  Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
13
9
 
14
10
  ```bash
15
- npm install @axel669/zephyr
11
+ npm install @axel669/zephyr@0.2.0-beta.1
16
12
  ```
17
13
 
18
- ## Usage
14
+ ## Components
19
15
  Components can be imported individually from the library for tree-shaking, or
20
16
  the entire lib can imported at once, but I dunno how big that bundle will be.
21
17
  Components can also take any windstorm function as a prop, using the same rules
22
18
  as the `wsx` action.
23
19
 
24
- > Windstorm expects a theme to be defined on an ancestor of the html elements
25
- > that use it, and Zephyr does not automatically set the theme because it can
26
- > used anywhere in the page. This means the wsx action (or setting the ws-x
27
- > attribute directly) will be needed for components to look right.
20
+ ### Theming
21
+ Windstorm expects a theme to be defined on an ancestor of the html elements
22
+ that use it, and Zephyr does not automatically set the theme because it can
23
+ used anywhere in the page. This means the wsx action (or setting the ws-x
24
+ attribute directly) will be needed for components to look right. Any valid
25
+ Windstorm theme is usable, including custom ones.
28
26
 
27
+ ### Example
29
28
  ```svelte
30
29
  <script>
31
30
  // individual import for tree shaking
32
- import { Button } from "@axel669/zephyr"
31
+ import {
32
+ Button,
33
+ wsx
34
+ } from "@axel669/zephyr"
33
35
 
34
36
  // bring the whole thing to keep it simple
35
37
  import * as Wind from "@axel669/zephyr"
38
+
39
+ const theme = "dark"
40
+ const handler = () => {
41
+ console.log("button clicked!")
42
+ }
36
43
  </script>
37
44
 
38
45
  <!-- the wsx action can be used to setup the ws-x needed for the body -->
39
46
  <svelte:body use:wsx={{"$theme": theme, "$app": true}} />
40
47
 
41
- <Button on:click={stuff}>
48
+ <Button on:click={handler}>
42
49
  I'm a button!
43
50
  </Button>
44
51
 
45
- <Wind.Button on:click={stuff}>
52
+ <Wind.Button on:click={handler}>
46
53
  I'm also button!
47
54
  </Wind.Button>
48
55
  ```
49
56
 
50
- ### Svelte Config
57
+ ## Svelte Config
51
58
  Zephyr does not output any css of its own, so no configuration is required to
52
59
  make it styled as expected. For people using Svelte 4+ you will need to make
53
60
  sure your bundler has the browser conditions set as some components do use
54
61
  lifecycle functions that will not be bundled without the setting.
55
- [Details](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
62
+ [Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
63
+ about the setting.
@@ -0,0 +1,31 @@
1
+ <script>
2
+ import Button from "../control/button.svelte"
3
+ import Spinner from "../spinner/circle-spinner.svelte"
4
+
5
+ export let handler = null
6
+ export let disabled
7
+ export let inactiveProps = null
8
+
9
+ let running = false
10
+ const asyncHandler = async (evt) => {
11
+ running = true
12
+ await handler(evt)
13
+ running = false
14
+ }
15
+
16
+ $: inactive = (typeof disabled === "boolean") ? disabled : running
17
+ $: props = {
18
+ ...$$restProps,
19
+ ...(running === false ? null : inactiveProps),
20
+ disabled: inactive,
21
+ }
22
+ </script>
23
+
24
+ <Button {...props} on:click={asyncHandler}>
25
+ <div ws-x="h[20px] m.r:not(:empty)[4px]">
26
+ {#if running === true}
27
+ <Spinner size="20px" />
28
+ {/if}
29
+ </div>
30
+ <slot />
31
+ </Button>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import Spinner from "../spinner/hexagon-spinner.svelte"
3
+ export let source = null
4
+ </script>
5
+
6
+ {#if source !== null}
7
+ {#await source}
8
+ <slot name="loading">
9
+ <ws-flex ws-x="fl.cross[center] fl.main[center]">
10
+ <span>Loading</span>
11
+ <Spinner size="100px" />
12
+ </ws-flex>
13
+ </slot>
14
+ {:then result}
15
+ <slot {result} />
16
+ {/await}
17
+ {/if}
@@ -1,3 +1,5 @@
1
+ NOTE: include Th as its own component
2
+
1
3
  # DataTable
2
4
 
3
5
  The DataTable is a more advanced way to show data on screen. Underneath is
@@ -14,21 +16,33 @@ are supported.
14
16
 
15
17
  - ### color
16
18
  Sets `$color`
17
- - ### cols `Array`
19
+
20
+ ### cols
21
+ `Array`
22
+
18
23
  The columns that should be displayed. Should be in the format of
19
24
  `{ label, width?, format?, prop? }`. If a format function is provided,
20
25
  it is called on each cell to determine a cells value as
21
26
  `format(rowItem)`, otherwise the property defined in prop will be used
22
27
  as the cell value.
23
- - ### data `Array`
28
+
29
+ ### data
30
+ `Array`
31
+
24
32
  The data to display. Each item in the array can be in either the same
25
33
  format as the Table, or any kind of object if column format functions
26
34
  are used.
27
- - ### cellWSX `function`
35
+
36
+ ### cellWSX
37
+ `function`
38
+
28
39
  If given, this function will be called for each cell, and should return
29
40
  an object that will be passed to the `wsx` action for each <td>
30
41
  generated. The function is passed `(rowvalue, rowNum, col)`.
31
- - ### rowWSX `function`
42
+
43
+ ### rowWSX
44
+ `function`
45
+
32
46
  If given, this function will be called for each row, and should return
33
47
  an object that will be passed to the `wsx` action for each <tr>
34
48
  generated. The function is passed `(rowValue, rowNum)`.
@@ -42,7 +56,7 @@ are supported.
42
56
  that may lead to a degraded user experience if the rows change size
43
57
  while paging through the data
44
58
 
45
- ## Usage
59
+ ## Example
46
60
  ```js
47
61
  let page
48
62
  const cols = [
@@ -20,7 +20,7 @@ addition to the buttons that show them.
20
20
  When the component is close the entry event is fired. The detail
21
21
  property of the event will have the value from closing it
22
22
 
23
- ## Usage
23
+ ## Example
24
24
  ```svelte
25
25
  <EntryButton component={Subscreen} on:entry={console.log}>
26
26
  Open Subscreen
@@ -7,14 +7,26 @@
7
7
  The default component for Toast to show messages with
8
8
 
9
9
  ## Props
10
- - ### actionText `string`
10
+
11
+ ### actionText
12
+ `string`
13
+
11
14
  If given, the message will have a button that can be clicked and will
12
15
  use this text for the button text
13
- - ### color `string`
16
+
17
+ ### color
18
+ `string`
19
+
14
20
  Sets `$color`
15
- - ### icon `string`
21
+
22
+ ### icon
23
+ `string`
24
+
16
25
  An icon to show with the message
17
- - ### message `string`
26
+
27
+ ### message
28
+ `string`
29
+
18
30
  The message to show
19
31
  */
20
32
 
@@ -26,7 +26,7 @@ also controls the children being shown for convenience.
26
26
  actions to be taken against interactions in the message without having
27
27
  to bind all kinds of events or callbacks.
28
28
 
29
- ## Usage
29
+ ## Example
30
30
  ```js
31
31
  let toast = null
32
32
  const notify = () => toast.show(5000, { message: "hi" })
@@ -17,14 +17,18 @@ Sets `$compact`
17
17
  ### fill / outline
18
18
  `bool`
19
19
 
20
- Sets the button type to $fill if fill is true, $outline if outline
21
- is true, or $flat if neither is true.
20
+ Sets the button type to `$fill` if fill is true, `$outline` if outline
21
+ is true, or `$flat` if neither is true.
22
22
 
23
23
  ## Events
24
24
  - click
25
25
 
26
26
  ## Example
27
27
  ```svelte
28
+ <script>
29
+ import { Button } from "@axel669/zephyr"
30
+ </script>
31
+
28
32
  <Button on:click={action}>
29
33
  Flat Button
30
34
  </Button>
@@ -0,0 +1,49 @@
1
+ # Label
2
+
3
+ The label component is a wrapper around a `<label>` element.
4
+
5
+ ## Props
6
+
7
+ ### button
8
+ `bool`
9
+
10
+ If true, the label will have the button appearance.
11
+
12
+ ### color
13
+ `string`
14
+
15
+ Sets `$color`
16
+
17
+ ### compact
18
+ `bool`
19
+
20
+ If true, will make the label button be more compact. No effect is `button` is
21
+ `false`.
22
+
23
+ ### disabled
24
+ `bool`
25
+
26
+ Disables the label.
27
+
28
+ ### fill / outline / flat
29
+ `bool`
30
+
31
+ Sets the button variant of the label when `button` is `true`.
32
+
33
+ ### for
34
+ `string`
35
+
36
+ [Label for attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#for)
37
+
38
+ ## Example
39
+
40
+ ```svelte
41
+ <script>
42
+ import { Label } from "@axel669/zephyr"
43
+ </script>
44
+
45
+ <Label for="checkbox">Toggle Checkbox</Label>
46
+ <Label for="checkbox" button color="primary" fill>
47
+ Open Menu
48
+ </Label>
49
+ ```
@@ -8,26 +8,39 @@ Themed and customizale `<a>` tag component.
8
8
 
9
9
  If true, the link will be styled like a button
10
10
 
11
- ### color `string`
11
+ ### color
12
+ `string`
12
13
 
13
14
  Sets the color of the button. Applies to both regular links and button
14
15
  style links.
15
16
 
16
- - ### href `string`
17
- Sets the href attribute.
17
+ ### href
18
+ `string`
18
19
 
19
- - ### rel `string`
20
- Sets the rel attribute.
20
+ Sets the href attribute.
21
21
 
22
- - ### target `string`
23
- Sets the target attribute.
22
+ ### rel
23
+ `string`
24
24
 
25
- - ### fill / outline `bool`
26
- Sets the link-button type to $fill if fill is true, $outline if outline
27
- is true, or $flat if neither is true.
25
+ Sets the rel attribute.
28
26
 
29
- ## Usage
27
+ ### target
28
+ `string`
29
+
30
+ Sets the target attribute.
31
+
32
+ ### fill / outline / flat
33
+ `bool`
34
+
35
+ Sets the link-button type to `$fill` if fill is true, `$outline` if outline
36
+ is true, or `$flat` if neither is true.
37
+
38
+ ## Example
30
39
  ```svelte
40
+ <script>
41
+ import { Link } from "@axel669/zephyr"
42
+ </script>
43
+
31
44
  <Link color="primary" href="test" target="_blank">
32
45
  Test
33
46
  </Link>
@@ -16,7 +16,7 @@
16
16
  $: type = variant({ fill, outline, flat })
17
17
 
18
18
  $: wind = {
19
- "@button": button,
19
+ "$button": button,
20
20
  [type]: true,
21
21
  "$color": color,
22
22
  ...$$restProps
@@ -7,24 +7,31 @@ are presented.
7
7
 
8
8
  ## Base
9
9
  Each radio item rendered is a
10
- [Windstorm Labeled Toggle](https://axel669.github.io/lib.windstorm/#components-labeled toggle)
10
+ [Windstorm Labeled Toggle](https://windstorm.axel669.net/lib/css/component/toggle)
11
11
  that uses a radio input.
12
12
 
13
13
  ## Props
14
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
15
- are supported.
16
14
 
17
- Unlike the Paper, the wind functions passed as props to the Radio component
18
- are passed directly to the layout specified because the Radio does not have
19
- a container element of its own.
15
+ The wind functions passed as props to the Radio component are passed directly to
16
+ the layout specified because the Radio does not have a container element of its
17
+ own.
20
18
 
21
- - ### layout `Component`
22
- The component to use for layout out the options. Default is Flex.
23
- - ### options `Array[Object]`
24
- An array of objects that defines the options to show. Details below.
25
- - ### value `any`
26
- The value currently selected. Can be bound to react to selections or
27
- change the current selection.
19
+ ### layout
20
+ `Component`
21
+
22
+ The component to use for layout out the options. Default is
23
+ [Flex](../layout/flex.md).
24
+
25
+ ### options
26
+ `Array[Object]`
27
+
28
+ An array of objects that defines the options to show. Details below.
29
+
30
+ ### value
31
+ `any`
32
+
33
+ The value currently selected. Can be bound to react to selections or change the
34
+ current selection.
28
35
 
29
36
  ## Options
30
37
  Each object in the options array supplied should have a `value` and `label`
@@ -34,16 +41,18 @@ the option can be passed as additional props.
34
41
  Labels should be strings, but values can be any type as long as they are
35
42
  unique in the list.
36
43
 
37
- ```js
38
- const options = [
39
- { label: "first", value: 1 },
40
- { label: "second", value: [] },
41
- { label: "third", value: "3", "$color": "warning" }
42
- ]
43
- ```
44
-
45
- ## Usage
44
+ ## Example
46
45
  ```svelte
46
+ <script>
47
+ import { Radio, Grid } from "@axel669/zephyr"
48
+
49
+ const options = [
50
+ { label: "first", value: 1 },
51
+ { label: "second", value: [] },
52
+ { label: "third", value: "3", "$color": "warning" }
53
+ ]
54
+ </script>
55
+
47
56
  <Radio {options} bind:value />
48
- <Radio {options} bind:value={other} layout={Grid} gr-col="1fr 1fr" />
57
+ <Radio {options} bind:value={other} layout={Grid} gr.cols="1fr 1fr" />
49
58
  ```
@@ -1,6 +1,4 @@
1
1
  <script>
2
- import asuid from "@labyrinthos/asuid"
3
-
4
2
  import wsx from "../wsx.mjs"
5
3
  import { handler$ } from "../handler$.mjs"
6
4
 
@@ -15,7 +13,7 @@
15
13
  (newValue) => value = newValue
16
14
  )
17
15
 
18
- const name = asuid()
16
+ const name = `${Math.random().toString(16)}-${Date.now()}`
19
17
  </script>
20
18
 
21
19
  <svelte:component this={layout} {...$$restProps}>
@@ -10,17 +10,29 @@ using a `<select>`
10
10
  All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
11
11
  are supported.
12
12
 
13
- - ### color `string`
14
- Sets `$color`
15
- - ### label `string`
16
- The text to display as the label
17
- - ### options `Array[Object]`
18
- An array of options and groups to show in the select. Details below
19
- - ### outline `bool`
20
- Sets `$outline`
21
- - ### value `any`
22
- The value currently selected. Can be bound to react to selections or
23
- change the current selection.
13
+ ### color
14
+ `string`
15
+
16
+ Sets `$color`
17
+
18
+ ### label
19
+ `string`
20
+
21
+ The text to display as the label
22
+
23
+ ### options
24
+ `Array[Object]`
25
+
26
+ An array of options and groups to show in the select. Details below
27
+
28
+ ### outline `bool`
29
+
30
+ Sets `$outline`
31
+ ### value
32
+ `any`
33
+
34
+ The value currently selected. Can be bound to react to selections or
35
+ change the current selection.
24
36
 
25
37
  ## Options
26
38
  Each object in the options provided should be in one of 2 forms:
@@ -34,22 +46,25 @@ array) is put into the optgroup defined by the group item.
34
46
 
35
47
  Labels and group names should be strings, but values can be any type.
36
48
 
37
- ## Usage
38
- ```js
39
- // Results in:
40
- // <option>first</option>
41
- // <optgroup label="Not Numbers">
42
- // <option>second</option>
43
- // <option>third</option>
44
- // </optgroup>
45
- const options = [
46
- { label: "first", value: 1 },
47
- { group: "Not numbers" },
48
- { label: "second", value: "two" },
49
- { label: "third", value: [3] },
50
- ]
51
- ```
49
+ ## Example
52
50
  ```svelte
51
+ <script>
52
+ import { Select } from "@axel669/zephyr"
53
+
54
+ // Results in:
55
+ // <option>first</option>
56
+ // <optgroup label="Not Numbers">
57
+ // <option>second</option>
58
+ // <option>third</option>
59
+ // </optgroup>
60
+ const options = [
61
+ { label: "first", value: 1 },
62
+ { group: "Not numbers" },
63
+ { label: "second", value: "two" },
64
+ { label: "third", value: [3] },
65
+ ]
66
+ </script>
67
+
53
68
  <Select {options} bind:value label="Blep" />
54
69
  <Select {options} bind:value color="warning" label="Why" />
55
70
  ```
@@ -2,34 +2,46 @@
2
2
 
3
3
  It's tabs, everyone knows what tabs are at this point.
4
4
 
5
- ## Base
6
- [Windstorm Tabs](https://axel669.github.io/lib.windstorm/#components-tabs)
7
-
8
5
  ## Props
9
- All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
10
- are supported.
11
-
12
- - ### color `string`
13
- Sets `$color`
14
- - ### options `Array[Object]`
15
- An array of options where each item is `{ label, value }`. `label`
16
- should be a string, `value` can be of any type.
17
- - ### vertical `bool`
18
- Sets `$vert`
19
- - ### solid `bool`
20
- Sets `$solid`
21
- - ### value `any`
22
- The value of the currently selected tab. Can be bound to react to
23
- changes and set to control which tab is selected.
24
-
25
- ## Usage
26
- ```js
27
- const options = [
28
- { label: "Left", value: "left" },
29
- { label: "Right", value: 2 },
30
- ]
31
- ```
6
+
7
+ ### color
8
+ `string`
9
+
10
+ Sets `$color`
11
+
12
+ ### options
13
+ `Array[Object]`
14
+
15
+ An array of options where each item is `{ label, value }`. `label`
16
+ should be a string, `value` can be of any type.
17
+
18
+ ### vertical
19
+ `bool`
20
+
21
+ Sets `$vert`
22
+
23
+ ### solid
24
+ `bool`
25
+
26
+ Sets `$solid`
27
+
28
+ ### value
29
+ `any`
30
+
31
+ The value of the currently selected tab. Can be bound to react to
32
+ changes and set to control which tab is selected.
33
+
34
+ ## Example
32
35
  ```svelte
36
+ <script>
37
+ import { Tabs } from "@axel669/zephyr"
38
+
39
+ const options = [
40
+ { label: "Left", value: "left" },
41
+ { label: "Right", value: 2 },
42
+ ]
43
+ </script>
44
+
33
45
  <Tab {options} bind:value color="primary" />
34
46
  <Tab {options} bind:value color="secondary" solid vertical />
35
47
  ```