Skip to content

Instantly share code, notes, and snippets.

@bobbyg603
Created December 13, 2022 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbyg603/40614361c2cb57c119358c8ecf9dc2f5 to your computer and use it in GitHub Desktop.
Save bobbyg603/40614361c2cb57c119358c8ecf9dc2f5 to your computer and use it in GitHub Desktop.
How to Build a Web Component
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