Skip to content

Instantly share code, notes, and snippets.

@abeisgoat
Last active April 19, 2023 19:21
Show Gist options
  • Save abeisgoat/a4f4f3a9fd0b6a6348768a8737344e17 to your computer and use it in GitHub Desktop.
Save abeisgoat/a4f4f3a9fd0b6a6348768a8737344e17 to your computer and use it in GitHub Desktop.
Simplit - Simplest, Tool-less Lit boilerplate
import {
LitElement,
html,
css,
} from "https://cdn.jsdelivr.net/gh/lit/dist@2/core/lit-core.min.js";
export class SimpleGreeting extends LitElement {
static properties = {
name: {},
};
// Define scoped styles right with your component, in plain CSS
static styles = css`
:host {
* {
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none !important;
touch-action: manipulation;
}
body {
padding: 0px;
margin: 0px;
position: fixed;
width: 100%;
height: calc(100% - env(safe-area-inset-top));
overflow: hidden;
}
}
`;
constructor() {
super();
// Declare reactive properties
this.name = "World";
}
// Render the UI as a function of component state
render() {
return html`<p>Hello, ${this.name}!</p>`;
}
}
customElements.define("simple-greeting", SimpleGreeting);
<!DOCTYPE html>
<html>
<head>
<title>Simplit</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=400, user-scalable=no, viewport-fit=cover"
/>
<meta name="description" content="Simple Lit.dev Boilerplate" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<script type="module" src="app.js"></script>
<script>
// Stop pinch to zoom n junk
document.addEventListener("click", function (e) {
e.preventDefault();
});
document.addEventListener("gesturestart", function (e) {
e.preventDefault();
});
document.addEventListener("touchstart", function (e) {
e.preventDefault();
});
</script>
<style>
* {
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none !important;
touch-action: manipulation;
}
body {
padding: 0px;
margin: 0px;
position: fixed;
width: 100%;
height: calc(100% - env(safe-area-inset-top));
overflow: hidden;
}
</style>
</head>
<body>
<simple-greeting name="Abe"></simple-greeting>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment