11<template >
22 <!-- Size & interactivity come from parent classes -->
3- <div class =" scribble-badge relative isolate grid place-items-center" :style = " cssVars " >
3+ <div class =" scribble-badge relative isolate grid place-items-center" >
44 <!-- Put your number (or any content) here -->
55 <slot >0</slot >
66 </div >
77</template >
88
99<script setup>
10- const props = defineProps ({
11- maskUrl: {
12- type: String ,
13- default: ' pattern-square.svg'
14- }
15- });
16-
17- const { app } = useRuntimeConfig ();
18- const baseURL = app .baseURL || ' /' ;
19-
20- // Construct the full pattern URL
21- const fullMaskPath = props .maskUrl .startsWith (' http' ) || props .maskUrl .startsWith (' /' )
22- ? props .maskUrl
23- : ` ${ baseURL} images/${ props .maskUrl } ` .replace (/ \/ + / g , ' /' );
24-
25- const patternUrl = ` ${ baseURL} images/pattern-square.svg` .replace (/ \/ + / g , ' /' );
26-
27- const cssVars = {
28- ' --pattern-url' : ` url("${ patternUrl} ")` ,
29- ' --mask-url' : ` url("${ fullMaskPath} ")`
30- };
10+ // no props needed — style via classes on the component usage
3111 </script >
3212
3313<style scoped>
3414/* Apply the mask to the host element so regular backgrounds get clipped too */
3515.scribble-badge {
36- -webkit-mask-image : var (--mask-url , var ( -- pattern-url ));
37- mask-image : var (--mask-url , var ( -- pattern-url ));
16+ -webkit-mask-image : var (--mask-url , url ( " /images/ pattern-square.svg " ));
17+ mask-image : var (--mask-url , url ( " /images/ pattern-square.svg " ));
3818 -webkit-mask-repeat : no-repeat ;
3919 mask-repeat : no-repeat ;
4020 -webkit-mask-position : var (--mask-position , center );
@@ -52,8 +32,8 @@ const cssVars = {
5232 pointer-events : none ;
5333
5434 /* Mask shape (user can override URL via a CSS var) */
55- -webkit-mask-image : var (--mask-url , var ( -- pattern-url ));
56- mask-image : var (--mask-url , var ( -- pattern-url ));
35+ -webkit-mask-image : var (--mask-url , url ( " /images/ pattern-square.svg " ));
36+ mask-image : var (--mask-url , url ( " /images/ pattern-square.svg " ));
5737 -webkit-mask-repeat : no-repeat ;
5838 mask-repeat : no-repeat ;
5939 -webkit-mask-position : var (--mask-position , center );
0 commit comments