Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from livraison-dev/tabs
Browse files Browse the repository at this point in the history
feat: add method tabs
  • Loading branch information
elonehoo authored Jan 10, 2024
2 parents ea1bdb5 + f6cce20 commit 9692476
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
50 changes: 50 additions & 0 deletions components/details/Details.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script setup lang="ts">
const activeTab = ref()
const tabs = computed(() => {
const items = []
items.push({
name: 'Params',
slug: 'params',
length: 0,
})
items.push({
name: 'Query',
slug: 'query',
length: 0,
})
items.push({
name: 'Body',
slug: 'body',
length: 0,
})
items.push({
name: 'Headers',
slug: 'headers',
length: 0,
})
items.push({
name: 'Cookies',
slug: 'cookies',
length: 0,
})
return items
})
</script>

<template>
<div flex="~ gap2 wrap" w-full items-center px4 pb2 text-center text-sm border="b" class="app-border-base">
<ButtonBase
v-for="tab of tabs"
:key="tab.slug"
:class="activeTab === tab.slug ? 'text-primary app-primary' : 'border-transparent shadow-none'"
@click="activeTab = tab.slug"
>
<Icon class="app-icon" :name="ServerRouteTabIcons[tab.slug]" />
<div class="hidden md:block">
{{ tab.name }}
{{ tab?.length ? `(${tab.length})` : '' }}
</div>
</ButtonBase>
</div>
</template>
7 changes: 7 additions & 0 deletions composables/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const ServerRouteTabIcons: Record<string, string> = {
headers: 'i-carbon-html-reference',
cookies: 'i-carbon-cookie',
params: 'i-carbon-text-selection',
query: 'i-carbon-help',
body: 'i-carbon-document',
}
3 changes: 3 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ const methodOptions = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS
<IconBase icon="carbon:send" />
</ButtonBase>
</div>
<div class="mt-3">
<Details />
</div>
</div>
</template>

0 comments on commit 9692476

Please sign in to comment.