Created
December 13, 2022 18:46
-
-
Save bobbyg603/40614361c2cb57c119358c8ecf9dc2f5 to your computer and use it in GitHub Desktop.
How to Build a Web Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { css, html, LitElement } from 'lit'; | |
import { customElement, property } from 'lit/decorators.js'; | |
/** | |
* Medium card body sub-component | |
* @property body - card body text | |
*/ | |
@customElement('medium-card-body') | |
export class MediumCardBodyElement extends LitElement { | |
static override styles = css` | |
:host { | |
flex-grow: 2; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
color: var(--medium-body-color); | |
} | |
`; | |
@property() | |
body = ''; | |
override render() { | |
return html`${this.body}`; | |
} | |
} | |
declare global { | |
interface HTMLElementTagNameMap { | |
'medium-card-body': MediumCardBodyElement; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment