diff options
author | 2023-04-14 01:20:47 +0200 | |
---|---|---|
committer | 2023-04-14 09:04:49 +0200 | |
commit | 8355bd2ae48954115d132dd42a40b1d3de1d9b2e (patch) | |
tree | a903f4560dcef8dcad351df61b05dd9f0a0d0c6e /src/tools/http-status-codes/http-status-codes.vue | |
parent | 6fb49946031dc093499e826bc228dbbff97e2db9 (diff) | |
download | it-tools-8355bd2ae48954115d132dd42a40b1d3de1d9b2e.tar.gz it-tools-8355bd2ae48954115d132dd42a40b1d3de1d9b2e.tar.zst it-tools-8355bd2ae48954115d132dd42a40b1d3de1d9b2e.zip |
feat(new-tool): http status codes
Diffstat (limited to 'src/tools/http-status-codes/http-status-codes.vue')
-rw-r--r-- | src/tools/http-status-codes/http-status-codes.vue | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/tools/http-status-codes/http-status-codes.vue b/src/tools/http-status-codes/http-status-codes.vue new file mode 100644 index 0000000..48bd77f --- /dev/null +++ b/src/tools/http-status-codes/http-status-codes.vue @@ -0,0 +1,60 @@ +<template> + <div> + <n-form-item :show-label="false"> + <n-input + v-model:value="search" + placeholder="Search http status..." + size="large" + autofocus + mb-10 + autocomplete="off" + autocorrect="off" + autocapitalize="off" + > + <template #prefix> + <n-icon :component="SearchRound" /> + </template> + </n-input> + </n-form-item> + + <div v-for="{ codes, category } of codesByCategoryFiltered" :key="category" mb-8> + <n-h2> {{ category }} </n-h2> + + <n-space vertical :size="20"> + <n-card v-for="{ code, description, name, type } of codes" :key="code"> + <n-space align="center"> + <n-text strong text-lg> {{ code }} {{ name }} </n-text> + </n-space> + <n-text depth="3">{{ description }} {{ type !== 'HTTP' ? `For ${type}.` : '' }}</n-text> + </n-card> + </n-space> + </div> + </div> +</template> + +<script setup lang="ts"> +import { useFuzzySearch } from '@/composable/fuzzySearch'; +import _ from 'lodash'; +import { SearchRound } from '@vicons/material'; +import { codesByCategories } from './http-status-codes.constants'; + +const search = ref(''); + +const { searchResult } = useFuzzySearch({ + search, + data: codesByCategories.flatMap(({ codes, category }) => codes.map((code) => ({ ...code, category }))), + options: { + keys: [{ name: 'code', weight: 3 }, { name: 'name', weight: 2 }, 'description', 'category'], + }, +}); + +const codesByCategoryFiltered = computed(() => { + if (!search.value) { + return codesByCategories; + } + + return [{ category: 'Search results', codes: searchResult.value }]; +}); +</script> + +<style lang="less" scoped></style> |