@marianmeres/stuic 2.1.20 → 2.1.22

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.
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { onMount } from "svelte";
3
2
  import { svgCircle, type SvgCircleOptions } from "../../utils/svg-circle.js";
4
3
  import { twMerge } from "../../utils/tw-merge.js";
5
4
 
@@ -1,17 +1,42 @@
1
1
  <script lang="ts">
2
2
  import { createTickerRAF } from "@marianmeres/ticker";
3
- import Circle from "../Circle/Circle.svelte";
3
+ import { onDestroy } from "svelte";
4
4
  import { oscillate } from "../../utils/oscillate.js";
5
5
  import { twMerge } from "../../utils/tw-merge.js";
6
+ import Circle from "../Circle/Circle.svelte";
6
7
 
7
8
  let {
8
9
  class: classProp = "",
9
10
  bgStrokeColor = "rgba(0 0 0 / .1)",
10
- }: { class?: string; bgStrokeColor?: string } = $props();
11
+ strokeWidth,
12
+ noOscillate,
13
+ rotateDuration = ".75s",
14
+ }: {
15
+ class?: string;
16
+ bgStrokeColor?: string;
17
+ strokeWidth?: number;
18
+ noOscillate?: boolean;
19
+ rotateDuration?: string;
20
+ } = $props();
21
+
22
+ /**
23
+ * NOTE: we happen to have 4 distinct values here which effect the overall look and feel...
24
+ * 1. the tick frequency
25
+ * 2. the oscillation time input (seconds)
26
+ * 3. the oscillation speed factor (1)
27
+ * 4. the animation-spin duration
28
+ */
11
29
 
12
30
  const ticker = createTickerRAF(50, true);
31
+ let completeness = $derived(noOscillate ? 0.66 : oscillate($ticker / 1000, 0.15, 0.85));
13
32
 
14
- let completeness = $derived(oscillate($ticker / 1000, 0.15, 0.85, 1));
33
+ onDestroy(ticker.stop);
15
34
  </script>
16
35
 
17
- <Circle {completeness} class={twMerge("animate-spin", classProp)} {bgStrokeColor} />
36
+ <Circle
37
+ {completeness}
38
+ class={twMerge("stuic-spinner-circle animate-spin", classProp)}
39
+ {bgStrokeColor}
40
+ {strokeWidth}
41
+ style="animation-duration: {rotateDuration}"
42
+ />
@@ -1,6 +1,9 @@
1
1
  type $$ComponentProps = {
2
2
  class?: string;
3
3
  bgStrokeColor?: string;
4
+ strokeWidth?: number;
5
+ noOscillate?: boolean;
6
+ rotateDuration?: string;
4
7
  };
5
8
  declare const SpinnerCircle: import("svelte").Component<$$ComponentProps, {}, "">;
6
9
  type SpinnerCircle = ReturnType<typeof SpinnerCircle>;
@@ -1,2 +1,3 @@
1
1
  export { default as Spinner } from "./Spinner.svelte";
2
- export { default as SpinnerUnicode, spinnerCreateBackAndForthCharFrames, type SpinnerUnicodeVariant, } from "./SpinnerUnicode.svelte";
2
+ export { default as SpinnerCircle } from "./SpinnerCircle.svelte";
3
+ export { spinnerCreateBackAndForthCharFrames, default as SpinnerUnicode, type SpinnerUnicodeVariant, } from "./SpinnerUnicode.svelte";
@@ -1,2 +1,3 @@
1
1
  export { default as Spinner } from "./Spinner.svelte";
2
- export { default as SpinnerUnicode, spinnerCreateBackAndForthCharFrames, } from "./SpinnerUnicode.svelte";
2
+ export { default as SpinnerCircle } from "./SpinnerCircle.svelte";
3
+ export { spinnerCreateBackAndForthCharFrames, default as SpinnerUnicode, } from "./SpinnerUnicode.svelte";
@@ -8,7 +8,7 @@ export interface SvgCircleOptions {
8
8
  rotate: number;
9
9
  strokeWidthRatio: number;
10
10
  }
11
- /** Will construct and return svg DOM element based on input options */
11
+ /** Will construct and return svg circle DOM element based on input options */
12
12
  export declare function svgCircle(options?: Partial<SvgCircleOptions>): {
13
13
  svg: SVGSVGElement;
14
14
  setCompleteness(completeness: number): void;
@@ -2,7 +2,7 @@ function _normalize_completness(v) {
2
2
  return Math.max(0, Math.min(1, v));
3
3
  }
4
4
  function _normalize_rotate(v) {
5
- return `${v % 360}`;
5
+ return v % 360;
6
6
  }
7
7
  function _normalize_cls(v) {
8
8
  return [
@@ -12,7 +12,7 @@ function _normalize_cls(v) {
12
12
  .filter(Boolean)),
13
13
  ];
14
14
  }
15
- /** Will construct and return svg DOM element based on input options */
15
+ /** Will construct and return svg circle DOM element based on input options */
16
16
  export function svgCircle(options = {}) {
17
17
  let { strokeWidth = 10, completeness = 1, bgStrokeColor = "", class: classProp = "", roundedEdges = true, rotate = 0, strokeWidthRatio = 0, } = options ?? {};
18
18
  completeness = _normalize_completness(completeness);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.1.20",
3
+ "version": "2.1.22",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",