This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
generated from hay-kot/go-web-template
-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter details for zero values (#364)
* filter details for zero values * ensure exhaustive checks * update event listener to only bind when collapsable
- Loading branch information
Showing
3 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,46 @@ | ||
<template> | ||
<div class="card bg-base-100 shadow-xl sm:rounded-lg"> | ||
<div v-if="$slots.title" class="px-4 py-5 sm:px-6"> | ||
<h3 class="text-lg font-medium leading-6"> | ||
<slot name="title"></slot> | ||
</h3> | ||
<p v-if="$slots.subtitle" class="mt-1 max-w-2xl text-sm text-gray-500"> | ||
<slot name="subtitle"></slot> | ||
</p> | ||
<template v-if="$slots['title-actions']"> | ||
<slot name="title-actions"></slot> | ||
</template> | ||
<component :is="collapsable ? 'button' : 'div'" v-on="collapsable ? { click: toggle } : {}"> | ||
<h3 class="text-lg font-medium leading-6 flex items-center"> | ||
<slot name="title"></slot> | ||
<template v-if="collapsable"> | ||
<span class="ml-2 swap swap-rotate" :class="`${collapsed ? 'swap-active' : ''}`"> | ||
<Icon class="h-6 w-6 swap-on" name="mdi-chevron-right" /> | ||
<Icon class="h-6 w-6 swap-off" name="mdi-chevron-down" /> | ||
</span> | ||
</template> | ||
</h3> | ||
</component> | ||
<div> | ||
<p v-if="$slots.subtitle" class="mt-1 max-w-2xl text-sm text-gray-500"> | ||
<slot name="subtitle"></slot> | ||
</p> | ||
<template v-if="$slots['title-actions']"> | ||
<slot name="title-actions"></slot> | ||
</template> | ||
</div> | ||
</div> | ||
<div | ||
:class="{ | ||
'max-h-screen': !collapsed, | ||
'max-h-0': collapsed, | ||
}" | ||
class="transition-[max-height] duration-200 overflow-hidden" | ||
> | ||
<slot /> | ||
</div> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
defineProps<{ | ||
collapsable?: boolean; | ||
}>(); | ||
function toggle() { | ||
collapsed.value = !collapsed.value; | ||
} | ||
const collapsed = ref(false); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters