Skip to content

Commit 740b4ee

Browse files
committed
Update FieldsetAsLabel to add description
1 parent 3d69bb7 commit 740b4ee

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

packages/js/ui/src/wp/fieldset-as-label/index.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,36 @@ import { __experimentalView as View } from '@wordpress/components';
22
import clsx from 'clsx';
33
import styles from './styles.module.scss';
44

5-
export type FieldsetAsLabelProps = {
5+
export type FieldsetAsLabelProps = React.HTMLAttributes<HTMLFieldSetElement> & {
66
label: React.ReactNode;
7-
children?: React.ReactNode;
7+
labelProps?: React.HTMLAttributes<HTMLLegendElement>;
8+
description?: React.ReactNode;
89
};
910

10-
export function FieldsetAsLabel({ label, children }: FieldsetAsLabelProps) {
11+
export function FieldsetAsLabel({
12+
label,
13+
children,
14+
labelProps,
15+
description,
16+
...props
17+
}: FieldsetAsLabelProps) {
1118
return (
12-
<fieldset>
19+
<fieldset {...props}>
1320
<View
21+
{...labelProps}
1422
as="legend"
1523
className={clsx('components-base-control__label', styles.label)}
1624
>
1725
{label}
1826
</View>
1927
<View>{children}</View>
28+
{description ? (
29+
<View
30+
className={clsx('components-base-control__help', styles.description)}
31+
>
32+
{description}
33+
</View>
34+
) : null}
2035
</fieldset>
2136
);
2237
}

packages/js/ui/src/wp/fieldset-as-label/styles.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@
77
margin-bottom: calc(8px);
88
padding: 0px;
99
}
10+
11+
.description {
12+
margin-top: calc(8px);
13+
margin-bottom: 0px;
14+
font-size: 12px;
15+
font-style: normal;
16+
color: rgb(117, 117, 117);
17+
}

0 commit comments

Comments
 (0)