ngx-astro-shine-border 1.0.0
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/package.json +29 -0
- package/src/ShineBorder.astro +131 -0
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ngx-astro-shine-border",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shine border effect for Astro. Port of @omnedia/ngx-shine-border without Angular runtime.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/ShineBorder.astro",
|
|
9
|
+
"./ShineBorder.astro": "./src/ShineBorder.astro"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"astro": ">=5.0.0"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"astro",
|
|
19
|
+
"astro-component",
|
|
20
|
+
"shine-border",
|
|
21
|
+
"effect",
|
|
22
|
+
"border",
|
|
23
|
+
"animation"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/whitedotjsx/ngx-ui-to-astro.git"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
gradientColorStart?: string;
|
|
4
|
+
gradientColorMiddle?: string;
|
|
5
|
+
gradientColorEnd?: string;
|
|
6
|
+
borderRadius?: string;
|
|
7
|
+
borderColor?: string;
|
|
8
|
+
animationDuration?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
gradientColorStart = '#ffaa40',
|
|
14
|
+
gradientColorMiddle = '#fe8fb5',
|
|
15
|
+
gradientColorEnd = '#9c40ff',
|
|
16
|
+
borderRadius = '0.5rem',
|
|
17
|
+
borderColor = 'hsla(0, 0%, 0%, 0)',
|
|
18
|
+
animationDuration = '14s',
|
|
19
|
+
class: className = '',
|
|
20
|
+
} = Astro.props;
|
|
21
|
+
|
|
22
|
+
const style = [
|
|
23
|
+
`--color-from: ${gradientColorStart}`,
|
|
24
|
+
`--color-middle: ${gradientColorMiddle}`,
|
|
25
|
+
`--color-to: ${gradientColorEnd}`,
|
|
26
|
+
`--border-radius: ${borderRadius}`,
|
|
27
|
+
`--border-color: ${borderColor}`,
|
|
28
|
+
`--animation-duration: ${animationDuration}`,
|
|
29
|
+
].join('; ');
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<div class="om-shine-border-wrapper">
|
|
33
|
+
<div class:list={['om-shine-border', className]} style={style} data-om-shine-border>
|
|
34
|
+
<div class="om-shine-border-border" data-om-shine-border-border></div>
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.om-shine-border-wrapper {
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
padding: 1px;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.om-shine-border {
|
|
48
|
+
--color-from: #ffaa40;
|
|
49
|
+
--color-middle: #fe8fb5;
|
|
50
|
+
--color-to: #9c40ff;
|
|
51
|
+
--border-radius: 0.5rem;
|
|
52
|
+
--border-color: hsla(0, 0%, 0%, 0);
|
|
53
|
+
--animation-duration: 14s;
|
|
54
|
+
|
|
55
|
+
border: 1px solid;
|
|
56
|
+
border-radius: var(--border-radius);
|
|
57
|
+
border-color: var(--border-color);
|
|
58
|
+
position: relative;
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
|
|
62
|
+
.om-shine-border-border {
|
|
63
|
+
border: 1px solid transparent;
|
|
64
|
+
border-radius: inherit;
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
|
|
67
|
+
&::before {
|
|
68
|
+
content: '';
|
|
69
|
+
position: absolute;
|
|
70
|
+
height: 100%;
|
|
71
|
+
width: 100%;
|
|
72
|
+
aspect-ratio: 1/1;
|
|
73
|
+
will-change: background-position;
|
|
74
|
+
border-radius: var(--border-radius);
|
|
75
|
+
padding: 1px;
|
|
76
|
+
inset: 0;
|
|
77
|
+
|
|
78
|
+
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
79
|
+
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
80
|
+
mask-composite: exclude;
|
|
81
|
+
|
|
82
|
+
background-size: 300% 300%;
|
|
83
|
+
background-image: radial-gradient(
|
|
84
|
+
transparent,
|
|
85
|
+
transparent,
|
|
86
|
+
var(--color-from),
|
|
87
|
+
var(--color-middle),
|
|
88
|
+
var(--color-to),
|
|
89
|
+
transparent,
|
|
90
|
+
transparent
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
animation: shine-pulse var(--animation-duration) infinite linear;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.paused::before {
|
|
97
|
+
animation-play-state: paused;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@keyframes shine-pulse {
|
|
103
|
+
0% {
|
|
104
|
+
background-position: 0 0;
|
|
105
|
+
content: '';
|
|
106
|
+
}
|
|
107
|
+
50% {
|
|
108
|
+
background-position: 100% 100%;
|
|
109
|
+
content: '';
|
|
110
|
+
}
|
|
111
|
+
100% {
|
|
112
|
+
background-position: 0 0;
|
|
113
|
+
content: '';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
</style>
|
|
117
|
+
|
|
118
|
+
<script>
|
|
119
|
+
(() => {
|
|
120
|
+
const borders = document.querySelectorAll<HTMLElement>('[data-om-shine-border]');
|
|
121
|
+
if (!borders.length) return;
|
|
122
|
+
|
|
123
|
+
borders.forEach((border) => {
|
|
124
|
+
const borderEl = border.querySelector<HTMLElement>('[data-om-shine-border-border]')!;
|
|
125
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
126
|
+
borderEl.classList.toggle('paused', !entry.isIntersecting);
|
|
127
|
+
});
|
|
128
|
+
observer.observe(border);
|
|
129
|
+
});
|
|
130
|
+
})();
|
|
131
|
+
</script>
|