Skip to content

Commit b9cdb2a

Browse files
authored
refactor(dialog): provide message slot (#1536)
1 parent 831d845 commit b9cdb2a

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## Unreleased
8+
### Added
9+
- #### Dialog
10+
- A new `message` slot that renders text content inside the dialog component has been added. The enhancement was introduced to align the design behavior between Ignite UI for WC and Ignite UI for Angular, ensuring a consistent user experience across products. The newly added `message' slot comes with additional styling with a max-width of 40 characters. The default slot is also still available for rendering content inside the dialog without limiting the component's width.
11+
712
## [5.2.0] - 2025-01-09
813
### Added
914
- Form-associated elements now have a `defaultValue` property (`defaultChecked` for radio buttons, checkboxes, and switches). When a form is reset, components will use this property’s value as their new value or checked state.

src/components/dialog/dialog.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { Constructor } from '../common/mixins/constructor.js';
1414
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
1515
import {
1616
createCounter,
17+
isEmpty,
1718
numberInRangeInclusive,
1819
partNameMap,
1920
} from '../common/util.js';
@@ -36,6 +37,7 @@ export interface IgcDialogComponentEventMap {
3637
*
3738
* @slot - Renders content inside the default slot.
3839
* @slot title - Renders the title of the dialog header.
40+
* @slot message - Renders the message content of the dialog.
3941
* @slot footer - Renders the dialog footer.
4042
*
4143
* @csspart base - The base wrapper of the dialog.
@@ -76,6 +78,9 @@ export default class IgcDialogComponent extends EventEmitterMixin<
7678
@queryAssignedElements({ slot: 'title' })
7779
private titleElements!: Array<HTMLElement>;
7880

81+
@queryAssignedElements({ slot: 'message' })
82+
private messageElements!: Array<HTMLElement>;
83+
7984
@queryAssignedElements({ slot: 'footer' })
8085
private footerElements!: Array<HTMLElement>;
8186

@@ -262,6 +267,7 @@ export default class IgcDialogComponent extends EventEmitterMixin<
262267
<slot name="title"><span>${this.title}</span></slot>
263268
</header>
264269
<section part="content">
270+
<slot name="message" .hidden=${isEmpty(this.messageElements)}></slot>
265271
<slot @slotchange=${this.handleContentChange}></slot>
266272
</section>
267273
<footer part="footer">

src/components/dialog/themes/dialog.base.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ slot[name='footer'] {
6565
}
6666
}
6767

68+
[name='message']::slotted(*) {
69+
max-width: 40ch;
70+
display: inline-block;
71+
}
72+
6873
dialog::backdrop {
6974
opacity: 0;
7075
}

stories/dialog.stories.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ const Template = ({
124124
.open=${open}
125125
title=${ifDefined(title)}
126126
>
127-
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Possimus rerum
128-
enim, incidunt magni ea asperiores laudantium, ducimus itaque quisquam
129-
dolore hic labore facere qui unde aliquam, dignissimos perspiciatis?
130-
Iusto, iure.
127+
<span slot="message">
128+
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Possimus
129+
rerum enim, incidunt magni ea asperiores laudantium, ducimus itaque
130+
quisquam dolore hic labore facere qui unde aliquam, dignissimos
131+
perspiciatis? Iusto, iure.
132+
</span>
131133
</igc-dialog>
132134
133135
<igc-dialog

0 commit comments

Comments
 (0)