You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
630 B

<script lang="ts">
export let value = "";
export let small = false;
let style = "";
$: {
let hash = 0;
for (let i = 0; i < value.length; i++) {
hash = value.charCodeAt(i) + ((hash << 5) - hash);
hash = hash & hash;
}
console.log(value, hash);
style = `color: hsl(${(hash << 4) % 360}, ${40 + (hash % 8)}%, ${50+(hash % 4)}%)`
}
</script>
<div style={style} class="tag" class:small>{value}</div>
<style>
div.tag {
padding: 0.25em 0.75ch;
margin: 0.25em 0.5ch;
font-size: 0.75em;
border: 1px solid;
}
div.tag.small {
padding: 0em 0.5ch;
}
</style>