spaper 0.2.5 → 0.2.6

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 CHANGED
@@ -60,6 +60,7 @@ npm i spaper
60
60
  - Button
61
61
  - Card
62
62
  - Collapsible
63
+ - Form
63
64
  - Checkbox
64
65
  - Input
65
66
  - Radio
@@ -73,8 +74,4 @@ npm i spaper
73
74
  - Progress
74
75
  - Table
75
76
  - Tabs
76
-
77
- ##### Coming soon:
78
- - Form
79
77
  - Toast
80
- - Step
@@ -4,7 +4,7 @@
4
4
  on:mouseenter={pause}
5
5
  on:mouseleave={dismiss}
6
6
  in:fly={{ y: position.includes('top') ? -100 : 100 }}
7
- out:fade={{ duration: 300 }}
7
+ out:fade={{ duration: TRANSITION_OUT_DURATION }}
8
8
  role="alert">
9
9
  {@html message}
10
10
  {#if dismissible||indefinite}
@@ -30,6 +30,7 @@ export let dismissible = false;
30
30
  export let indefinite = false;
31
31
  export let closeAriaLabel = 'close';
32
32
  export let onClose = null;
33
+ const TRANSITION_OUT_DURATION = 300;
33
34
  let active = true;
34
35
  let toastElement;
35
36
  let timeoutId;
@@ -56,19 +57,31 @@ function dismiss() {
56
57
  }
57
58
  function close() {
58
59
  active = false;
60
+ removeContainer();
59
61
  onClose === null || onClose === void 0 ? void 0 : onClose();
60
62
  }
63
+ function getContainer() {
64
+ return document.querySelector(containerSelector);
65
+ }
61
66
  function setupContainer() {
62
67
  new ToastContainer({
63
68
  target: document.body,
64
69
  props: { position },
65
70
  });
66
- return document.querySelector(containerSelector);
71
+ return getContainer();
67
72
  }
68
73
  function insert() {
69
- const container = document.querySelector(containerSelector) || setupContainer();
74
+ const container = getContainer() || setupContainer();
70
75
  container.insertAdjacentElement('afterbegin', toastElement);
71
76
  }
77
+ function removeContainer() {
78
+ const container = getContainer();
79
+ setTimeout(() => {
80
+ if (container.children.length === 1) {
81
+ container.remove();
82
+ }
83
+ }, TRANSITION_OUT_DURATION);
84
+ }
72
85
  </script>
73
86
 
74
87
  <style>
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "papercss",
9
9
  "components"
10
10
  ],
11
- "version": "0.2.5",
11
+ "version": "0.2.6",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/Oli8/spaper.git"