alpinejs-ripple 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +182 -2
- package/dist/ripple.css +1 -0
- package/dist/ripple.esm.js +1 -0
- package/dist/ripple.min.js +1 -0
- package/package.json +22 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 reafeichtinger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,183 @@
|
|
|
1
|
-
#
|
|
1
|
+
# alpinejs-ripple
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
A simple yet powerful alpinejs directive to add ripple effects to any element using the `::before` or `::after` css selectors. No new elements are added to the DOM making this very stable. Simply use the directive `x-ripple` on any HTML element.
|
|
9
|
+
|
|
10
|
+
The package is minimal and simple. We are using the following css classes so make sure you are not overwriting them by accident:
|
|
11
|
+
|
|
12
|
+
- `.ripple`
|
|
13
|
+
- `.ripple-before`
|
|
14
|
+
- `.ripple-after`
|
|
15
|
+
- `.ripple--active`
|
|
16
|
+
|
|
17
|
+
This package has been developed for [bellisUI](https://bellis-ui.com/docs/ripple) but it can be used standalone as it is just an alpinejs plugin.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
### With a CDN
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script defer src="https://unpkg.com/alpinejs-ripple@latest/dist/ripple.min.js"></script>
|
|
25
|
+
<link rel="stylesheet" href="https://unpkg.com/alpinejs-ripple@latest/dist/ripple.css">
|
|
26
|
+
|
|
27
|
+
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### With a Package Manager
|
|
31
|
+
|
|
32
|
+
Choose whatever package manager you use.
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
npm install alpinejs-ripple
|
|
36
|
+
|
|
37
|
+
yarn add alpinejs-ripple
|
|
38
|
+
|
|
39
|
+
pnpm add alpinejs-ripple
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then load the Alpine plugin in your main javascript file.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import Alpine from 'alpinejs'
|
|
46
|
+
import Ripple from 'alpinejs-ripple'
|
|
47
|
+
import 'alpinejs-ripple/dist/ripple.css' // Optional css import via js
|
|
48
|
+
|
|
49
|
+
Alpine.plugin(Ripple)
|
|
50
|
+
|
|
51
|
+
Alpine.start()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can also import the css separately. This is NOT NEEDED if you already imported it via cdn or javascript.
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
@import 'alpinejs-ripple/dist/ripple.css';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Examples
|
|
61
|
+
|
|
62
|
+
You can find a full example in the [index.html](./index.html) file.
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<img alt="A default example of the ripple effect on a button click." src="./media/preview.gif" height="128" title="Default example">
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
### Default usage
|
|
69
|
+
|
|
70
|
+
We are using sensible defaults that look good out of the box.
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<button x-ripple></button>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Custom duration
|
|
77
|
+
|
|
78
|
+
You can customize the duration in seconds or milliseconds.
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<button x-ripple.duration.2s>2 Seconds</button>
|
|
82
|
+
<button x-ripple.duration.1_5s>1.5 Seconds</button>
|
|
83
|
+
<button x-ripple.duration.250ms>250 Milliseconds</button>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Custom radius
|
|
87
|
+
|
|
88
|
+
You can customize the border radius in px, rem or %.
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<button x-ripple.radius.0px>0 Pixel</button>
|
|
92
|
+
<button x-ripple.radius.3rem>3 Rem</button>
|
|
93
|
+
<button x-ripple.radius.25%>25 Percent</button>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Custom color
|
|
97
|
+
|
|
98
|
+
You can customize the color with builtin colors, hex or variables.
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<button x-ripple.color.red>Builtin color</button>
|
|
102
|
+
<button x-ripple.color.#f00>Short hex</button>
|
|
103
|
+
<button x-ripple.color.#ff0000>Long hex</button>
|
|
104
|
+
<button x-ripple.color.--some-color>Variable</button>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Custom opacity
|
|
108
|
+
|
|
109
|
+
You can customize the opacity.
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<button x-ripple.opacity.0>Invisible</button>
|
|
113
|
+
<button x-ripple.opacity.0_5>50% Visible</button>
|
|
114
|
+
<button x-ripple.opacity.1>100% Visible</button>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Custom animation timing
|
|
118
|
+
|
|
119
|
+
You can customize the animation timing function.
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<button x-ripple.timing.ease>ease</button>
|
|
123
|
+
<button x-ripple.timing.ease-in>ease-in</button>
|
|
124
|
+
<button x-ripple.timing.ease-out>ease-out</button>
|
|
125
|
+
<button x-ripple.timing.ease-in-out>ease-in-out</button>
|
|
126
|
+
<button x-ripple.timing.linear>linear</button>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Using ::before instead of ::after
|
|
130
|
+
|
|
131
|
+
By default the ripple is placed in the ::after pseudo-element. If that is already used by your element you can switch to ::before instead.
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<button x-ripple.before>ease</button>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
### Customizing via css variables
|
|
139
|
+
|
|
140
|
+
All modifiers can also be set via css by setting the respective variable. This allows you to set global defaults or regional ones.
|
|
141
|
+
|
|
142
|
+
Global default:
|
|
143
|
+
```css
|
|
144
|
+
* {
|
|
145
|
+
--ripple-duration: 2s;
|
|
146
|
+
--ripple-radius: 100px;
|
|
147
|
+
--ripple-color: red;
|
|
148
|
+
--ripple-timing: linear;
|
|
149
|
+
--ripple-opacity: 1;
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Regional default:
|
|
154
|
+
```html
|
|
155
|
+
<div style="
|
|
156
|
+
--ripple-duration: 2s; --ripple-radius: 100px; --ripple-color: red;
|
|
157
|
+
--ripple-timing: linear; --ripple-opacity: 1;">
|
|
158
|
+
...
|
|
159
|
+
<button x-ripple>Some buton</button>
|
|
160
|
+
...
|
|
161
|
+
</div>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Local:
|
|
165
|
+
```html
|
|
166
|
+
<button x-ripple style="
|
|
167
|
+
--ripple-duration: 2s; --ripple-radius: 100px; --ripple-color: red;
|
|
168
|
+
--ripple-timing: linear; --ripple-opacity: 1;">
|
|
169
|
+
Some buton
|
|
170
|
+
</button>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Contributing
|
|
174
|
+
|
|
175
|
+
1. Clone the repository.
|
|
176
|
+
2. Run `npm install`.
|
|
177
|
+
3. Make whatever changes you want.
|
|
178
|
+
4. Run `npm run build` to build your changed files.
|
|
179
|
+
5. Either use the build files directly or use something like [vercel/serve](https://www.npmjs.com/package/serve) to locally test your changes.
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
package/dist/ripple.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ripple{position:relative;overflow:hidden;-webkit-tap-highlight-color:transparent}.ripple-before:before,.ripple-after:after{content:"";position:absolute;left:var(--ripple-x, 50%);top:var(--ripple-y, 50%);width:var(--ripple-d, 200px);height:var(--ripple-d, 200px);border-radius:var(--ripple-radius, 50%);background:var(--ripple-color, currentColor);opacity:0;transform:translate(-50%,-50%) scale(0);pointer-events:none;transition:none}.ripple-before.ripple--active:before,.ripple-after.ripple--active:after{animation:ripple var(--ripple-duration, .6s) var(--ripple-timing, cubic-bezier(.4, 0, .2, 1)) forwards}@keyframes ripple{0%{transform:translate(-50%,-50%) scale(0);opacity:var(--ripple-opacity, .35)}to{transform:translate(-50%,-50%) scale(1);opacity:0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(u){u.directive("ripple",(e,{modifiers:y},{cleanup:v})=>{function g(t){if(typeof t!="string")return t;let n=t;return(t.startsWith("#")||t.startsWith("_"))&&(n=`#${t.substring(1)}`),n}function h(t){let n=new Set(["duration","radius","color","timing","opacity"]),r={},c=!1;for(let o=0;o<t.length;o++){if(t[o]==="before"){c=!0;continue}if(n.has(t[o])&&o+1<t.length){let d=t[o+1];r[t[o]]=t[o]==="color"?g(d):d,o++}}return{options:r,useBefore:c}}e.classList.add("ripple");let{options:i,useBefore:L}=h(y);if(e.classList.add(L?"ripple-before":"ripple-after"),i.duration&&e.style.setProperty("--ripple-duration",i.duration.replace(/_/g,".")),i.radius&&e.style.setProperty("--ripple-radius",i.radius.replace(/_/g,".")),i.color){let t;i.color.startsWith("--")?t=`var(${i.color})`:t=i.color,e.style.setProperty("--ripple-color",t)}i.timing&&e.style.setProperty("--ripple-timing",i.timing),i.opacity&&e.style.setProperty("--ripple-opacity",i.opacity.replace(/_/g,"."));let s,p,l;function a(t,n){let r=e.getBoundingClientRect();e.style.setProperty("--ripple-x",`${t===null?r.width/2:t-r.left}px`),e.style.setProperty("--ripple-y",`${n===null?r.height/2:n-r.top}px`),e.style.setProperty("--ripple-d",`${Math.hypot(r.width,r.height)*2}px`),e.classList.remove("ripple--active"),e.offsetWidth,e.classList.add("ripple--active")}s=t=>{t.button===0&&a(t.clientX,t.clientY)},p=t=>{t.detail===0&&a(null,null)},l=()=>{e.classList.remove("ripple--active")},e.addEventListener("pointerdown",s),e.addEventListener("click",p),e.addEventListener("animationend",l),v(()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("click",p),e.removeEventListener("animationend",l),e.classList.remove("ripple--active"),e.classList.remove("ripple"),e.classList.remove("ripple-before"),e.classList.remove("ripple-after")})})}var x=f;export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{function f(u){u.directive("ripple",(e,{modifiers:y},{cleanup:v})=>{function g(t){if(typeof t!="string")return t;let n=t;return(t.startsWith("#")||t.startsWith("_"))&&(n=`#${t.substring(1)}`),n}function L(t){let n=new Set(["duration","radius","color","timing","opacity"]),r={},c=!1;for(let o=0;o<t.length;o++){if(t[o]==="before"){c=!0;continue}if(n.has(t[o])&&o+1<t.length){let d=t[o+1];r[t[o]]=t[o]==="color"?g(d):d,o++}}return{options:r,useBefore:c}}e.classList.add("ripple");let{options:i,useBefore:h}=L(y);if(e.classList.add(h?"ripple-before":"ripple-after"),i.duration&&e.style.setProperty("--ripple-duration",i.duration.replace(/_/g,".")),i.radius&&e.style.setProperty("--ripple-radius",i.radius.replace(/_/g,".")),i.color){let t;i.color.startsWith("--")?t=`var(${i.color})`:t=i.color,e.style.setProperty("--ripple-color",t)}i.timing&&e.style.setProperty("--ripple-timing",i.timing),i.opacity&&e.style.setProperty("--ripple-opacity",i.opacity.replace(/_/g,"."));let p,s,l;function a(t,n){let r=e.getBoundingClientRect();e.style.setProperty("--ripple-x",`${t===null?r.width/2:t-r.left}px`),e.style.setProperty("--ripple-y",`${n===null?r.height/2:n-r.top}px`),e.style.setProperty("--ripple-d",`${Math.hypot(r.width,r.height)*2}px`),e.classList.remove("ripple--active"),e.offsetWidth,e.classList.add("ripple--active")}p=t=>{t.button===0&&a(t.clientX,t.clientY)},s=t=>{t.detail===0&&a(null,null)},l=()=>{e.classList.remove("ripple--active")},e.addEventListener("pointerdown",p),e.addEventListener("click",s),e.addEventListener("animationend",l),v(()=>{e.removeEventListener("pointerdown",p),e.removeEventListener("click",s),e.removeEventListener("animationend",l),e.classList.remove("ripple--active"),e.classList.remove("ripple"),e.classList.remove("ripple-before"),e.classList.remove("ripple-after")})})}document.addEventListener("alpine:init",()=>window.Alpine.plugin(f));})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alpinejs-ripple",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A simple yet powerful alpinejs directive to add ripple effects to any element using the ::before or ::after css selectors.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Alpine",
|
|
7
|
+
"Alpine JS",
|
|
8
|
+
"Alpine JS Plugin",
|
|
9
|
+
"Alpine JS Plugins",
|
|
10
|
+
"Ripple",
|
|
11
|
+
"Ripple Effect",
|
|
12
|
+
"CSS"
|
|
13
|
+
],
|
|
14
|
+
"module": "dist/ripple.esm.js",
|
|
15
|
+
"unpkg": "dist/ripple.min.js",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "node scripts/build.js"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"esbuild": "^0.25.0"
|
|
24
|
+
}
|
|
6
25
|
}
|