Skip to content

Commit

Permalink
feat: setup lit + tailwind project
Browse files Browse the repository at this point in the history
work on #9
  • Loading branch information
bsorrentino committed Jul 12, 2024
1 parent d57e917 commit 4ddc639
Show file tree
Hide file tree
Showing 12 changed files with 2,741 additions and 0 deletions.
33 changes: 33 additions & 0 deletions jetty/src/main/js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
bun.lockb
.parcel-cache/7f973df67467291d-AssetGraph-0
.parcel-cache/6054c31dbe703fb9-BundleGraph-0
.parcel-cache/a8a28560cabca33b-AssetGraph-0
.parcel-cache/data.mdb
.parcel-cache/lock.mdb
.parcel-cache/requestGraph-8b272c8491111040-0
.parcel-cache/requestGraph-nodes-0-8b272c8491111040-0
.parcel-cache/snapshot-8b272c8491111040.txt
5 changes: 5 additions & 0 deletions jetty/src/main/js/.postcssrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
plugins: {
tailwindcss: {}
}
}
18 changes: 18 additions & 0 deletions jetty/src/main/js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Lit App</title>
<script type="module" src="/src/my-element.js"></script>
<script type="module" src="/src/my-input.js"></script>
</head>
<body>
<my-element >
<p slot="left">PANEL1</p>
<p slot="right">PANEL2</p>
<div slot="bottom"><my-input></my-input></div>
</my-element>
</body>
</html>
21 changes: 21 additions & 0 deletions jetty/src/main/js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "lit-vite",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "parcel index.html",
"build": "parcel build index.html"
},
"dependencies": {
"lit": "^3.1.4"
},
"devDependencies": {
"@types/node": "^20.14.10",
"autoprefixer": "^10.4.2",
"daisyui": "^4.12.2",
"parcel": "^2.12.0",
"postcss": "^8.4.7",
"tailwindcss": "^3.0.23",
"typescript": "^5.4.5"
}
}
3 changes: 3 additions & 0 deletions jetty/src/main/js/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
15 changes: 15 additions & 0 deletions jetty/src/main/js/src/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions jetty/src/main/js/src/my-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import './app.css';

import { html, css, LitElement } from 'lit';

export class MyElement extends LitElement {

static styles = css`
.item-a {
grid-area: left;
background-color: red;
}
.item-b {
grid-area: right;
background-color: blue;
}
.item-c {
grid-area: bottom;
//background-color: yellow;
}
.container {
height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 25% 25% 25% 25% ;
grid-template-areas:
"left left right right"
"left left right right"
"left left right right"
"bottom bottom right right";
}
`;
render() {
return html`
<div class="container">
<div class="item-a" id="panel1"><slot name="left">LEFT</slot></div>
<div class="item-b" id="panel3"><slot name="right">RIGHT</slot></div>
<div class="item-c border border-gray-200" id="panel2"><slot name="bottom">BOTTOM</slot></div>
</div>
`;
}
}

window.customElements.define('my-element', MyElement);
32 changes: 32 additions & 0 deletions jetty/src/main/js/src/my-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import TWStyles from './twlit';

import { html, css, LitElement } from 'lit';


export class MyInputElement extends LitElement {

static styles = [ TWStyles, css`
.container {
display: flex;
flex-direction: row;
}
`]
// createRenderRoot() {
// return this; // turn off shadow dom to access external styles. Now this element can use DaisyUI
// }

connectedCallback() {
super.connectedCallback();
}

render() {
return html`
<div class="container">
<input type="text" placeholder="Type here is" class="input w-full max-w-xs" />
<button class="btn">Button</button>
</div>
`;
}
}

window.customElements.define('my-input', MyInputElement);
Loading

0 comments on commit 4ddc639

Please sign in to comment.