Add frontend 2.0
This commit is contained in:
18
frontend/src/lib/randomlabel.ts
Normal file
18
frontend/src/lib/randomlabel.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { readonly, ref } from 'vue';
|
||||
|
||||
export function randomLabel(options: string[]) {
|
||||
const label = ref<string>();
|
||||
const randomLabel = () => {
|
||||
let newLabel;
|
||||
do {
|
||||
newLabel = options[Math.floor(Math.random() * options.length)];
|
||||
} while (newLabel === label.value);
|
||||
return newLabel;
|
||||
};
|
||||
label.value = randomLabel();
|
||||
|
||||
return {
|
||||
label: readonly(label),
|
||||
update: () => (label.value = randomLabel()),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user