introduce fieldset component (#23005)

This commit is contained in:
Alan Ren
2023-05-06 21:36:08 -07:00
committed by GitHub
parent feed449d97
commit 718b149e84
6 changed files with 61 additions and 10 deletions

View File

@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Widget } from 'vs/base/browser/ui/widget';
import * as DOM from 'vs/base/browser/dom';
import 'vs/css!./media/fieldset';
export interface FieldSetOptions {
ariaLabel: string;
}
/**
* A wrapper for the HTML FieldSet element, used to group logically related elements in a form.
* Note: The element must be put under the context of an HTML form element in order to make the screen reader announce
* the group name.
*/
export class FieldSet extends Widget {
public readonly element: HTMLFieldSetElement;
constructor(container: HTMLElement, opts: FieldSetOptions) {
super();
this.element = DOM.$('fieldset.default-fieldset');
this.element.setAttribute('aria-label', opts.ariaLabel);
container.appendChild(this.element);
}
}

View File

@@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.default-fieldset {
border: none;
margin-inline: 0px;
padding-inline: 0px;
padding-block: 0px;
}