This commit is contained in:
2023-07-26 16:02:54 +02:00
parent fb0143f5e4
commit a08c9782eb
2 changed files with 34 additions and 12 deletions

32
src/BuySellSlider.vue Normal file
View File

@@ -0,0 +1,32 @@
<script setup lang="ts">
import { useVModel } from '@vueuse/core';
interface Props {
modelValue?: boolean;
}
interface Emits {
(e: 'update:modelValue', value: boolean): void;
}
const props = withDefaults(defineProps<Props>(), {
modelValue: false
});
const emit = defineEmits<Emits>();
const value = useVModel(props, 'modelValue', emit);
</script>
<template>
<label class="flex items-center relative w-max cursor-pointer select-none">
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-14 h-7 rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-black" v-model="value" />
<span class="absolute font-medium text-xs right-1 text-white"> Buy </span>
<span class="absolute font-medium text-xs right-8 text-white"> Sell </span>
<span class="w-7 h-7 right-7 absolute rounded-full transform transition-transform bg-gray-200" />
</label>
</template>
<style scoped>
input:checked ~ span:last-child {
--tw-translate-x: 1.75rem;
}
</style>

View File

@@ -1,4 +1,5 @@
<script setup lang="ts">
import BuySellSlider from '@/BuySellSlider.vue';
import { iskFormater, percentFormater } from '@/formaters';
import { useStorage } from '@vueuse/core';
import { computed, ref } from 'vue';
@@ -29,12 +30,7 @@ const copyToClipboard = (s: string) => navigator.clipboard.writeText(s);
<template>
<div class="grid grid-cols-2 mb-2 mt-4 ms-auto">
<div class="justify-self-end">
<label class="flex items-center relative w-max cursor-pointer select-none">
<input type="checkbox" class="appearance-none transition-colors cursor-pointer w-14 h-7 rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-black" v-model="useSellOrder" />
<span class="absolute font-medium text-xs right-1 text-white"> Buy </span>
<span class="absolute font-medium text-xs right-8 text-white"> Sell </span>
<span class="w-7 h-7 right-7 absolute rounded-full transform transition-transform bg-gray-200" />
</label>
<BuySellSlider v-model="useSellOrder" />
</div>
<div class="justify-self-end ms-2">
<span>Threshold: </span>
@@ -60,9 +56,3 @@ const copyToClipboard = (s: string) => navigator.clipboard.writeText(s);
</tbody>
</table>
</template>
<style scoped>
input:checked ~ span:last-child {
--tw-translate-x: 1.75rem;
}
</style>