Skip to content

Commit 5dae268

Browse files
committed
fixup! feat: add NcFieldset
1 parent cb40d4c commit 5dae268

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/components/NcFieldset/NcFieldset.vue

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ import type { Slot } from 'vue'
99
import { createElementId } from '../../utils/createElementId.ts'
1010
1111
const {
12-
legend = undefined,
12+
label = undefined,
1313
description = undefined,
14-
hideLegend = false,
14+
hideLabel = false,
1515
hideDescription = false,
1616
noGap = false,
1717
} = defineProps<{
1818
/**
19-
* Fieldset legend. #legend slot can be used for custom legend content
19+
* Group label (the fieldset's legend). #label slot can be used for custom label content
2020
*/
21-
legend?: string
21+
label?: string
2222
/**
2323
* Optional fieldset description. #description slot can be used for custom description content
2424
*/
2525
description?: string
2626
/**
27-
* Hide the legend visually but keep it accessible for screen readers
27+
* Hide the label visually but keep it accessible for screen readers
2828
*/
29-
hideLegend?: boolean
29+
hideLabel?: boolean
3030
/**
3131
* Hide the description visually but keep it accessible for screen readers
3232
*/
@@ -43,17 +43,17 @@ const slots = defineSlots<{
4343
*/
4444
default?: Slot
4545
/**
46-
* Custom legend content
46+
* Custom label content
4747
*/
48-
legend?: Slot
48+
label?: Slot
4949
/**
5050
* Custom description content
5151
*/
5252
description?: Slot
5353
}>()
5454
5555
const id = `nc-fieldset-${createElementId()}`
56-
const labelId = `${id}-legend`
56+
const labelId = `${id}-label`
5757
const descriptionId = `${id}-description`
5858
5959
const hasDescription = () => !!description || !!slots.description
@@ -64,9 +64,9 @@ const getDescriptionId = () => hasDescription() ? descriptionId : undefined
6464
<fieldset
6565
:class="[$style.fieldset, { [$style.fieldset_noGap]: noGap }]"
6666
:aria-describedby="getDescriptionId()">
67-
<legend :id="labelId" :class="[$style.fieldset__legend, { 'hidden-visually': hideLegend }]">
68-
<slot name="legend">
69-
{{ legend || '⚠️ Missing legend' }}
67+
<legend :id="labelId" :class="[$style.fieldset__legend, { 'hidden-visually': hideLabel }]">
68+
<slot name="label">
69+
{{ label || '⚠️ Missing label' }}
7070
</slot>
7171
</legend>
7272
<div v-if="hasDescription()" :id="descriptionId" :class="[$style.fieldset__description, { 'hidden-visually': hideDescription }]">
@@ -129,7 +129,7 @@ Native `<fieldset>` element for grouping form elements with a legend.
129129

130130
```vue
131131
<template>
132-
<NcFieldset legend="Personal information">
132+
<NcFieldset label="Personal information">
133133
<NcTextField label="First name" />
134134
<NcTextField label="Last name" />
135135
</NcFieldset>
@@ -140,7 +140,7 @@ Native `<fieldset>` element for grouping form elements with a legend.
140140

141141
```vue
142142
<template>
143-
<NcFieldset legend="Personal information" description="Your contact details">
143+
<NcFieldset label="Personal information" description="Your contact details">
144144
<NcTextField label="First name" />
145145
<NcTextField label="Last name" />
146146
</NcFieldset>
@@ -155,17 +155,17 @@ By default `NcFieldset`:
155155

156156
```vue
157157
<template>
158-
<NcFieldset legend="Personal information">
158+
<NcFieldset label="Personal information">
159159
<NcTextField label="First name" />
160160
<NcTextField label="Last name" />
161161
</NcFieldset>
162162

163-
<NcFieldset legend="Personal information">
163+
<NcFieldset label="Personal information">
164164
<NcTextField label="First name" />
165165
<NcTextField label="Last name" />
166166
</NcFieldset>
167167

168-
<NcFieldset legend="No gap (for custom content)" no-gap>
168+
<NcFieldset label="No gap (for custom content)" no-gap>
169169
<NcTextField label="First name" />
170170
<NcTextField label="Last name" />
171171
</NcFieldset>

0 commit comments

Comments
 (0)