refactor(ui): replaced some n-input with c-input-text

This commit is contained in:
Corentin Thomasset 2023-05-15 00:41:45 +02:00 committed by Corentin THOMASSET
parent b3b6b7c46b
commit f7fc779e63
10 changed files with 189 additions and 226 deletions

View file

@ -1,37 +1,37 @@
<template>
<div>
<n-form-item label="MAC address:" v-bind="validationAttrs as any">
<n-input
v-model:value="macAddress"
size="large"
placeholder="Type a MAC address"
clearable
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
</n-form-item>
<c-input-text
v-model:value="macAddress"
label="MAC address:"
size="large"
placeholder="Type a MAC address"
clearable
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
:validation-rules="macAddressValidationRules"
mb-5
/>
<n-form-item label="Vendor info:">
<c-card>
<n-text v-if="details">
<div v-for="(detail, index) of details.split('\n')" :key="index">{{ detail }}</div>
</n-text>
<div mb-5px>Vendor info:</div>
<c-card mb-5>
<div v-if="details">
<div v-for="(detail, index) of details.split('\n')" :key="index">{{ detail }}</div>
</div>
<n-text v-else depth="3" italic>Unknown vendor for this address</n-text>
</c-card>
</n-form-item>
<div v-else italic op-60>Unknown vendor for this address</div>
</c-card>
<n-space justify="center">
<div flex justify-center>
<c-button :disabled="!details" @click="copy"> Copy vendor info </c-button>
</n-space>
</div>
</div>
</template>
<script setup lang="ts">
import db from 'oui/oui.json';
import { macAddressValidation } from '@/utils/macAddress';
import { macAddressValidationRules } from '@/utils/macAddress';
import { useCopy } from '@/composable/copy';
const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '').toUpperCase().substring(0, 6);
@ -39,8 +39,6 @@ const getVendorValue = (address: string) => address.trim().replace(/[.:-]/g, '')
const macAddress = ref('20:37:06:12:34:56');
const details = computed<string | undefined>(() => db[getVendorValue(macAddress.value)]);
const { attrs: validationAttrs } = macAddressValidation(macAddress);
const { copy } = useCopy({ source: details, text: 'Vendor info copied to the clipboard' });
</script>