@budibase/bbui 1.0.0 → 1.0.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 +375 -0
- package/README.md +19 -17
- package/dist/bbui.es.js +2 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +68 -26
- package/src/ActionButton/ActionButton.svelte +83 -0
- package/src/ActionGroup/ActionGroup.svelte +26 -0
- package/src/ActionMenu/ActionMenu.svelte +43 -0
- package/src/Actions/ClickOutside.svench.svx +30 -0
- package/src/Actions/PositionDropdown.svench.svx +81 -0
- package/src/Actions/autoresize_textarea.js +14 -0
- package/src/Actions/click_outside.js +18 -0
- package/src/Actions/position_dropdown.js +66 -0
- package/src/Avatar/Avatar.svelte +49 -0
- package/src/Badge/Badge.svelte +29 -0
- package/src/Button/Button.svelte +52 -0
- package/src/Button/Button.svench +138 -0
- package/src/ButtonGroup/ButtonGroup.svelte +19 -0
- package/src/ClearButton/ClearButton.svelte +19 -0
- package/src/ColorPicker/ColorPicker.svelte +292 -0
- package/src/DetailSummary/DetailSummary.svelte +83 -0
- package/src/Divider/Divider.svelte +25 -0
- package/src/Drawer/Drawer.svelte +85 -0
- package/src/Drawer/Drawer.svench +42 -0
- package/src/Drawer/DrawerContent.svelte +46 -0
- package/src/Form/Checkbox.svelte +23 -0
- package/src/Form/Combobox.svelte +44 -0
- package/src/Form/Core/Checkbox.svelte +67 -0
- package/src/Form/Core/Combobox.svelte +156 -0
- package/src/Form/Core/DatePicker.svelte +183 -0
- package/src/Form/Core/Dropzone.svelte +393 -0
- package/src/Form/Core/Multiselect.svelte +88 -0
- package/src/Form/Core/Picker.svelte +241 -0
- package/src/Form/Core/RadioGroup.svelte +47 -0
- package/src/Form/Core/Search.svelte +101 -0
- package/src/Form/Core/Select.svelte +81 -0
- package/src/Form/Core/Stepper.svelte +172 -0
- package/src/Form/Core/Switch.svelte +35 -0
- package/src/Form/Core/TextArea.svelte +60 -0
- package/src/Form/Core/TextField.svelte +104 -0
- package/src/Form/Core/index.js +12 -0
- package/src/Form/DatePicker.svelte +33 -0
- package/src/Form/Dropzone.svelte +34 -0
- package/src/Form/Field.svelte +41 -0
- package/src/Form/FieldLabel.svelte +27 -0
- package/src/Form/Input.svelte +38 -45
- package/src/Form/Multiselect.svelte +39 -0
- package/src/Form/RadioGroup.svelte +38 -0
- package/src/Form/Search.svelte +32 -0
- package/src/Form/Select.svelte +45 -43
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +25 -44
- package/src/Form/Toggle.svelte +23 -0
- package/src/Icon/Icon.svelte +47 -0
- package/src/InlineAlert/InlineAlert.svelte +56 -0
- package/src/Label/Label.svelte +67 -0
- package/src/Layout/Layout.svelte +75 -0
- package/src/Layout/Page.svelte +25 -0
- package/src/Link/Link.svelte +22 -0
- package/src/List/Items/DetailSummary.svench +53 -0
- package/src/Menu/Item.svelte +45 -0
- package/src/Menu/Menu.svelte +7 -0
- package/src/Menu/Menu.svench +19 -0
- package/src/Menu/Section.svelte +10 -0
- package/src/Menu/Separator.svelte +1 -0
- package/src/Modal/Content.svelte +6 -0
- package/src/Modal/CustomContent.svelte +38 -0
- package/src/Modal/Modal.svelte +133 -0
- package/src/Modal/Modal.svench +117 -0
- package/src/Modal/ModalContent.svelte +139 -0
- package/src/Modal/QuizModal.svelte +54 -0
- package/src/Notification/Notification.svelte +20 -0
- package/src/Notification/NotificationDisplay.svelte +36 -0
- package/src/Pagination/Pagination.svelte +57 -0
- package/src/Popover/Popover.svelte +52 -0
- package/src/Popover/Popover.svench +121 -0
- package/src/ProgressBar/ProgressBar.svelte +54 -0
- package/src/ProgressCircle/ProgressCircle.svelte +62 -0
- package/src/SideNavigation/Item.svelte +45 -0
- package/src/SideNavigation/Navigation.svelte +12 -0
- package/src/StatusLight/StatusLight.svelte +41 -0
- package/src/Stores/Notifications.svench.svx +78 -0
- package/src/Stores/notifications.js +56 -0
- package/src/Table/ArrayRenderer.svelte +17 -0
- package/src/Table/AttachmentRenderer.svelte +55 -0
- package/src/Table/BooleanRenderer.svelte +42 -0
- package/src/Table/CellRenderer.svelte +37 -0
- package/src/Table/DateTimeRenderer.svelte +13 -0
- package/src/Table/InternalRenderer.svelte +28 -0
- package/src/Table/RelationshipRenderer.svelte +40 -0
- package/src/Table/SelectEditRenderer.svelte +16 -0
- package/src/Table/StringRenderer.svelte +13 -0
- package/src/Table/Table.svelte +506 -0
- package/src/Table/index.js +1 -0
- package/src/Tabs/Tab.svelte +66 -0
- package/src/Tabs/Tabs.svelte +105 -0
- package/src/Tags/Tag.svelte +43 -0
- package/src/Tags/Tags.svelte +7 -0
- package/src/Tooltip/Tooltip.svelte +24 -0
- package/src/TreeView/Item.svelte +41 -0
- package/src/TreeView/Tree.svelte +16 -0
- package/src/Typography/Body.svelte +19 -0
- package/src/Typography/Code.svelte +10 -0
- package/src/Typography/Detail.svelte +15 -0
- package/src/Typography/Heading.svelte +16 -0
- package/src/bbui.css +96 -0
- package/src/context.js +3 -0
- package/src/index.js +75 -10
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
- package/src/utils/helpers.js +8 -0
- package/dist/bundle.css +0 -6
- package/dist/bundle.css.map +0 -18
- package/dist/index.js +0 -919
- package/dist/index.mjs +0 -906
- package/src/Branding/Budibase-logo.svelte +0 -68
- package/src/Branding/Logo.svelte +0 -16
- package/src/Branding/Logo.svench +0 -8
- package/src/Form/Button.svelte +0 -52
- package/src/Form/Button.svench +0 -26
- package/src/Form/Input.svench +0 -8
- package/src/Form/Select.svench +0 -8
- package/src/Form/TextArea.svench +0 -8
- package/src/Links/Home.svelte +0 -49
- package/src/Links/Home.svench +0 -19
- package/src/actions/autoresize_textarea.js +0 -14
- package/src/icons/Contribution.svelte +0 -14
- package/src/index.svench.svx +0 -35
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import ModalContent from "./ModalContent.svelte"
|
|
3
|
+
import Input from "../Form/Input.svelte"
|
|
4
|
+
|
|
5
|
+
let modal
|
|
6
|
+
let answer
|
|
7
|
+
let error
|
|
8
|
+
|
|
9
|
+
export function show() {
|
|
10
|
+
modal.show()
|
|
11
|
+
}
|
|
12
|
+
export function hide() {
|
|
13
|
+
modal.hide
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function resetState() {
|
|
17
|
+
answer = undefined
|
|
18
|
+
error = undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function answerQuiz() {
|
|
22
|
+
const correct = answer === "8"
|
|
23
|
+
error = !correct
|
|
24
|
+
return correct
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<ModalContent
|
|
29
|
+
title="Quick Maths"
|
|
30
|
+
bind:this={modal}
|
|
31
|
+
confirmText="Submit"
|
|
32
|
+
onConfirm={answerQuiz}
|
|
33
|
+
on:show={resetState}
|
|
34
|
+
>
|
|
35
|
+
{#if error}
|
|
36
|
+
<p class="error">Wrong answer! Try again.</p>
|
|
37
|
+
{/if}
|
|
38
|
+
<p>What is 4 + 4?</p>
|
|
39
|
+
<Input label="Answer" bind:value={answer} />
|
|
40
|
+
</ModalContent>
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
p {
|
|
44
|
+
margin: 0;
|
|
45
|
+
font-family: var(--font-sans);
|
|
46
|
+
font-size: var(--font-size-s);
|
|
47
|
+
}
|
|
48
|
+
p.error {
|
|
49
|
+
color: #e26d69;
|
|
50
|
+
background-color: #ffe6e6;
|
|
51
|
+
padding: 8px;
|
|
52
|
+
border-radius: 4px;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let type = "info"
|
|
3
|
+
export let icon = "Info"
|
|
4
|
+
export let message = ""
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="spectrum-Toast spectrum-Toast--{type}">
|
|
8
|
+
{#if icon}
|
|
9
|
+
<svg
|
|
10
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Toast-typeIcon"
|
|
11
|
+
focusable="false"
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
>
|
|
14
|
+
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
15
|
+
</svg>
|
|
16
|
+
{/if}
|
|
17
|
+
<div class="spectrum-Toast-body">
|
|
18
|
+
<div class="spectrum-Toast-content">{message || ""}</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/toast/dist/index-vars.css"
|
|
3
|
+
import Portal from "svelte-portal"
|
|
4
|
+
import { flip } from "svelte/animate"
|
|
5
|
+
import { notifications } from "../Stores/notifications"
|
|
6
|
+
import Notification from "./Notification.svelte"
|
|
7
|
+
import { fly } from "svelte/transition"
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Portal target=".modal-container">
|
|
11
|
+
<div class="notifications">
|
|
12
|
+
{#each $notifications as { type, icon, message, id } (id)}
|
|
13
|
+
<div animate:flip transition:fly={{ y: -30 }}>
|
|
14
|
+
<Notification {type} {icon} {message} />
|
|
15
|
+
</div>
|
|
16
|
+
{/each}
|
|
17
|
+
</div>
|
|
18
|
+
</Portal>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.notifications {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 20px;
|
|
24
|
+
left: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
margin: 0 auto;
|
|
27
|
+
padding: 0;
|
|
28
|
+
z-index: 9999;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
justify-content: flex-start;
|
|
32
|
+
align-items: center;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
gap: 10px;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/pagination/dist/index-vars.css"
|
|
3
|
+
import "@spectrum-css/actionbutton/dist/index-vars.css"
|
|
4
|
+
import "@spectrum-css/typography/dist/index-vars.css"
|
|
5
|
+
|
|
6
|
+
export let page
|
|
7
|
+
export let goToPrevPage
|
|
8
|
+
export let goToNextPage
|
|
9
|
+
export let hasPrevPage = true
|
|
10
|
+
export let hasNextPage = true
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<nav class="spectrum-Pagination spectrum-Pagination--explicit">
|
|
14
|
+
<div
|
|
15
|
+
href="#"
|
|
16
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-ActionButton--quiet spectrum-Pagination-prevButton"
|
|
17
|
+
on:click={hasPrevPage ? goToPrevPage : null}
|
|
18
|
+
class:is-disabled={!hasPrevPage}
|
|
19
|
+
>
|
|
20
|
+
<svg
|
|
21
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronLeft100"
|
|
22
|
+
focusable="false"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
aria-label="ChevronLeft"
|
|
25
|
+
>
|
|
26
|
+
<use xlink:href="#spectrum-css-icon-Chevron100" />
|
|
27
|
+
</svg>
|
|
28
|
+
</div>
|
|
29
|
+
<span class="spectrum-Body--secondary spectrum-Pagination-counter">
|
|
30
|
+
Page {page}
|
|
31
|
+
</span>
|
|
32
|
+
<div
|
|
33
|
+
href="#"
|
|
34
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-ActionButton--quiet spectrum-Pagination-nextButton"
|
|
35
|
+
on:click={hasNextPage ? goToNextPage : null}
|
|
36
|
+
class:is-disabled={!hasNextPage}
|
|
37
|
+
>
|
|
38
|
+
<svg
|
|
39
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronRight100"
|
|
40
|
+
focusable="false"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
aria-label="ChevronLeft"
|
|
43
|
+
>
|
|
44
|
+
<use xlink:href="#spectrum-css-icon-Chevron100" />
|
|
45
|
+
</svg>
|
|
46
|
+
</div>
|
|
47
|
+
</nav>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.spectrum-Pagination-counter {
|
|
51
|
+
margin-left: 0;
|
|
52
|
+
user-select: none;
|
|
53
|
+
}
|
|
54
|
+
.is-disabled:hover {
|
|
55
|
+
cursor: initial;
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/popover/dist/index-vars.css"
|
|
3
|
+
import Portal from "svelte-portal"
|
|
4
|
+
import { createEventDispatcher } from "svelte"
|
|
5
|
+
import positionDropdown from "../Actions/position_dropdown"
|
|
6
|
+
import clickOutside from "../Actions/click_outside"
|
|
7
|
+
|
|
8
|
+
const dispatch = createEventDispatcher()
|
|
9
|
+
|
|
10
|
+
export let anchor
|
|
11
|
+
export let align = "right"
|
|
12
|
+
export let portalTarget
|
|
13
|
+
|
|
14
|
+
export const show = () => {
|
|
15
|
+
dispatch("open")
|
|
16
|
+
open = true
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const hide = () => {
|
|
20
|
+
dispatch("close")
|
|
21
|
+
open = false
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let open = null
|
|
25
|
+
|
|
26
|
+
function handleEscape(e) {
|
|
27
|
+
if (open && e.key === "Escape") {
|
|
28
|
+
hide()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if open}
|
|
34
|
+
<Portal target={portalTarget}>
|
|
35
|
+
<div
|
|
36
|
+
tabindex="0"
|
|
37
|
+
use:positionDropdown={{ anchor, align }}
|
|
38
|
+
use:clickOutside={hide}
|
|
39
|
+
on:keydown={handleEscape}
|
|
40
|
+
class="spectrum-Popover is-open"
|
|
41
|
+
role="presentation"
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
</Portal>
|
|
46
|
+
{/if}
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.spectrum-Popover {
|
|
50
|
+
min-width: var(--spectrum-global-dimension-size-2000) !important;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { View } from "svench";
|
|
3
|
+
import Popover from "./Popover.svelte";
|
|
4
|
+
import Button from "../Button/Button.svelte";
|
|
5
|
+
import TextButton from "../Button/TextButton.svelte";
|
|
6
|
+
import Icon from "../Icons/Icon.svelte";
|
|
7
|
+
import Input from "../Form/Input.svelte";
|
|
8
|
+
import Select from "../Form/Select.svelte";
|
|
9
|
+
|
|
10
|
+
let anchorRight;
|
|
11
|
+
let anchorLeft;
|
|
12
|
+
let dropdownRight;
|
|
13
|
+
let dropdownLeft;
|
|
14
|
+
|
|
15
|
+
const options = ["Column 1", "Column 2", "Super cool column"];
|
|
16
|
+
const option1s = ["Is", "Is not", "Contains" , "Does not contain"];
|
|
17
|
+
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.button-group {
|
|
22
|
+
margin-top: var(--spacing-l);
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: flex-end;
|
|
25
|
+
gap: var(--spacing-s);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
h6 {
|
|
29
|
+
font-size: var(--font-size-m);
|
|
30
|
+
margin: 0 0 var(--spacing-l) 0;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
font-family: var(--font-sans);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.input-group-column {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: var(--spacing-s);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.input-group-row {
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];
|
|
44
|
+
gap: var(--spacing-s);
|
|
45
|
+
margin-bottom: var(--spacing-l);
|
|
46
|
+
align-items: center;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
p {
|
|
50
|
+
margin:0;
|
|
51
|
+
font-size: var(--font-size-xs);
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
|
|
55
|
+
<View name="Simple popover">
|
|
56
|
+
<div bind:this={anchorLeft}>
|
|
57
|
+
<Button text on:click={dropdownLeft.show}>
|
|
58
|
+
<Icon name="view" />
|
|
59
|
+
Add View
|
|
60
|
+
</Button>
|
|
61
|
+
</div>
|
|
62
|
+
<Popover bind:this={dropdownLeft} anchor={anchorLeft} align="left">
|
|
63
|
+
<h6>Add New View</h6>
|
|
64
|
+
<Input thin placeholder="Enter your name" />
|
|
65
|
+
<div class="button-group">
|
|
66
|
+
<Button secondary on:click={() => alert('Clicked!')}>Cancel</Button>
|
|
67
|
+
<Button primary on:click={() => alert('Clicked!')}>Add New View</Button>
|
|
68
|
+
</div>
|
|
69
|
+
</Popover>
|
|
70
|
+
</View>
|
|
71
|
+
|
|
72
|
+
<View name="Stacked columns">
|
|
73
|
+
<div bind:this={anchorRight}>
|
|
74
|
+
<Button text on:click={dropdownRight.show}>
|
|
75
|
+
<Icon name="addrow" />
|
|
76
|
+
Add Row
|
|
77
|
+
</Button>
|
|
78
|
+
</div>
|
|
79
|
+
<Popover bind:this={dropdownRight} anchor={anchorRight}>
|
|
80
|
+
<h6>Add New Row</h6>
|
|
81
|
+
<div class="input-group-column">
|
|
82
|
+
<Input thin placeholder="Enter your string" />
|
|
83
|
+
<Input thin placeholder="Enter your string" />
|
|
84
|
+
<Input thin placeholder="Enter your string" />
|
|
85
|
+
</div>
|
|
86
|
+
<div class="button-group">
|
|
87
|
+
<Button secondary on:click={() => alert('Clicked!')}>Cancel</Button>
|
|
88
|
+
<Button primary on:click={() => alert('Clicked!')}>Add New Row</Button>
|
|
89
|
+
</div>
|
|
90
|
+
</Popover>
|
|
91
|
+
</View>
|
|
92
|
+
|
|
93
|
+
<View name="Multiple inputs in a row">
|
|
94
|
+
<div bind:this={anchorLeft}>
|
|
95
|
+
<Button text on:click={dropdownLeft.show}>
|
|
96
|
+
<Icon name="filter" />
|
|
97
|
+
Add Filter
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
100
|
+
<Popover bind:this={dropdownLeft} anchor={anchorLeft} align="left">
|
|
101
|
+
<h6>Add New Filter</h6>
|
|
102
|
+
<div class="input-group-row">
|
|
103
|
+
<p>Where</p>
|
|
104
|
+
<Select secondary thin name="Test">
|
|
105
|
+
{#each options as option}
|
|
106
|
+
<option value={option}>{option}</option>
|
|
107
|
+
{/each}
|
|
108
|
+
</Select>
|
|
109
|
+
<Select secondary thin name="Test">
|
|
110
|
+
{#each option1s as option1}
|
|
111
|
+
<option value={option1}>{option1}</option>
|
|
112
|
+
{/each}
|
|
113
|
+
</Select>
|
|
114
|
+
<Input thin placeholder="Enter your name" />
|
|
115
|
+
<Button text on:click={() => alert('Clicked!')}>
|
|
116
|
+
<Icon name="close" />
|
|
117
|
+
</Button>
|
|
118
|
+
</div>
|
|
119
|
+
<Button text on:click={() => alert('Clicked!')}>Add Filter</Button>
|
|
120
|
+
</Popover>
|
|
121
|
+
</View>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/progressbar/dist/index-vars.css"
|
|
3
|
+
import { tweened } from "svelte/motion"
|
|
4
|
+
import { cubicOut } from "svelte/easing"
|
|
5
|
+
|
|
6
|
+
export let value = false
|
|
7
|
+
export let easing = cubicOut
|
|
8
|
+
export let duration = 1000
|
|
9
|
+
export let width = false
|
|
10
|
+
export let sideLabel = false
|
|
11
|
+
|
|
12
|
+
export let size = "M"
|
|
13
|
+
|
|
14
|
+
const progress = tweened(0, {
|
|
15
|
+
duration: duration,
|
|
16
|
+
easing: easing,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
$: if (value) $progress = value
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class:spectrum-ProgressBar--indeterminate={!value}
|
|
24
|
+
class:spectrum-ProgressBar--sideLabel={sideLabel}
|
|
25
|
+
class="spectrum-ProgressBar spectrum-ProgressBar--size{size}"
|
|
26
|
+
value={$progress}
|
|
27
|
+
role="progressbar"
|
|
28
|
+
aria-valuenow={$progress}
|
|
29
|
+
aria-valuemin="0"
|
|
30
|
+
aria-valuemax="100"
|
|
31
|
+
style={width ? `width: ${width}px;` : ""}
|
|
32
|
+
>
|
|
33
|
+
{#if $$slots}
|
|
34
|
+
<div
|
|
35
|
+
class="spectrum-FieldLabel spectrum-ProgressBar-label spectrum-FieldLabel--size{size}"
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
</div>
|
|
39
|
+
{/if}
|
|
40
|
+
{#if value}
|
|
41
|
+
<div
|
|
42
|
+
class="spectrum-FieldLabel spectrum-ProgressBar-percentage spectrum-FieldLabel--size{size}"
|
|
43
|
+
>
|
|
44
|
+
{Math.round($progress)}%
|
|
45
|
+
</div>
|
|
46
|
+
{/if}
|
|
47
|
+
<div class="spectrum-ProgressBar-track">
|
|
48
|
+
<div
|
|
49
|
+
class="spectrum-ProgressBar-fill"
|
|
50
|
+
style={value ? `width: ${$progress}%` : ""}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="spectrum-ProgressBar-label" hidden="" />
|
|
54
|
+
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/progresscircle/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
export let size = "M"
|
|
5
|
+
function convertSize(size) {
|
|
6
|
+
switch (size) {
|
|
7
|
+
case "S":
|
|
8
|
+
return "small"
|
|
9
|
+
case "L":
|
|
10
|
+
return "large"
|
|
11
|
+
default:
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export let value = null
|
|
17
|
+
export let minValue = 0
|
|
18
|
+
export let maxValue = 100
|
|
19
|
+
|
|
20
|
+
let subMask1Style
|
|
21
|
+
let subMask2Style
|
|
22
|
+
$: calculateSubMasks(value)
|
|
23
|
+
|
|
24
|
+
function calculateSubMasks(value) {
|
|
25
|
+
if (value) {
|
|
26
|
+
let percentage = ((value - minValue) / (maxValue - minValue)) * 100
|
|
27
|
+
let angle
|
|
28
|
+
if (percentage > 0 && percentage <= 50) {
|
|
29
|
+
angle = -180 + (percentage / 50) * 180
|
|
30
|
+
subMask1Style = `transform: rotate(${angle}deg);`
|
|
31
|
+
subMask2Style = "transform: rotate(-180deg);"
|
|
32
|
+
} else if (percentage > 50) {
|
|
33
|
+
angle = -180 + ((percentage - 50) / 50) * 180
|
|
34
|
+
subMask1Style = "transform: rotate(0deg);"
|
|
35
|
+
subMask2Style = `transform: rotate(${angle}deg);`
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export let overBackground
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
on:click
|
|
45
|
+
class:spectrum-ProgressCircle--indeterminate={value == null}
|
|
46
|
+
class:spectrum-ProgressCircle--overBackground={overBackground}
|
|
47
|
+
class="spectrum-ProgressCircle spectrum-ProgressCircle--{convertSize(size)}"
|
|
48
|
+
>
|
|
49
|
+
<div class="spectrum-ProgressCircle-track" />
|
|
50
|
+
<div class="spectrum-ProgressCircle-fills">
|
|
51
|
+
<div class="spectrum-ProgressCircle-fillMask1">
|
|
52
|
+
<div class="spectrum-ProgressCircle-fillSubMask1" style={subMask1Style}>
|
|
53
|
+
<div class="spectrum-ProgressCircle-fill" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="spectrum-ProgressCircle-fillMask2">
|
|
57
|
+
<div class="spectrum-ProgressCircle-fillSubMask2" style={subMask2Style}>
|
|
58
|
+
<div class="spectrum-ProgressCircle-fill" />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from "svelte"
|
|
3
|
+
const multilevel = getContext("sidenav-type")
|
|
4
|
+
export let href = ""
|
|
5
|
+
export let external = false
|
|
6
|
+
export let heading = ""
|
|
7
|
+
export let icon = ""
|
|
8
|
+
export let selected = false
|
|
9
|
+
export let disabled = false
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<li
|
|
13
|
+
class="spectrum-SideNav-item"
|
|
14
|
+
class:is-selected={selected}
|
|
15
|
+
class:is-disabled={disabled}
|
|
16
|
+
on:click
|
|
17
|
+
>
|
|
18
|
+
{#if heading}
|
|
19
|
+
<h2 class="spectrum-SideNav-heading" id="nav-heading-{heading}">
|
|
20
|
+
{heading}
|
|
21
|
+
</h2>
|
|
22
|
+
{/if}
|
|
23
|
+
<a
|
|
24
|
+
target={external ? "_blank" : ""}
|
|
25
|
+
{href}
|
|
26
|
+
class="spectrum-SideNav-itemLink"
|
|
27
|
+
aria-current="page"
|
|
28
|
+
>
|
|
29
|
+
{#if icon}
|
|
30
|
+
<svg
|
|
31
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-SideNav-itemIcon"
|
|
32
|
+
focusable="false"
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
>
|
|
35
|
+
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
36
|
+
</svg>
|
|
37
|
+
{/if}
|
|
38
|
+
<slot />
|
|
39
|
+
</a>
|
|
40
|
+
{#if multilevel && $$slots.subnav}
|
|
41
|
+
<ul class="spectrum-SideNav">
|
|
42
|
+
<slot name="subnav" />
|
|
43
|
+
</ul>
|
|
44
|
+
{/if}
|
|
45
|
+
</li>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { setContext } from "svelte"
|
|
3
|
+
import "@spectrum-css/sidenav/dist/index-vars.css"
|
|
4
|
+
export let multilevel = false
|
|
5
|
+
setContext("sidenav-type", multilevel)
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<nav>
|
|
9
|
+
<ul class="spectrum-SideNav" class:spectrum-SideNav--multiLevel={multilevel}>
|
|
10
|
+
<slot />
|
|
11
|
+
</ul>
|
|
12
|
+
</nav>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/statuslight"
|
|
3
|
+
|
|
4
|
+
export let size = "M"
|
|
5
|
+
export let celery = false
|
|
6
|
+
export let yellow = false
|
|
7
|
+
export let fuchsia = false
|
|
8
|
+
export let indigo = false
|
|
9
|
+
export let seafoam = false
|
|
10
|
+
export let chartreuse = false
|
|
11
|
+
export let magenta = false
|
|
12
|
+
export let purple = false
|
|
13
|
+
export let neutral = false
|
|
14
|
+
export let info = false
|
|
15
|
+
export let positive = false
|
|
16
|
+
export let notice = false
|
|
17
|
+
export let negative = false
|
|
18
|
+
export let disabled = false
|
|
19
|
+
export let active = false
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
class="spectrum-StatusLight spectrum-StatusLight--size{size}"
|
|
24
|
+
class:spectrum-StatusLight--celery={celery}
|
|
25
|
+
class:spectrum-StatusLight--yellow={yellow}
|
|
26
|
+
class:spectrum-StatusLight--fuchsia={fuchsia}
|
|
27
|
+
class:spectrum-StatusLight--indigo={indigo}
|
|
28
|
+
class:spectrum-StatusLight--seafoam={seafoam}
|
|
29
|
+
class:spectrum-StatusLight--chartreuse={chartreuse}
|
|
30
|
+
class:spectrum-StatusLight--magenta={magenta}
|
|
31
|
+
class:spectrum-StatusLight--purple={purple}
|
|
32
|
+
class:spectrum-StatusLight--neutral={neutral}
|
|
33
|
+
class:spectrum-StatusLight--info={info}
|
|
34
|
+
class:spectrum-StatusLight--positive={positive}
|
|
35
|
+
class:spectrum-StatusLight--notice={notice}
|
|
36
|
+
class:spectrum-StatusLight--negative={negative}
|
|
37
|
+
class:spectrum-StatusLight--disabled={disabled}
|
|
38
|
+
class:spectrum-StatusLight--active={active}
|
|
39
|
+
>
|
|
40
|
+
<slot />
|
|
41
|
+
</div>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { flip } from 'svelte/animate';
|
|
3
|
+
import { fly } from "svelte/transition"
|
|
4
|
+
import { View } from "svench";
|
|
5
|
+
import { notifications } from "./notifications";
|
|
6
|
+
|
|
7
|
+
export let themes = {
|
|
8
|
+
danger: "#E26D69",
|
|
9
|
+
success: "#84C991",
|
|
10
|
+
warning: "#f0ad4e",
|
|
11
|
+
info: "#5bc0de",
|
|
12
|
+
default: "#aaaaaa",
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
## Notification Store
|
|
17
|
+
|
|
18
|
+
This custom can be used to display toast messages. It has 5 different methods: `send`, `danger`, `warning`, `success`, `info`.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<View name="danger">
|
|
22
|
+
<button on:click={() => notifications.error('This is a danger!')}>Danger</button>
|
|
23
|
+
</View>
|
|
24
|
+
<View name="warning">
|
|
25
|
+
<button on:click={() => notifications.warning('This is a warning!')}>Warning</button>
|
|
26
|
+
</View>
|
|
27
|
+
<View name="success">
|
|
28
|
+
<button on:click={() => notifications.success('This is a success!')}>Success</button>
|
|
29
|
+
</View>
|
|
30
|
+
<View name="info">
|
|
31
|
+
<button on:click={() => notifications.info('This is an info toast!')}>Info</button>
|
|
32
|
+
</View>
|
|
33
|
+
|
|
34
|
+
<div class="notifications">
|
|
35
|
+
{#each $notifications as notification (notification.id)}
|
|
36
|
+
<div
|
|
37
|
+
animate:flip
|
|
38
|
+
class="toast"
|
|
39
|
+
style="background: {themes[notification.type]};"
|
|
40
|
+
transition:fly={{ y: -30 }}>
|
|
41
|
+
<div class="content">{notification.message}</div>
|
|
42
|
+
{#if notification.icon}<i class={notification.icon} />{/if}
|
|
43
|
+
</div>
|
|
44
|
+
{/each}
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<style>
|
|
48
|
+
.notifications {
|
|
49
|
+
position: fixed;
|
|
50
|
+
top: 10px;
|
|
51
|
+
left: 0;
|
|
52
|
+
right: 0;
|
|
53
|
+
margin: 0 auto;
|
|
54
|
+
padding: 0;
|
|
55
|
+
z-index: 9999;
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
justify-content: flex-start;
|
|
59
|
+
align-items: center;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.toast {
|
|
64
|
+
flex: 0 0 auto;
|
|
65
|
+
margin-bottom: 10px;
|
|
66
|
+
border-radius: var(--border-radius-s);
|
|
67
|
+
/* The toasts now support being auto sized, so this static width could be removed */
|
|
68
|
+
width: 40vw;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.content {
|
|
72
|
+
padding: 10px;
|
|
73
|
+
display: block;
|
|
74
|
+
color: white;
|
|
75
|
+
font-weight: 500;
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
78
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { writable } from "svelte/store"
|
|
2
|
+
|
|
3
|
+
const NOTIFICATION_TIMEOUT = 3000
|
|
4
|
+
|
|
5
|
+
export const createNotificationStore = () => {
|
|
6
|
+
const timeoutIds = new Set()
|
|
7
|
+
const _notifications = writable([], () => {
|
|
8
|
+
return () => {
|
|
9
|
+
// clear all the timers
|
|
10
|
+
timeoutIds.forEach(timeoutId => {
|
|
11
|
+
clearTimeout(timeoutId)
|
|
12
|
+
})
|
|
13
|
+
_notifications.set([])
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
let block = false
|
|
17
|
+
|
|
18
|
+
const blockNotifications = (timeout = 1000) => {
|
|
19
|
+
block = true
|
|
20
|
+
setTimeout(() => (block = false), timeout)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const send = (message, type = "default", icon = "") => {
|
|
24
|
+
if (block) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
let _id = id()
|
|
28
|
+
_notifications.update(state => {
|
|
29
|
+
return [...state, { id: _id, type, message, icon }]
|
|
30
|
+
})
|
|
31
|
+
const timeoutId = setTimeout(() => {
|
|
32
|
+
_notifications.update(state => {
|
|
33
|
+
return state.filter(({ id }) => id !== _id)
|
|
34
|
+
})
|
|
35
|
+
}, NOTIFICATION_TIMEOUT)
|
|
36
|
+
timeoutIds.add(timeoutId)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { subscribe } = _notifications
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
subscribe,
|
|
43
|
+
send,
|
|
44
|
+
info: msg => send(msg, "info", "Info"),
|
|
45
|
+
error: msg => send(msg, "error", "Alert"),
|
|
46
|
+
warning: msg => send(msg, "warning", "Alert"),
|
|
47
|
+
success: msg => send(msg, "success", "CheckmarkCircle"),
|
|
48
|
+
blockNotifications,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function id() {
|
|
53
|
+
return "_" + Math.random().toString(36).substr(2, 9)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const notifications = createNotificationStore()
|