Skip to content

Commit b066ebc

Browse files
committed
fix: remove nothing update
1 parent 84aa3ec commit b066ebc

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

packages/dialog/src/Dialog.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
property,
2323
query,
2424
} from '@spectrum-web-components/base/src/decorators.js';
25-
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
25+
import { classMap } from '@spectrum-web-components/base/src/directives.js';
2626
import { conditionAttributeWithId } from '@spectrum-web-components/base/src/condition-attribute-with-id.js';
2727

2828
import '@spectrum-web-components/divider/sp-divider.js';
@@ -127,11 +127,7 @@ export class Dialog extends FocusVisiblePolyfillMixin(
127127

128128
protected renderHeading(): TemplateResult {
129129
return html`
130-
<slot
131-
name="heading"
132-
class=${ifDefined(this.hasHero ? this.hasHero : undefined)}
133-
@slotchange=${this.onHeadingSlotchange}
134-
></slot>
130+
<slot name="heading" @slotchange=${this.onHeadingSlotchange}></slot>
135131
`;
136132
}
137133

@@ -144,7 +140,6 @@ export class Dialog extends FocusVisiblePolyfillMixin(
144140
}
145141

146142
protected renderFooter(): TemplateResult {
147-
if (!this.hasFooter) return html``;
148143
return html`
149144
<div class="footer">
150145
<slot name="footer"></slot>
@@ -153,33 +148,26 @@ export class Dialog extends FocusVisiblePolyfillMixin(
153148
}
154149

155150
protected renderButtons(): TemplateResult {
156-
if (!this.hasButtons) return html``;
151+
const classes = {
152+
'button-group': true,
153+
'button-group--noFooter': !this.hasFooter,
154+
};
157155
return html`
158-
<sp-button-group
159-
class="button-group ${this.hasFooter
160-
? nothing
161-
: 'button-group--noFooter'}"
162-
>
156+
<sp-button-group class=${classMap(classes)}>
163157
<slot name="button"></slot>
164158
</sp-button-group>
165159
`;
166160
}
167161

168162
protected renderDismiss(): TemplateResult {
169-
if (!this.dismissable) return html``;
170163
return html`
171-
<sp-action-button
164+
<sp-close-button
172165
class="close-button"
173166
label="Close"
174167
quiet
175168
size="m"
176169
@click=${this.close}
177-
>
178-
<sp-icon-cross500
179-
class="spectrum-UIIcon-Cross500"
180-
slot="icon"
181-
></sp-icon-cross500>
182-
</sp-action-button>
170+
></sp-close-button>
183171
`;
184172
}
185173

@@ -197,8 +185,10 @@ export class Dialog extends FocusVisiblePolyfillMixin(
197185
: html`
198186
<sp-divider size="m" class="divider"></sp-divider>
199187
`}
200-
${this.renderContent()} ${this.renderFooter()}
201-
${this.renderButtons()} ${this.renderDismiss()}
188+
${this.renderContent()}
189+
${this.hasFooter ? this.renderFooter() : nothing}
190+
${this.hasButtons ? this.renderButtons() : nothing}
191+
${this.dismissable ? this.renderDismiss() : nothing}
202192
</div>
203193
`;
204194
}

packages/dialog/test/dialog.test.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ describe('Dialog', () => {
8080
});
8181
it('allows hero override', async () => {
8282
class Override extends Dialog {
83-
renderHero(): TemplateResult {
83+
protected override get hasHero(): boolean {
84+
return true;
85+
}
86+
protected override renderHero(): TemplateResult {
8487
return html`
8588
<div id="hero-container"></div>
8689
`;
@@ -100,7 +103,7 @@ describe('Dialog', () => {
100103
});
101104
it('allows heading override', async () => {
102105
class Override extends Dialog {
103-
renderHeading(): TemplateResult {
106+
protected override renderHeading(): TemplateResult {
104107
return html`
105108
<h2 id="heading-container">Test</h2>
106109
`;
@@ -120,7 +123,7 @@ describe('Dialog', () => {
120123
});
121124
it('allows content override', async () => {
122125
class Override extends Dialog {
123-
renderContent(): TemplateResult {
126+
protected override renderContent(): TemplateResult {
124127
return html`
125128
<p id="content-container">Test</p>
126129
`;
@@ -140,7 +143,10 @@ describe('Dialog', () => {
140143
});
141144
it('allows footer override', async () => {
142145
class Override extends Dialog {
143-
renderFooter(): TemplateResult {
146+
protected override get hasFooter(): boolean {
147+
return true;
148+
}
149+
protected override renderFooter(): TemplateResult {
144150
return html`
145151
<p id="footer-container">Test</p>
146152
`;
@@ -160,7 +166,10 @@ describe('Dialog', () => {
160166
});
161167
it('allows button override', async () => {
162168
class Override extends Dialog {
163-
renderButtons(): TemplateResult {
169+
protected override get hasButtons(): boolean {
170+
return true;
171+
}
172+
protected override renderButtons(): TemplateResult {
164173
return html`
165174
<p id="button-container">Test</p>
166175
`;
@@ -180,7 +189,7 @@ describe('Dialog', () => {
180189
});
181190
it('allows dismiss override', async () => {
182191
class Override extends Dialog {
183-
renderDismiss(): TemplateResult {
192+
protected override renderDismiss(): TemplateResult {
184193
return html`
185194
<p id="dismiss-container">Test</p>
186195
`;
@@ -191,7 +200,7 @@ describe('Dialog', () => {
191200

192201
const el = await fixture<Override>(
193202
html`
194-
<dismiss-dialog></dismiss-dialog>
203+
<dismiss-dialog dismissable></dismiss-dialog>
195204
`
196205
);
197206

0 commit comments

Comments
 (0)