Skip to content

Commit

Permalink
fix(slideout): add slots
Browse files Browse the repository at this point in the history
  • Loading branch information
aanchalm01 committed Jul 31, 2023
1 parent 838fb89 commit a33e44c
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions src/components/KSlideout/KSlideout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,47 @@
:class="hasOverlay ? 'panel-background' : 'panel-background-transparent'"
/>
</transition>
<transition
name="slide"
>
<transition name="slide">
<div
v-if="isVisible"
ref="slideOutRef"
class="panel"
:class="{ 'is-visible': isVisible, 'border-styles': !hasOverlay }"
>
<!-- If there is title prop or header slot, display the header content -->
<!-- title slot -->
<div
v-if="title || hasTitle"
class="k-slideout-header-content"
>
<slot name="header">
<slot name="title">
<p class="k-slideout-title">
{{ title }}
</p>
</slot>
</div>

<button
:class="closeButtonAlignment === 'start' ? 'close-button-start' : 'close-button-end'"
@click="(event: any) => emit('close')"
<!-- header custom slot -->
<div v-if="hasHeader">
<slot name="header" />
</div>

<!-- cancelButton slot -->
<slot
v-if="hasCancelButton"
name="cancelButton"
>
<KIcon
:color="`var(--kui-color-text-neutral-stronger, ${KUI_COLOR_TEXT_NEUTRAL_STRONGER})`"
icon="close"
:size="KUI_ICON_SIZE_50"
/>
</button>
<button
:class="closeButtonAlignment === 'start' ? 'close-button-start' : 'close-button-end'"
@click="(event: any) => emit('close')"
>
<KIcon
:color="`var(--kui-color-text-neutral-stronger, ${KUI_COLOR_TEXT_NEUTRAL_STRONGER})`"
icon="close"
:size="KUI_ICON_SIZE_50"
/>
</button>
</slot>

<div class="content">
<KCard border-variant="noBorder">
<template #body>
Expand Down Expand Up @@ -92,6 +102,8 @@ const emit = defineEmits<{
const slots = useSlots()
const hasTitle = computed((): boolean => !!slots.title)
const hasHeader = computed((): boolean => !!slots.header)
const hasCancelButton = computed((): boolean => !!slots.cancelButton)
const { getSizeFromString } = useUtilities()
const slideOutRef = ref(null)
Expand Down

0 comments on commit a33e44c

Please sign in to comment.