11<div class =" max-w-7xl mx-auto py-3 px-6" x-data =" sMultisite.sPinner('domain{{ ucfirst ($item -> key )} } ')" >
22 <div class =" s-meta-block-head" >
3- <span @click =" togglePin " class =" s-meta-block-btn bg-[var(--brand-accent)]" @if (trim ($domain -> site_color ?? ' ' ) ) @style ([' background-color: ' . $domain -> site_color ] ) @endif >
3+ <span @click =" toggle() " class =" s-meta-block-btn bg-[var(--brand-accent)]" @if (trim ($domain -> site_color ?? ' ' ) ) @style ([' background-color: ' . $domain -> site_color ] ) @endif >
44 <div class =" flex items-center gap-2" >
55 <svg data-lucide =" link-2" class =" w-5 h-5 text-[var(--brand-color)]" ></svg >
66 <span class =" font-semibold text-base text-slate-700 darkness:text-slate-200" >{{ $item -> site_name ??' ' } } </span >
101101 </div >
102102 </div >
103103 </div >
104- </div >
104+ </div >
105+ @push (' scripts.bot' )
106+ <script >
107+ document .addEventListener (' DOMContentLoaded' , () => {
108+
109+ function getContrastColor (r , g , b ) {
110+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255 ;
111+ return luminance > 0.5 ? ' #0f172a' : ' #ffffff' ;
112+ }
113+
114+ function applyContrast (el ) {
115+ const bg = getComputedStyle (el).backgroundColor || ' ' ;
116+ const m = bg .match (/ rgba? \( (\d + ),\s * (\d + ),\s * (\d + )/ i );
117+
118+ if (! m) return ;
119+
120+ const r = parseInt (m[1 ], 10 );
121+ const g = parseInt (m[2 ], 10 );
122+ const b = parseInt (m[3 ], 10 );
123+
124+ el .style .color = getContrastColor (r, g, b);
125+ }
126+
127+ function run () {
128+ document .querySelectorAll (' .s-meta-block-btn' ).forEach (applyContrast);
129+ }
130+
131+ run ();
132+
133+ const observer = new MutationObserver (run);
134+ observer .observe (document .body , {
135+ subtree: true ,
136+ childList: true ,
137+ attributes: true ,
138+ attributeFilter: [' style' ]
139+ });
140+ });
141+ </script >
142+ @endpush
0 commit comments