mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00

* refactor(math-evaluator): added keywords for search * refactor(math-evaluator): improved input
28 lines
593 B
Vue
28 lines
593 B
Vue
<script setup lang="ts">
|
|
import { evaluate } from 'mathjs';
|
|
|
|
import { withDefaultOnError } from '@/utils/defaults';
|
|
|
|
const expression = ref('');
|
|
|
|
const result = computed(() => withDefaultOnError(() => evaluate(expression.value) ?? '', ''));
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<c-input-text
|
|
v-model:value="expression"
|
|
rows="1"
|
|
multiline
|
|
placeholder="Your math expression (ex: 2*sqrt(6) )..."
|
|
raw-text
|
|
monospace
|
|
autofocus
|
|
autosize
|
|
/>
|
|
|
|
<c-card v-if="result !== ''" title="Result " mt-5>
|
|
{{ result }}
|
|
</c-card>
|
|
</div>
|
|
</template>
|