3
3
export let action_label;
4
4
export let color = " #00D690" ;
5
5
let contrastedColor = ' ' ;
6
-
7
- onMount (async () => {
8
- const fontColorContrast = (await import (' font-color-contrast' )).default ;
9
- contrastedColor = fontColorContrast (color);
10
- });
6
+ function darkenColor (hex , percent ) {
7
+ const num = parseInt (hex .slice (1 ), 16 ),
8
+ amt = Math .round (2.55 * percent),
9
+ R = (num >> 16 ) - amt,
10
+ G = (num >> 8 & 0x00FF ) - amt,
11
+ B = (num & 0x0000FF ) - amt;
12
+ return ` #${ (
13
+ 0x1000000 +
14
+ (R < 255 ? (R < 0 ? 0 : R ) : 255 ) * 0x10000 +
15
+ (G < 255 ? (G < 0 ? 0 : G ) : 255 ) * 0x100 +
16
+ (B < 255 ? (B < 0 ? 0 : B ) : 255 )
17
+ )
18
+ .toString (16 )
19
+ .slice (1 )} ` ;
20
+ }
21
+ let darkerColor = darkenColor (color, 7 );
22
+ onMount (async () => {
23
+ const fontColorContrast = (await import (' font-color-contrast' )).default ;
24
+ contrastedColor = fontColorContrast (color);
25
+ });
11
26
</script >
12
27
13
- <button class ="Button min-w-[137px] h-12 px-6 py-2 rounded-3xl justify-center items-center inline-flex" style ={
28
+ <button class ="Button min-w-[137px] h-12 px-6 py-2 rounded-3xl justify-center items-center inline-flex hover:bg-white/75 transition ease-in duration-150 " style ={
14
29
` background-color: ${color };
15
- color: ${contrastedColor } `
16
- }>
30
+ color: ${contrastedColor }; `
31
+ } onMouseOver = "this.style.backgroundColor=' { darkerColor } '" onMouseOut = "this.style.backgroundColor=' { color } '" >
17
32
<span class ="Button text-base font-['Albert Sans'] uppercase leading-normal font-bold" > {action_label }</span >
18
33
</button >
0 commit comments