Skip to content

Commit 02b1807

Browse files
committed
refactor(dialog): provide message slot
1 parent 5fbc725 commit 02b1807

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/components/dialog/dialog.ts

Lines changed: 5 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';
@@ -76,6 +77,9 @@ export default class IgcDialogComponent extends EventEmitterMixin<
7677
@queryAssignedElements({ slot: 'title' })
7778
private titleElements!: Array<HTMLElement>;
7879

80+
@queryAssignedElements({ slot: 'message' })
81+
private messageElements!: Array<HTMLElement>;
82+
7983
@queryAssignedElements({ slot: 'footer' })
8084
private footerElements!: Array<HTMLElement>;
8185

@@ -262,6 +266,7 @@ export default class IgcDialogComponent extends EventEmitterMixin<
262266
<slot name="title"><span>${this.title}</span></slot>
263267
</header>
264268
<section part="content">
269+
<slot name="message" .hidden=${isEmpty(this.messageElements)}></slot>
265270
<slot @slotchange=${this.handleContentChange}></slot>
266271
</section>
267272
<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)