Remove unused var and fix button ui margin

pull/1/head
fadhlu 2021-03-19 17:28:01 +07:00
parent 6eef67d5da
commit 5041cc7a2c
2 changed files with 5 additions and 7 deletions

View File

@ -7,14 +7,13 @@
import Input from '../../components/Input.svelte'; import Input from '../../components/Input.svelte';
import { time } from '../../stores/time'; import { time } from '../../stores/time';
let changed = false; let changed = true;
let currentResin = ''; let currentResin = '';
let desiredResin = ''; let desiredResin = '';
let maxResin = 160; let maxResin = 160;
let millisecondsToWait; let millisecondsToWait;
let fullTime = null; let fullTime = null;
let missingResin = 160; let missingResin = 160;
let showResult = false;
let resinTypeOutput = ''; let resinTypeOutput = '';
let resinOutput = ''; let resinOutput = '';
@ -36,7 +35,7 @@
}; };
$: isCurrentResin = currentResin >= 0 && currentResin < 160 && currentResin !== ''; $: isCurrentResin = currentResin >= 0 && currentResin < 160 && currentResin !== '';
$: isDesiredResin = desiredResin <= 160 && desiredResin >= 1 && desiredResin === ''; $: isDesiredResin = desiredResin <= 160 && desiredResin >= 1 && desiredResin !== '';
$: canCalculate = isCurrentResin || isDesiredResin; $: canCalculate = isCurrentResin || isDesiredResin;
function calculate() { function calculate() {
@ -44,12 +43,11 @@
resinOutput = resinTypeOutput === 'maxResin' ? missingResin : desiredResin; resinOutput = resinTypeOutput === 'maxResin' ? missingResin : desiredResin;
millisecondsToWait = resinTypeOutput === 'maxResin' ? missingResin * minutePerResin : desiredResin * minutePerResin; millisecondsToWait = resinTypeOutput === 'maxResin' ? missingResin * minutePerResin : desiredResin * minutePerResin;
fullTime = new Date($time.getTime() + millisecondsToWait); fullTime = new Date($time.getTime() + millisecondsToWait);
showResult = true; changed = false;
} }
function onChange(type) { function onChange(type) {
changed = true; changed = true;
showResult = false;
resinTypeOutput = type; resinTypeOutput = type;
} }
</script> </script>
@ -89,7 +87,7 @@
<Button disabled={!canCalculate} className="block w-full md:w-auto" on:click={calculate} <Button disabled={!canCalculate} className="block w-full md:w-auto" on:click={calculate}
>{$t('calculator.resin.calculate')}</Button >{$t('calculator.resin.calculate')}</Button
> >
{#if showResult} {#if !changed}
<div transition:fade={{ duration: 100 }} class="bg-background rounded-xl p-4 mt-2 block xl:inline-block"> <div transition:fade={{ duration: 100 }} class="bg-background rounded-xl p-4 mt-2 block xl:inline-block">
<tr> <tr>
<td class="text-right border-b border-gray-700 py-1"> <td class="text-right border-b border-gray-700 py-1">

View File

@ -92,7 +92,7 @@
{$t('calculator.goto')} {$t('calculator.goto')}
{$t('calculator.titleWeapon')} {$t('calculator.titleWeapon')}
</Button> </Button>
<Button className="md:mb-0 md:ml-4 mb-4" on:click={() => findPos('resin')}> <Button className="md:mt-0 md:mr-4 mt-4" on:click={() => findPos('resin')}>
<Icon size={0.8} path={mdiArrowDown} /> <Icon size={0.8} path={mdiArrowDown} />
{$t('calculator.goto')} {$t('calculator.goto')}
{$t('calculator.titleResin')} {$t('calculator.titleResin')}