aboutsummaryrefslogtreecommitdiff
path: root/src/tools/url-parser/url-parser.vue
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-05-14 21:26:18 +0200
committerGravatar Corentin THOMASSET <corentin.thomasset74@gmail.com> 2023-05-14 22:30:23 +0200
commit77f2efc0b92847c3b1198446f4b520ecb2263164 (patch)
tree942ea5ffd922dbe7a9913e235a4fae17b117c925 /src/tools/url-parser/url-parser.vue
parentaad8d84e13ce31c1b7c1cbb930fb8bd4c0abe13a (diff)
downloadit-tools-77f2efc0b92847c3b1198446f4b520ecb2263164.tar.gz
it-tools-77f2efc0b92847c3b1198446f4b520ecb2263164.tar.zst
it-tools-77f2efc0b92847c3b1198446f4b520ecb2263164.zip
refactor(ui): replaced some n-input with c-input-text
Diffstat (limited to 'src/tools/url-parser/url-parser.vue')
-rw-r--r--src/tools/url-parser/url-parser.vue70
1 files changed, 39 insertions, 31 deletions
diff --git a/src/tools/url-parser/url-parser.vue b/src/tools/url-parser/url-parser.vue
index ac80f61..04ab939 100644
--- a/src/tools/url-parser/url-parser.vue
+++ b/src/tools/url-parser/url-parser.vue
@@ -1,51 +1,59 @@
<template>
<c-card>
- <n-form-item label="Your url to parse:" :feedback="validation.message" :validation-status="validation.status">
- <n-input v-model:value="urlToParse" placeholder="Your url to parse..." />
- </n-form-item>
+ <c-input-text
+ v-model:value="urlToParse"
+ label="Your url to parse:"
+ placeholder="Your url to parse..."
+ raw-text
+ :validation-rules="urlValidationRules"
+ />
- <n-divider style="margin-top: 0" />
+ <n-divider />
- <n-form>
- <n-input-group v-for="{ title, key } in properties" :key="key">
- <n-input-group-label style="flex: 0 0 120px"> {{ title }}: </n-input-group-label>
- <input-copyable :value="(urlParsed?.[key] as string) ?? ''" readonly placeholder=" " />
- </n-input-group>
+ <input-copyable
+ v-for="{ title, key } in properties"
+ :key="key"
+ :label="title"
+ :value="(urlParsed?.[key] as string) ?? ''"
+ readonly
+ label-position="left"
+ label-width="110px"
+ mb-2
+ placeholder=" "
+ />
- <n-input-group
- v-for="[k, v] in Object.entries(Object.fromEntries(urlParsed?.searchParams.entries() ?? []))"
- :key="k"
- >
- <n-input-group-label style="flex: 0 0 120px">
- <n-icon :component="SubdirectoryArrowRightRound" />
- </n-input-group-label>
- <input-copyable :value="k" readonly />
- <input-copyable :value="v" readonly />
- </n-input-group>
- </n-form>
+ <div
+ v-for="[k, v] in Object.entries(Object.fromEntries(urlParsed?.searchParams.entries() ?? []))"
+ :key="k"
+ mb-2
+ w-full
+ flex
+ >
+ <div style="flex: 1 0 110px">
+ <icon-mdi-arrow-right-bottom />
+ </div>
+
+ <input-copyable :value="k" readonly />
+ <input-copyable :value="v" readonly />
+ </div>
</c-card>
</template>
<script setup lang="ts">
-import { useValidation } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
-import { SubdirectoryArrowRightRound } from '@vicons/material';
import { computed, ref } from 'vue';
import InputCopyable from '../../components/InputCopyable.vue';
const urlToParse = ref('https://me:pwd@it-tools.tech:3000/url-parser?key1=value&key2=value2#the-hash');
const urlParsed = computed(() => withDefaultOnError(() => new URL(urlToParse.value), undefined));
-const validation = useValidation({
- source: urlToParse,
- rules: [
- {
- validator: (value) => isNotThrowing(() => new URL(value)),
- message: 'Invalid url',
- },
- ],
-});
+const urlValidationRules = [
+ {
+ validator: (value: string) => isNotThrowing(() => new URL(value)),
+ message: 'Invalid url',
+ },
+];
const properties: { title: string; key: keyof URL }[] = [
{ title: 'Protocol', key: 'protocol' },