Skip to content

Commit

Permalink
configure
Browse files Browse the repository at this point in the history
  • Loading branch information
deebloo committed Oct 7, 2024
1 parent db2983b commit 3f89086
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 211 deletions.
432 changes: 234 additions & 198 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@

<joist-header></joist-header>

<joist-nav></joist-nav>
<joist-main>
<joist-nav slot="nav"></joist-nav>

<script type="module" src="./elements/joist-header/joist-header.ts"></script>
<script type="module" src="./elements/joist-nav/joist-nav.ts"></script>
<main>
<h1>Hello World</h1>

<p>Welcome to Joist</p>
</main>
</joist-main>

<script type="module" src="/src/elements/joist-header/joist-header.ts"></script>
<script type="module" src="/src/elements/joist-nav/joist-nav.ts"></script>
<script type="module" src="/src/elements/joist-main/joist-main.ts"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.4.7"
"vite": "6.0.0-beta.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { element } from '@joist/element';
@element({
tagName: 'joist-header'
})
class JoistHeaderElement extends HTMLElement {
constructor() {
super();
}
}
class JoistHeaderElement extends HTMLElement {}

export { JoistHeaderElement };
11 changes: 11 additions & 0 deletions website/src/elements/joist-main/joist-main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:host {
display: flex;
}

#nav {
display: block;
}

#main {
display: block;
}
3 changes: 3 additions & 0 deletions website/src/elements/joist-main/joist-main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<slot id="nav" name="nav"></slot>

<slot id="main"></slot>
8 changes: 8 additions & 0 deletions website/src/elements/joist-main/joist-main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { element } from '@joist/element';

@element({
tagName: 'joist-main'
})
class JoistMainElement extends HTMLElement {}

export { JoistMainElement };
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
nav {
display: flex;
flex-direction: column;
padding: 1rem;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { element } from '@joist/element';
@element({
tagName: 'joist-nav'
})
class JoistNavElement extends HTMLElement {}
class JoistNavElement extends HTMLElement {
connectedCallback(): void {
alert('test');
}
}

export { JoistNavElement };
1 change: 1 addition & 0 deletions website/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
23 changes: 23 additions & 0 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
9 changes: 6 additions & 3 deletions website/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { defineConfig } from 'vite';
const applicator = new Applicator(
new NoopTemplateCache(),
new FileSysTemplateLoader(
(tag) => `elements/${tag}/${tag}.html`,
(tag) => `elements/${tag}/${tag}.css`
(tag) => `./src/elements/${tag}/${tag}.html`,
(tag) => `./src/elements/${tag}/${tag}.css`
)
);

export default defineConfig({
esbuild: {
target: 'es2020'
},
plugins: [
{
name: 'Web Component SSR',
transformIndexHtml: {
order: 'pre',
handler(html) {
return applicator.apply(html, ['joist-header', 'joist-nav']);
return applicator.apply(html, ['joist-header', 'joist-nav', 'joist-main']);
}
},
handleHotUpdate({ file, server }) {
Expand Down

0 comments on commit 3f89086

Please sign in to comment.