Skip to content

Commit

Permalink
feat(go-dialog): allow custom heading tag
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwuapps committed Nov 25, 2023
1 parent c381a40 commit a41c09a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ export namespace Components {
* Heading of the overlay content
*/
"heading"?: string;
/**
* HTML tag for the heading
*/
"headingTag"?: string;
"open": () => Promise<void>;
/**
* If persistent, the overlay will not be closed when the user clicks outside of it or presses the escape key.
Expand Down Expand Up @@ -2087,6 +2091,10 @@ declare namespace LocalJSX {
* Heading of the overlay content
*/
"heading"?: string;
/**
* HTML tag for the heading
*/
"headingTag"?: string;
/**
* If persistent, the overlay will not be closed when the user clicks outside of it or presses the escape key.
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/components/go-dialog/go-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ go-overlay.go-dialog {
display: flex;
align-items: flex-start;
justify-content: space-between;
flex: 1;
.heading{
font-size: var(--go-size-3);
font-weight: 500;
line-height: 1.5;
}
.close-btn {
flex: 0;
}
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/components/go-dialog/go-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export class GoDialog {
*/
@Prop() heading?: string;

/**
* HTML tag for the heading
*/
@Prop() headingTag?: string = 'h2';

// aria-labelledby https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html
headingId: string = uniqueId('overlay-label-');

Expand Down Expand Up @@ -52,7 +57,7 @@ export class GoDialog {
}

render() {
const { active, heading, persistent, headingId } = this;
const { active, heading, persistent, headingId, headingTag: H } = this;
return (
<go-overlay
class="go-dialog"
Expand All @@ -66,7 +71,7 @@ export class GoDialog {
onOverlayClose={() => this.handleOverlayClose()}>
<div class="overlay-heading" id={headingId}>
<slot name="heading">
<h3>{heading}</h3>
<H class="heading">{heading}</H>
</slot>
{!persistent ? (
<go-button
Expand Down

0 comments on commit a41c09a

Please sign in to comment.