@webwriter/neural-network
Version:
Deep learning visualization for feed-forward networks with custom datasets, training and prediction.
66 lines (53 loc) • 1.73 kB
text/typescript
import { LitElementWw } from '@webwriter/lit'
import { CSSResult, TemplateResult, html, css } from 'lit'
import { customElement, property } from 'lit/decorators.js'
import { consume } from '@lit/context'
import SlButton from "@shoelace-style/shoelace/dist/components/button/button.component.js"
import { panelContext } from '@/contexts/panels_context'
export class CTab extends LitElementWw {
static scopedElements = {
"sl-button": SlButton
}
({ type: String })
accessor name: string
({ type: String })
accessor prefix: string
({ type: Boolean })
accessor colored: boolean
({ context: panelContext, subscribe: true })
accessor panel: string
// STYLES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static styles: CSSResult = css`
sl-button {
width: 100px;
}
:host([colored]) sl-button::part(base) {
background-color: var(--sl-color-primary-100);
}
.active::part(base) {
background-color: var(--sl-color-primary-600) ;
color: var(--sl-color-neutral-0);
}
`
// RENDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
render(): TemplateResult<1> {
return html`
<div class="c-tab">
<sl-button
class="${this.panel == this.name ? 'active' : ''}"
@click="${(_e: MouseEvent) =>
this.dispatchEvent(
new CustomEvent<string>('open-panel', {
detail: this.name,
bubbles: true,
composed: true,
})
)}"
>
<slot name="prefix" slot="prefix"></slot>
<slot>
</sl-button>
</div>
`
}
}