fix: Update default button text handling and improve demo example in dees-form-submit

This commit is contained in:
Juergen Kunz
2025-06-19 12:42:50 +00:00
parent d1e7e5447c
commit 99b23236a1
2 changed files with 8 additions and 12 deletions

View File

@ -181,7 +181,7 @@ export class DeesButton extends DeesElement {
${this.status === 'normal' ? html``: html` ${this.status === 'normal' ? html``: html`
<dees-spinner .bnw=${true} status="${this.status}"></dees-spinner> <dees-spinner .bnw=${true} status="${this.status}"></dees-spinner>
`} `}
<div class="textbox">${this.text ? this.text : this.textContent}</div> <div class="textbox">${this.text || html`<slot>Button</slot>`}</div>
</div> </div>
`; `;
} }
@ -202,9 +202,6 @@ export class DeesButton extends DeesElement {
} }
public async firstUpdated() { public async firstUpdated() {
if (!this.textContent) { // Don't set default text here as it interferes with slotted content
this.textContent = 'Button';
this.performUpdate();
}
} }
} }

View File

@ -5,7 +5,6 @@ import {
css, css,
cssManager, cssManager,
property, property,
type CSSResult,
} from '@design.estate/dees-element'; } from '@design.estate/dees-element';
import { DeesForm } from './dees-form.js'; import { DeesForm } from './dees-form.js';
@ -17,7 +16,7 @@ declare global {
@customElement('dees-form-submit') @customElement('dees-form-submit')
export class DeesFormSubmit extends DeesElement { export class DeesFormSubmit extends DeesElement {
public static demo = () => html`<dees-form-submit>This is a sloted text</dees-form-submit>`; public static demo = () => html`<dees-form-submit>Submit Form</dees-form-submit>`;
@property({ @property({
type: Boolean, type: Boolean,
@ -38,17 +37,17 @@ export class DeesFormSubmit extends DeesElement {
constructor() { constructor() {
super(); super();
} }
public static styles = [cssManager.defaultStyles, css``]; public static styles = [cssManager.defaultStyles, css``];
public render() { public render() {
return html` return html`
<dees-button <dees-button
status=${this.status} status="${this.status}"
@click=${this.submit} @click="${this.submit}"
.disabled=${this.disabled} ?disabled="${this.disabled}"
.text=${this.text ? this.text : this.textContent}
> >
${this.text || html`<slot></slot>`}
</dees-button> </dees-button>
`; `;
} }