Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KCheckbox description prop, simplified logic around slot vs label showing #199

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/KCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@
</div>

<div
v-if="!label && $slots.default"
v-if="$slots.default"
class="k-checkbox-label"
>
<!-- @slot Slot alternative to the `label` prop -->
<slot></slot>
<div v-if="description" class="description">
{{ description }}
</div>
</div>

<!-- In this case, we presume that there is a `label` prop given -->
<label
v-else-if="label && !$slots.default"
v-else
dir="auto"
class="k-checkbox-label"
:for="id"
Expand All @@ -61,6 +64,9 @@
@click.prevent
>
{{ label }}
<div v-if="description" class="description">
{{ description }}
</div>
</label>

</div>
Expand Down Expand Up @@ -112,6 +118,14 @@
type: Boolean,
default: false,
},
/**
* Description - subtext to the label
*/
description: {
type: String,
default: null,
required: false,
},
},
data: () => ({
isCurrentlyChecked: false,
Expand Down Expand Up @@ -241,4 +255,9 @@
height: $checkbox-height;
}

.description {
font-size: 12px;
line-height: normal;
}

</style>