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

fix(*): deprecate klabel help prop #1799

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions docs/guide/migrating-to-version-9.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Kongponents styles are no longer designed to be utilized standalone, separately
#### Props

* `testMode` prop has been removed
* `help` property of `labelAttributes` prop has been deprecated in favor of `info`

#### Slots

Expand Down Expand Up @@ -179,15 +180,14 @@ Component has been renamed to `KDropdown`

* `SizeArray` and `IconPositionArray` constants have been removed
* `Size` and `IconPosition` types have been removed
* `help` property was removed from `LabelAttributes` interface (TODO: after KLabel is reskinned)

#### Props

* `overlayLabel` prop has been removed
* `size` prop has been removed (KInput only comes in 1 size now)
* `iconPosition` prop has been removed
* `testMode` prop has been removed
* `help` property was removed from `labelAttributes` prop (TODO: after KLabel is reskinned)
* `help` property of `labelAttributes` prop has been deprecated in favor of `info`
* `hasError` prop has been deprecated in favor of `error`

#### Slots
Expand All @@ -211,7 +211,7 @@ Component has been renamed to `KDropdown`

#### Props

* `help` prop has been removed
* `help` prop has been deprecated in favor of `info`
* `testMode` prop has been removed

### KMenu
Expand Down Expand Up @@ -285,6 +285,7 @@ Removed as of `v9`. Use `KTooltip` instead.

* `testMode` prop has been removed
* `type` prop has been deprecated in favor of `card` prop
* `help` property of `labelAttributes` prop has been deprecated in favor of `info`

#### Slots

Expand Down
50 changes: 49 additions & 1 deletion sandbox/pages/SandboxLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,59 @@
required
/>
</SandboxSectionComponent>

<!-- Legacy -->
<SandboxTitleComponent
is-subtitle
title="Legacy"
/>
<SandboxSectionComponent
description="Handles backwards compatibility for deprecated prop usage when passed directly to KLabel or propagated through other components through labelAttributes prop."
title="Props: help (deprecated)"
>
<div class="vertical-spacing">
<KLabel
help="This is help text"
>
Label with help tooltip
</KLabel>
<KInput
label="Label"
:label-attributes="{
help: 'KLabel help.',
}"
/>
<KRadio
v-model="radioCheck"
label="Label"
:label-attributes="{ help: 'KLabel help.' }"
:selected-value="true"
/>
<KCheckbox
v-model="radioCheck"
label="Label"
:label-attributes="{ help: 'KLabel help.' }"
/>
</div>
</SandboxSectionComponent>
</div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import SandboxTitleComponent from '../components/SandboxTitleComponent.vue'
import SandboxSectionComponent from '../components/SandboxSectionComponent.vue'
import { KExternalLink, KLabel, KInput } from '@/components'
import { KExternalLink, KLabel, KInput, KRadio, KCheckbox } from '@/components'

const radioCheck = ref<boolean>(false)
</script>

<style scoped lang="scss">
.klabel-sandbox {
.vertical-spacing {
display: flex;
flex-direction: column;
gap: $kui-space-50;
}
}
</style>
7 changes: 7 additions & 0 deletions src/components/KCheckbox/KCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ const props = defineProps({
labelAttributes: {
type: Object as PropType<LabelAttributes>,
default: () => ({}),
validator: (value: LabelAttributes): boolean => {
if (value.help) {
console.warn('KCheckbox: `help` property of `labelAttributes` prop is deprecated. Please use `info` prop instead. See the migration guide for more details: https://alpha--kongponents.netlify.app/guide/migrating-to-version-9.html#klabel')
}

return true
},
},
description: {
type: String,
Expand Down
7 changes: 7 additions & 0 deletions src/components/KInput/KInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ const props = defineProps({
labelAttributes: {
type: Object as PropType<LabelAttributes>,
default: () => ({}),
validator: (value: LabelAttributes): boolean => {
if (value.help) {
console.warn('KInput: `help` property of `labelAttributes` prop is deprecated. Please use `info` prop instead. See the migration guide for more details: https://alpha--kongponents.netlify.app/guide/migrating-to-version-9.html#klabel')
}

return true
},
},
help: {
type: String,
Expand Down
18 changes: 16 additions & 2 deletions src/components/KLabel/KLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
tabindex="0"
/>
<template #content>
<slot name="tooltip">{{ info }}</slot>
<slot name="tooltip">{{ help || info }}</slot>
</template>
</KTooltip>
</label>
Expand All @@ -43,11 +43,25 @@ const props = defineProps({
type: Object as PropType<TooltipAttributes>,
default: () => ({}),
},
/**
* @deprecated in favor of `info` prop
*/
help: {
type: String,
default: '',
validator: (value: string): boolean => {
if (value) {
console.warn('KLabel: `help` prop is deprecated. Please use `info` prop instead. See the migration guide for more details: https://alpha--kongponents.netlify.app/guide/migrating-to-version-9.html#klabel')
}

return true
},
},
})

const slots = useSlots()

const hasTooltip = computed((): boolean => !!(props.info || slots.tooltip))
const hasTooltip = computed((): boolean => !!(props.help || props.info || slots.tooltip))
</script>

<style lang="scss" scoped>
Expand Down
7 changes: 7 additions & 0 deletions src/components/KRadio/KRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ const props = defineProps({
labelAttributes: {
type: Object as PropType<LabelAttributes>,
default: () => ({}),
validator: (value: LabelAttributes): boolean => {
if (value.help) {
console.warn('KRadio: `help` property of `labelAttributes` prop is deprecated. Please use `info` prop instead. See the migration guide for more details: https://alpha--kongponents.netlify.app/guide/migrating-to-version-9.html#klabel')
}

return true
},
},
/**
* Overrides default description text
Expand Down
1 change: 1 addition & 0 deletions src/types/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface LabelAttributes {
info?: string
required?: boolean
tooltipAttributes?: TooltipAttributes
help?: string // @deprecated in favor of `info`
}

export interface LimitExceededData {
Expand Down
Loading