This project is a web application built with Lit and TypeScript, bundled using Webpack, and integrates Material Web Components for the UI.
- Lit for building fast, lightweight web components.
- TypeScript for type-safe JavaScript development.
- Material Web Components for beautiful, accessible UI elements.
- Webpack for bundling and managing development and production builds.
- Live reload for a smooth development experience.
To get started, you need to have Node.js installed on your machine. You can download it from Node.js official website.
-
Clone the repository:
git clone https://github.com/avnerma/ts-lit-material-wp.git cd yourproject
-
Install the dependencies: Make sure you're in the project directory, and run the following command to install the required dependencies:
npm install
During development, you can use the Webpack Dev Server for live reloading and hot module replacement.
-
Run the development server:
npm run dev
-
Open your browser: Webpack Dev Server will automatically open your default browser, but if not, you can manually open:
http://localhost:8080
-
Make changes: Any changes made in the source files (
src/
) will trigger a live reload, updating the browser automatically.
To create a production-ready build, Webpack will minify and optimize the output.
-
Build the project for production:
npm run build
-
The bundled files will be output into the
dist/
directory, ready for deployment.
This project demonstrates how to create a custom Lit component and integrate Material Web Components. The custom element <my-element>
is defined in my-element.ts
and uses Material Web's button component (md-filled-button
).
The custom component is created using Lit, and it can be easily reused:
<my-element name="Lit"></my-element>
The component includes a Material Web button, which you can interact with.
import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import '@material/web/button/filled-button.js';
@customElement('my-element')
export class MyElement extends LitElement {
@property({ type: String }) name = 'World';
static styles = css`
:host {
display: block;
padding: 16px;
}
`;
render() {
return html`
<h1>Hello, ${this.name}!</h1>
<md-filled-button @click=${this.handleClick}>Click me</md-filled-button>
`;
}
handleClick() {
alert(`Hello, ${this.name}!`);
}
}
- Lit - A simple library for building fast, lightweight web components.
- TypeScript - Type-safe JavaScript.
- Material Web Components - Material Design components for the web.
- Webpack - A powerful bundler for JavaScript, CSS, and HTML.
npm run dev
- Starts the Webpack development server with live reload.npm run build
- Bundles the project for production.
This project is licensed under the MIT License. See the LICENSE file for more information.