Skip to content

Commit

Permalink
fix: review
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Dec 19, 2024
1 parent 52b0401 commit c30ee23
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions tools/generate-component/boilerplate/component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
import { html, LitElement, nothing } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';

import { EventEmitter } from '../core/eventing.js';
import type { CSSResultGroup, TemplateResult } from 'lit';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';

import style from './__noPrefixName__.scss?lit&inline';

Expand All @@ -16,40 +14,12 @@ import style from './__noPrefixName__.scss?lit&inline';
export class __nameUpperCase__ extends LitElement {
public static override styles: CSSResultGroup = style;
public static readonly events: Record<string, string> = {
myEventName: 'myEventName',
// Add event names or remove
} as const;

/** myProp documentation */
@property({ attribute: 'my-prop', reflect: true }) public myProp: string = '';

/** _myState documentation */
@state() private _myState = false;

private _myEvent: EventEmitter<any> = new EventEmitter(
this,
__nameUpperCase__.events.myEventName,
);

private _onClickFn(): void {
this._myEvent.emit();
}

protected override willUpdate(changedProperties: PropertyValues<this>): void {
super.willUpdate(changedProperties);

if (changedProperties.has('myProp')) {
// do stuff
}
}

public override disconnectedCallback(): void {
super.disconnectedCallback();
// do stuff
}

protected override render(): TemplateResult {
return html`
<div class="__name__">${this._myState ? html`<slot></slot>` : nothing} ${this.myProp}</div>
<div class="__name__"><slot></slot></div>
`;
}
}
Expand Down

0 comments on commit c30ee23

Please sign in to comment.