File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
2
import { onMount } from ' svelte' ;
3
3
export let text = ' Badge' ;
4
- export let color = ' #0073F4' ;
4
+ export let color = getRandomHexColor ();
5
+ function getRandomHexColor () {
6
+ const letters = ' 0123456789ABCDEF' ;
7
+ let color = ' #' ;
8
+ for (let i = 0 ; i < 6 ; i++ ) {
9
+ color += letters[Math .floor (Math .random () * 16 )];
10
+ }
11
+ return color;
12
+ }
13
+ let contrastedColor = ' ' ;
5
14
6
-
7
- let contrastedColor = ' ' ;
8
-
9
- onMount (async () => {
10
- const fontColorContrast = (await import (' font-color-contrast' )).default ;
11
- contrastedColor = fontColorContrast (color);
12
- });
15
+ onMount (async () => {
16
+ const fontColorContrast = (await import (' font-color-contrast' )).default ;
17
+ contrastedColor = fontColorContrast (color);
18
+ });
13
19
</script >
14
20
15
21
You can’t perform that action at this time.
0 commit comments