tecitheme 0.14.1 → 0.14.3

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,5 @@
1
1
  <script>
2
- import { getColorStyles, getGridItemSizeStyles, getGridSizeStyles, getTeciImageURL, makeIdString, triggerWhenVisible } from "../utils";
2
+ import { conditionalTransition, getColorStyles, getGridItemSizeStyles, getGridSizeStyles, getTeciImageURL, makeIdString, triggerWhenVisible } from "../utils";
3
3
  import { onMount } from "svelte";
4
4
  import { cubicInOut } from "svelte/easing";
5
5
  import { writable } from "svelte/store";
@@ -17,7 +17,8 @@
17
17
  rows,
18
18
  button,
19
19
  items,
20
- animateOnScroll = true
20
+ animateOnScroll = true,
21
+ animate = true,
21
22
  } = data;
22
23
 
23
24
  let id = makeIdString(name);
@@ -25,7 +26,9 @@
25
26
  // Detect if the heading is visible, then trigger animations
26
27
  let scrollTargetVisible = writable(false);
27
28
  onMount(() => {
28
- triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
29
+ if (animate) {
30
+ triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
31
+ }
29
32
  })
30
33
  </script>
31
34
 
@@ -33,18 +36,18 @@
33
36
  <div class="mx-auto max-w-2xl px-6 lg:max-w-7xl lg:px-8">
34
37
 
35
38
  <!-- Eyebrow Text -->
36
- <h2 class="font-semibold {getColorStyles("text", color)} text-center w-full">{eyebrowText}</h2>
39
+ <h2 class="font-semibold {getColorStyles("text", color)} text-center w-full">{eyebrowText ? eyebrowText : ""}</h2>
37
40
 
38
41
  <!-- Heading -->
39
- <a id={id+"Heading"} href={`#${id}`} class="mt-2 text-balance text-center text-4xl font-semibold tracking-tight sm:text-5xl w-full text-gray-900 mx-auto"><p>{heading}</p></a>
42
+ <a id={id+"Heading"} href={`#${id}`} class="mt-2 text-balance text-center text-4xl font-semibold tracking-tight sm:text-5xl w-full text-gray-900 mx-auto"><p>{heading ? heading : ""}</p></a>
40
43
 
41
44
  <!-- Grid -->
42
45
  <div class="mt-10 grid grid-cols-1 gap-4 sm:mt-16 {getGridSizeStyles(columns, rows)}">
43
46
 
