Skip to content

feat(ui5-form, ui5-form-group): add headerLevel property #11372

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions packages/main/src/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import FormCss from "./generated/themes/Form.css.js";

import type FormItemSpacing from "./types/FormItemSpacing.js";
import type FormGroup from "./FormGroup.js";
import type TitleLevel from "./types/TitleLevel.js";

const additionalStylesMap = new Map<string, string>();

Expand Down Expand Up @@ -41,6 +42,7 @@ interface IFormItem extends UI5Element {
colsS?: number;
columnSpan?: number;
headerText?: string;
headerLevel?: `${TitleLevel}`;
}

type GroupItemsInfo = {
Expand Down Expand Up @@ -265,6 +267,16 @@ class Form extends UI5Element {
@property()
headerText?: string;

/**
* Defines the compoennt heading level,
* set by the `headerText`.
* @default "H4"
* @since 2.10.0
* @public
*/
@property()
headerLevel: `${TitleLevel}` = "H4";

/**
* Defines the vertical spacing between form items.
*
Expand Down
11 changes: 11 additions & 0 deletions packages/main/src/FormGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import type FormItem from "./FormItem.js";
import type { IFormItem } from "./Form.js";
import type FormItemSpacing from "./types/FormItemSpacing.js";
import type TitleLevel from "./types/TitleLevel.js";

/**
* @class
Expand Down Expand Up @@ -47,6 +48,16 @@ class FormGroup extends UI5Element implements IFormItem {
@property()
headerText?: string;

/**
* Defines the compoennt heading level,
* set by the `headerText`.
* @default "H5"
* @public
* @since 2.10.0
*/
@property()
headerLevel: `${TitleLevel}` = "H5";

/**
* Defines column span of the component,
* e.g how many columns the group should span to.
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/FormTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function FormTemplate(this: Form) {
{this.hasCustomHeader ?
<slot name="header"></slot>
:
<Title id={`${this._id}-header-text`} level="H4">{this.headerText}</Title>
<Title id={`${this._id}-header-text`} level={this.headerLevel}>{this.headerText}</Title>
}
</div>
}
Expand All @@ -38,7 +38,7 @@ export default function FormTemplate(this: Form) {
<div class="ui5-form-group" role="form" aria-labelledby={groupItemInfo.accessibleNameRef}>
{groupItem.headerText &&
<div class="ui5-form-group-heading">
<Title id={`${groupItem._id}-group-header-text`} level="H6">{groupItem.headerText}</Title>
<Title id={`${groupItem._id}-group-header-text`} level={groupItem.headerLevel} size="H6">{groupItem.headerText}</Title>
</div>
}

Expand Down
Loading