srcdev-nuxt-components 2.1.19 → 2.1.21

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.
@@ -23,7 +23,8 @@ watch(
23
23
  </script>
24
24
 
25
25
  <style lang="css">
26
- @keyframes textAnimation {
26
+
27
+ @keyframes animatedSvgText {
27
28
  0% {
28
29
  fill: transparent;
29
30
  stroke-dashoffset: var(--_animated-svg-text-stroke-dasharray);
@@ -34,39 +35,53 @@ watch(
34
35
  stroke-width: 0.3;
35
36
  }
36
37
  100% {
37
- fill: var(--_animated-svg-fill-color, var(--_animated-svg-text-fill-light));
38
+ fill: var(--_animated-svg-fill-color);
38
39
  stroke-dashoffset: 0;
39
40
  stroke-width: 0;
40
41
  }
41
42
  }
42
- .animated-svg-text {
43
- svg path {
44
- stroke: var(--_animated-svg-text-color, var(--_animated-svg-text-stroke-light));
45
- stroke-width: 0.3;
46
- stroke-dasharray: var(--_animated-svg-text-stroke-dasharray);
47
- stroke-dashoffset: var(--_animated-svg-text-stroke-dasharray);
48
- animation: textAnimation var(--_animated-svg-animation-duration) linear 1 forwards;
49
- }
50
43
 
51
- @media (prefers-color-scheme: light) {
52
- --_animated-svg-text-color: var(--_animated-svg-text-stroke-light);
53
- --_animated-svg-fill-color: var(--_animated-svg-text-fill-light);
44
+ html {
45
+
46
+ &[data-color-scheme='light'] {
47
+ .animated-svg-text {
48
+ --_animated-svg-text-color: var(--_animated-svg-text-stroke-light);
49
+ --_animated-svg-fill-color: var(--_animated-svg-text-fill-light);
50
+ }
51
+ }
52
+ &[data-color-scheme='dark'] {
53
+ .animated-svg-text {
54
+ --_animated-svg-text-color: var(--_animated-svg-text-stroke-dark);
55
+ --_animated-svg-fill-color: var(--_animated-svg-text-fill-dark);
56
+ }
54
57
  }
58
+ &[data-color-scheme='auto'] {
59
+ .animated-svg-text {
60
+ @media (prefers-color-scheme: light) {
61
+ --_animated-svg-text-color: var(--_animated-svg-text-stroke-light);
62
+ --_animated-svg-fill-color: var(--_animated-svg-text-fill-light);
63
+ }
55
64
 
56
- @media (prefers-color-scheme: dark) {
57
- --_animated-svg-text-color: var(--_animated-svg-text-stroke-dark);
58
- --_animated-svg-fill-color: var(--_animated-svg-text-fill-dark);
65
+ @media (prefers-color-scheme: dark) {
66
+ --_animated-svg-text-color: var(--_animated-svg-text-stroke-dark);
67
+ --_animated-svg-fill-color: var(--_animated-svg-text-fill-dark);
68
+ }
69
+ }
59
70
  }
60
- }
61
71
 
62
- /* html {
63
- &[data-color-scheme='light'] {
64
- --_animated-svg-text-color: var(--_animated-svg-text-stroke-light);
72
+ .animated-svg-text {
73
+
74
+ --_animated-svg-text-color: var(--_animated-svg-text-stroke-light):
65
75
  --_animated-svg-fill-color: var(--_animated-svg-text-fill-light);
76
+
77
+ svg path {
78
+ stroke: var(--_animated-svg-text-color);
79
+ stroke-width: 0.3;
80
+ stroke-dasharray: var(--_animated-svg-text-stroke-dasharray);
81
+ stroke-dashoffset: var(--_animated-svg-text-stroke-dasharray);
82
+ animation: animatedSvgText var(--_animated-svg-animation-duration) linear 1 forwards;
83
+ }
66
84
  }
67
- &[data-color-scheme='dark'] {
68
- --_animated-svg-text-color: var(--_animated-svg-text-stroke-dark);
69
- --_animated-svg-fill-color: var(--_animated-svg-text-fill-dark);
70
- }
71
- } */
85
+
86
+ }
72
87
  </style>
@@ -0,0 +1,73 @@
1
+ <template>
2
+ <div class="clip-element-wrapper" ref="container" :class="elementClasses">
3
+ <div class="clipped-element" :style="`--_clip-path: inset(${clipOffset}px 0 0 0)`" ref="clipElement">
4
+ <slot name="default"></slot>
5
+ </div>
6
+ </div>
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+
11
+ const props = defineProps({
12
+ maxClip: {
13
+ type: Number,
14
+ default: 100,
15
+ },
16
+ styleClassPassthrough: {
17
+ type: Array as PropType<string[]>,
18
+ default: () => [],
19
+ },
20
+ });
21
+
22
+ const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
23
+
24
+
25
+ const container = ref(null);
26
+ const clipElement = ref<HTMLDivElement | null>(null);
27
+ const clipOffset = ref(0);
28
+
29
+ const updateClip = () => {
30
+
31
+ if (clipElement.value) {
32
+
33
+ const topPosition = Math.floor(clipElement.value.getBoundingClientRect().top);
34
+
35
+ if (topPosition < props.maxClip && topPosition > 0) {
36
+ clipOffset.value = props.maxClip - topPosition;
37
+ }
38
+ else if (topPosition < 0) {
39
+ clipOffset.value = props.maxClip + Math.abs(topPosition);
40
+ }
41
+ else if (topPosition > props.maxClip) {
42
+ clipOffset.value = 0;
43
+ }
44
+ }
45
+ };
46
+
47
+ onMounted(() => {
48
+
49
+ if (import.meta.client) {
50
+ updateClip(); // Initial check
51
+ window.addEventListener('scroll', updateClip, { passive: true });
52
+ }
53
+
54
+ });
55
+
56
+ onBeforeUnmount(() => {
57
+ window.removeEventListener('scroll', updateClip);
58
+ });
59
+
60
+
61
+ </script>
62
+
63
+ <style lang="css">
64
+ .clip-element-wrapper {
65
+ position: relative;
66
+ overflow: hidden;
67
+ }
68
+ .clipped-element {
69
+ width: 100%;
70
+ clip-path: var(--_clip-path);
71
+ display: block;
72
+ }
73
+ </style>
package/nuxt.config.ts CHANGED
@@ -7,6 +7,7 @@ export default defineNuxtConfig({
7
7
  head: {
8
8
  htmlAttrs: {
9
9
  lang: 'en',
10
+ 'data-color-scheme': 'auto',
10
11
  },
11
12
  titleTemplate: '%s - Nuxt Components Layer',
12
13
  meta: [{ charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-components",
3
3
  "type": "module",
4
- "version": "2.1.19",
4
+ "version": "2.1.21",
5
5
  "main": "nuxt.config.ts",
6
6
  "scripts": {
7
7
  "clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",