44
47
  {#each items as item, index}
45
- {#if $scrollTargetVisible}
48
+ {#if $scrollTargetVisible || !animate}
46
49
  <div class="relative {getGridItemSizeStyles(item.width, item.height)}"
47
- in:fly={{ delay: index*100, duration: 1500, easing: cubicInOut, x:'100%'}}
50
+ in:conditionalTransition={{ fn:fly, condition:animate, delay: index*100, duration: 1500, easing: cubicInOut, x:'100%'}}
48
51
  >
49
52
  <a class="relative flex h-full flex-col overflow-hidden shadow ring-1 ring-black/5 {item.url ? "hover:scale-105 transition ease-in-out delay-75" : ""}" href={item.url} rel="external">
50
53
 
@@ -53,8 +56,11 @@
53
56
 
54
57
  <!-- Text -->
55
58
  <div class="p-10 pt-4">
56
- <h3 class="text-sm/4 font-semibold {getColorStyles("text", color)}">{item.eyebrowText}</h3>
57
- <p class="mt-2 text-lg font-semibold tracking-tight text-gray-900">{item.heading}</p>
59
+
60
+ <h3 class="{item.eyebrowText ? "" : "h-4"} text-sm/4 font-semibold {getColorStyles("text", color)}">{item.eyebrowText ? item.eyebrowText : ""}</h3>
61
+
62
+ <p class="{item.heading ? "" : "h-6"} mt-2 text-lg font-semibold tracking-tight text-gray-900">{item.heading ? item.heading : ""}</p>
63
+
58
64
  <p class="mt-2 text-sm">{item.text}</p>
59
65
  </div>
60
66
  </a>
@@ -17,7 +17,8 @@
17
17
  color,
18
18
  image,
19
19
  button,
20
- animateOnScroll = true
20
+ animateOnScroll = true,
21
+ animate = true
21
22
  } = data;
22
23
 
23
24
  let id = makeIdString(name);
@@ -25,12 +26,14 @@
25
26
  // Detect if the heading is visible, then trigger animations
26
27
  let scrollTargetVisible = writable(false);
27
28
  onMount(() => {
28
- triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
29
+ if (animate) {
30
+ triggerWhenVisible(scrollTargetVisible, id+"Heading", !animateOnScroll)
31
+ }
29
32
  })
30
33
 
31
34
  </script>
32
35
 
33
- <div {id} class="{getColorStyles("background", color)} py-16">
36
+ <div {id} class="{getColorStyles("background", color)} py-8 lg:py-12">
34
37
  <div class="relative isolate">
35
38
  <div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
36
39
  <div class="mx-auto flex max-w-2xl flex-col gap-16 px-6 py-16 sm:p-8 lg:mx-0 lg:max-w-none lg:flex-row lg:items-center lg:py-20 xl:gap-x-20 xl:px-20">
@@ -45,9 +48,9 @@
45
48
  <div class="w-full flex-auto">
46
49
 
47
50
  <!-- Heading -->
48
- <a id={id+"Heading"} href={`#${id}`} class="text-4xl font-semibold tracking-tight text-pretty sm:text-5xl">{heading}</a>
51
+ <a id={id+"Heading"} href={`#${id}`} class="text-4xl font-semibold tracking-tight text-pretty sm:text-5xl text-gray-900">{heading}</a>
49
52
 
50
- {#if $scrollTargetVisible}
53
+ {#if $scrollTargetVisible || !animate}
51
54
  <!-- Text -->
52
55
  <p
53
56
  class="mt-6 text-lg/8 text-pretty"
@@ -69,12 +72,12 @@
69
72
  </li>
70
73
  {/each}
71
74
  </ul>
72
- {:else}
75
+ {:else if animate}
73
76
  <div class="h-32"></div>
74
77
  {/if}
75
78
 
76
79
  <!-- Button -->
77
- {#if $scrollTargetVisible}
80
+ {#if $scrollTargetVisible || !animate}
78
81
  <div
79
82
  class="mt-10 flex"
80
83
  in:fly={{ delay: 300, duration: 1750, easing: cubicInOut, x:"100%"}}
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { getColorStyles, makeIdString, triggerWhenVisible } from "../utils";
2
+ import { conditionalTransition, getColorStyles, makeIdString, triggerWhenVisible } from "../utils";
3
3
  import { onMount } from "svelte";
4
4
  import { fly, fade } from "svelte/transition";
5
5
  import Button from "./Button.svelte";
@@ -19,7 +19,8 @@
19
19
  icon,
20
20
  testimonial,
21
21
  textPosition,
22
- animateOnScroll = true
22
+ animateOnScroll = true,
23
+ animate = true
23
24
  } = data;
24
25
 
25
26
  // Initialize Text Position if left undefined
@@ -28,7 +29,9 @@
28
29
  // Detect if the heading is visible, then trigger animations
29
30
  let scrollTargetVisible = writable(false);
30
31
  onMount(() => {
31
- triggerWhenVisible(scrollTargetVisible, id+"text", !animateOnScroll)
32
+ if (animate) {
33
+ triggerWhenVisible(scrollTargetVisible, id+"text", !animateOnScroll)
34
+ }
32
35
  })
33
36
 
34
37
  </script>
@@ -40,7 +43,7 @@
40
43
 
41
44
  <!-- Text -->
42
45
  <div id={id+"text"} class="mx-auto max-w-xl px-6 lg:mx-0 lg:max-w-none lg:px-0 lg:py-16 {textPosition == "left" ? "" : "lg-col-start-2"} relative">
43
- {#if !$scrollTargetVisible}
46
+ {#if !$scrollTargetVisible && animate}
44
47
  <div
45
48
  out:fade={{delay: 0, duration: 500, easing:cubicInOut}}
46
49
  class="absolute top-0 bottom-0 w-full bg-gray-200 animate-pulse my-16"
@@ -50,38 +53,45 @@
50
53
  <div>
51
54
 
52
55
  <!-- Icon -->
53
- {#if icon && $scrollTargetVisible}
56
+ {#if icon && ($scrollTargetVisible || !animate)}
54
57
  <div
55
58
  class="hidden sm:flex size-16 items-center justify-center sm:shrink-0 flex-shrink-0 {getColorStyles("background", color)} text-3xl"
56
- in:fade={{delay: 200, duration: 750, easing:cubicInOut}}
57
- out:fade={{delay: 200, duration: 750, easing:cubicInOut}}
59
+ in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
60
+ out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
58
61
  >
59
62
  <Icon icon={icon.name} classes={"m-8 " + (icon.classes != undefined ? icon.classes : "")}/>
60
63
  </div>
61
64
  {/if}
62
65
 
63
66
  <!-- Heading, Text, and Button -->
64
- {#if $scrollTargetVisible}
67
+ {#if $scrollTargetVisible || !animate}
65
68
  <div
66
69
  class="mt-6"
67
- in:fade={{delay: 200, duration: 750, easing:cubicInOut}}
68
- out:fade={{delay: 200, duration: 750, easing:cubicInOut}}
70
+ in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
71
+ out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 750, easing:cubicInOut}}
69
72
  >
70
- <a href={`#${id}`} class="text-3xl font-bold tracking-tight text-gray-900">{heading}</a>
73
+ {#if heading}
74
+ <a href={`#${id}`} class="text-3xl font-bold tracking-tight text-gray-900">{heading}</a>
75
+ {/if}
76
+
71
77
  <p class="mt-4 text-lg text-gray-500">{text}</p>
72
- <div class="mt-6">
73
- <Button url={button.url} text={button.text} color={color} justify={button.justify} fullwidth={button.fullwidth}/>
74
- </div>
78
+
79
+ {#if button}
80
+ <div class="mt-6">
81
+ <Button url={button.url} text={button.text} color={color} justify={button.justify} fullwidth={button.fullwidth}/>
82
+ </div>
83
+ {/if}
84
+
75
85
  </div>
76
86
  {/if}
77
87
  </div>
78
88
 
79
89
  <!-- Testimonial -->
80
- {#if testimonial && $scrollTargetVisible}
90
+ {#if testimonial && ($scrollTargetVisible || !animate)}
81
91
  <div
82
92
  class="mt-8 border-t border-gray-200 pt-6"
83
- in:fly={{ delay: 300, duration: 1750, easing: cubicInOut, x: textPosition == "left" ? '-100%' : '100%' }}
84
- out:fly={{ delay: 300, duration: 1750, easing: cubicInOut, x: textPosition == "left" ? '-100%' : '100%' }}
93
+ in:conditionalTransition={{ fn: fade, condition: animate, delay: 300, duration: 1750, easing:cubicInOut, x: textPosition == "left" ? '-100%' : '100%'}}
94
+ out:conditionalTransition={{fn: fade, condition: animate, delay: 300, duration: 1750, easing:cubicInOut, x: textPosition == "left" ? '-100%' : '100%'}}
85
95
  >
86
96
  <blockquote>
87
97
  <div>
@@ -107,15 +117,15 @@
107
117
  <!-- Image -->
108
118
  <div id={id + "image"} class="relative mt-12 sm:mt-16 lg:mt-0 {textPosition == "left" ? "" : "lg:col-start-1"}"
109
119
  >
110
- {#if $scrollTargetVisible}
120
+ {#if $scrollTargetVisible || !animate}
111
121
  <div
112
122
  class="{textPosition == "left" ? "-mr-48 pl-6 md:-mr-16" : "-ml-48 pr-6 md:-ml-16"} lg:relative lg:m-0 lg:h-full lg:px-0"
113
- in:fly={{ delay: 200, duration: 1250, easing: cubicInOut, x: textPosition == "left" ? '100%' : '-100%' }}
114
- out:fly={{ delay: 200, duration: 1250, easing: cubicInOut, x: textPosition == "left" ? '100%' : '-100%' }}
123
+ in:conditionalTransition={{ fn: fade, condition: animate, delay: 200, duration: 1250, easing:cubicInOut, x: textPosition == "left" ? '100%' : '-100%'}}
124
+ out:conditionalTransition={{fn: fade, condition: animate, delay: 200, duration: 1250, easing:cubicInOut, x: textPosition == "left" ? '100%' : '-100%'}}
115
125
  >
116
126
  <img class="w-full shadow-xl ring-1 ring-black/5 lg:absolute {textPosition == "left" ? "lg:left-0" : "right-0"} lg:h-full lg:w-auto lg:max-w-none" src="https://files.thunderheadeng.com/www/images/{image.url}?fmt=auto" alt={image.alt}>
117
127
  </div>
118
- {:else}
128
+ {:else if animate}
119
129
  <div
120
130
  out:fly={{ delay: 0, duration: 500, easing: cubicInOut, x: textPosition == "left" ? '100%' : '-100%' }}
121
131
  class="absolute top-0 bottom-0 w-full bg-gray-200 animate-pulse my-16"
package/dist/utils.d.ts CHANGED
@@ -58,3 +58,10 @@ export function getTeciImageURL(imageSrc: any, site?: any): any;
58
58
  * @param {*} latch If true, the state will always be set to true after the page loads
59
59
  */
60
60
  export function triggerWhenVisible(store: any, elementId: any, latch?: any): void;
61
+ /** Simplifies the logic of conditionally animating an element using Svelte transitions. If options.condition is true, options.fn is run, passing options as an argument.
62
+ *
63
+ * @param {*} node The node that passed to this function (provided by svelte)
64
+ * @param {*} options Options to pass to the transition function. Should always define the properties options.condition and options.fn.
65
+ * @returns
66
+ */
67
+ export function conditionalTransition(node: any, options: any): any;
package/dist/utils.js CHANGED
@@ -485,4 +485,16 @@ export function triggerWhenVisible(store, elementId, latch = false) {
485
485
  addEventListener("scroll", (event) => {
486
486
  updateVisibility()
487
487
  })
488
+ }
489
+
490
+ /** Simplifies the logic of conditionally animating an element using Svelte transitions. If options.condition is true, options.fn is run, passing options as an argument.
491
+ *
492
+ * @param {*} node The node that passed to this function (provided by svelte)
493
+ * @param {*} options Options to pass to the transition function. Should always define the properties options.condition and options.fn.
494
+ * @returns
495
+ */
496
+ export function conditionalTransition(node, options) {
497
+ if (options.condition) {
498
+ return options.fn(node, options)
499
+ }
488
500
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tecitheme",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",