alpinejs-ripple 1.0.0 → 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 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,8 +1,9 @@
1
1
  # alpinejs-ripple
2
2
 
3
- ![](https://img.shields.io/npm/v/alpinejs-ripple)
4
- ![](https://img.shields.io/npm/dt/alpinejs-ripple)
5
- ![](https://img.shields.io/github/license/markmead/alpinejs-ripple)
3
+ ![Package version](https://img.shields.io/npm/v/alpinejs-ripple)
4
+ ![NPM Downloads](https://img.shields.io/npm/dy/alpinejs-ripple)
5
+ ![Package License](https://img.shields.io/github/license/reafeichtinger/alpinejs-ripple)
6
+ ![NPM package minimized gzipped size](https://img.shields.io/bundlejs/size/alpinejs-ripple)
6
7
 
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.
8
9
 
@@ -43,12 +44,19 @@ Then load the Alpine plugin in your main javascript file.
43
44
  ```js
44
45
  import Alpine from 'alpinejs'
45
46
  import Ripple from 'alpinejs-ripple'
47
+ import 'alpinejs-ripple/dist/ripple.css' // Optional css import via js
46
48
 
47
49
  Alpine.plugin(Ripple)
48
50
 
49
51
  Alpine.start()
50
52
  ```
51
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
+
52
60
  ## Examples
53
61
 
54
62
  You can find a full example in the [index.html](./index.html) file.
@@ -1 +1 @@
1
- function d(u){u.directive("ripple",(t,{modifiers:f},{cleanup:v})=>{function y(e){let p=new Set(["duration","radius","color","timing","opacity"]),r={},c=!1;for(let o=0;o<e.length;o++){if(e[o]==="before"){c=!0;continue}p.has(e[o])&&o+1<e.length&&(r[e[o]]=e[o+1],o++)}return{options:r,useBefore:c}}t.classList.add("ripple");let{options:i,useBefore:L}=y(f);if(t.classList.add(L?"ripple-before":"ripple-after"),i.duration&&t.style.setProperty("--ripple-duration",i.duration.replace(/_/g,".")),i.radius&&t.style.setProperty("--ripple-radius",i.radius.replace(/_/g,".")),i.color){let e=i.color.startsWith("--")?`var(${i.color})`:i.color;t.style.setProperty("--ripple-color",e)}i.timing&&t.style.setProperty("--ripple-timing",i.timing),i.opacity&&t.style.setProperty("--ripple-opacity",i.opacity.replace(/_/g,"."));let n,s,a;function l(e,p){let r=t.getBoundingClientRect();t.style.setProperty("--ripple-x",`${e===null?r.width/2:e-r.left}px`),t.style.setProperty("--ripple-y",`${p===null?r.height/2:p-r.top}px`),t.style.setProperty("--ripple-d",`${Math.hypot(r.width,r.height)*2}px`),t.classList.remove("ripple--active"),t.offsetWidth,t.classList.add("ripple--active")}n=e=>{e.button===0&&l(e.clientX,e.clientY)},s=e=>{e.detail===0&&l(null,null)},a=()=>{t.classList.remove("ripple--active")},t.addEventListener("pointerdown",n),t.addEventListener("click",s),t.addEventListener("animationend",a),v(()=>{t.removeEventListener("pointerdown",n),t.removeEventListener("click",s),t.removeEventListener("animationend",a),t.classList.remove("ripple--active"),t.classList.remove("ripple"),t.classList.remove("ripple-before"),t.classList.remove("ripple-after")})})}var m=d;export{m as default};
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};
@@ -1 +1 @@
1
- (()=>{function d(u){u.directive("ripple",(t,{modifiers:v},{cleanup:f})=>{function y(e){let n=new Set(["duration","radius","color","timing","opacity"]),r={},c=!1;for(let o=0;o<e.length;o++){if(e[o]==="before"){c=!0;continue}n.has(e[o])&&o+1<e.length&&(r[e[o]]=e[o+1],o++)}return{options:r,useBefore:c}}t.classList.add("ripple");let{options:i,useBefore:L}=y(v);if(t.classList.add(L?"ripple-before":"ripple-after"),i.duration&&t.style.setProperty("--ripple-duration",i.duration.replace(/_/g,".")),i.radius&&t.style.setProperty("--ripple-radius",i.radius.replace(/_/g,".")),i.color){let e=i.color.startsWith("--")?`var(${i.color})`:i.color;t.style.setProperty("--ripple-color",e)}i.timing&&t.style.setProperty("--ripple-timing",i.timing),i.opacity&&t.style.setProperty("--ripple-opacity",i.opacity.replace(/_/g,"."));let p,s,a;function l(e,n){let r=t.getBoundingClientRect();t.style.setProperty("--ripple-x",`${e===null?r.width/2:e-r.left}px`),t.style.setProperty("--ripple-y",`${n===null?r.height/2:n-r.top}px`),t.style.setProperty("--ripple-d",`${Math.hypot(r.width,r.height)*2}px`),t.classList.remove("ripple--active"),t.offsetWidth,t.classList.add("ripple--active")}p=e=>{e.button===0&&l(e.clientX,e.clientY)},s=e=>{e.detail===0&&l(null,null)},a=()=>{t.classList.remove("ripple--active")},t.addEventListener("pointerdown",p),t.addEventListener("click",s),t.addEventListener("animationend",a),f(()=>{t.removeEventListener("pointerdown",p),t.removeEventListener("click",s),t.removeEventListener("animationend",a),t.classList.remove("ripple--active"),t.classList.remove("ripple"),t.classList.remove("ripple-before"),t.classList.remove("ripple-after")})})}document.addEventListener("alpine:init",()=>window.Alpine.plugin(d));})();
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,7 +1,7 @@
1
1
  {
2
2
  "name": "alpinejs-ripple",
3
- "version": "1.0.0",
4
- "description": "DESCRIPTION",
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
5
  "keywords": [
6
6
  "Alpine",
7
7
  "Alpine JS",