-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
deebloo
committed
Oct 7, 2024
1 parent
b19b6ce
commit db2983b
Showing
12 changed files
with
690 additions
and
11 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:host { | ||
display: contents; | ||
} | ||
|
||
header { | ||
padding: 1rem; | ||
background: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<header>Joist</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { element } from '@joist/element'; | ||
|
||
@element({ | ||
tagName: 'joist-header' | ||
}) | ||
class JoistHeaderElement extends HTMLElement { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
|
||
export { JoistHeaderElement }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:host { | ||
display: contents; | ||
} | ||
|
||
nav { | ||
display: flex; | ||
flex-direction: column; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<nav> | ||
<a href="">Getting Started</a> | ||
<a href="">API</a> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { element } from '@joist/element'; | ||
|
||
@element({ | ||
tagName: 'joist-nav' | ||
}) | ||
class JoistNavElement extends HTMLElement {} | ||
|
||
export { JoistNavElement }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
* { | ||
font-family: | ||
system-ui, | ||
-apple-system, | ||
BlinkMacSystemFont, | ||
'Segoe UI', | ||
Roboto, | ||
Oxygen, | ||
Ubuntu, | ||
Cantarell, | ||
'Open Sans', | ||
'Helvetica Neue', | ||
sans-serif; | ||
} | ||
</style> | ||
|
||
<joist-header></joist-header> | ||
|
||
<joist-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> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@joist/website", | ||
"type": "module", | ||
"scripts": { | ||
"start": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"vite": "^5.4.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Applicator, NoopTemplateCache, FileSysTemplateLoader } from '@joist/ssr'; | ||
import { defineConfig } from 'vite'; | ||
|
||
const applicator = new Applicator( | ||
new NoopTemplateCache(), | ||
new FileSysTemplateLoader( | ||
(tag) => `elements/${tag}/${tag}.html`, | ||
(tag) => `elements/${tag}/${tag}.css` | ||
) | ||
); | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
{ | ||
name: 'Web Component SSR', | ||
transformIndexHtml: { | ||
order: 'pre', | ||
handler(html) { | ||
return applicator.apply(html, ['joist-header', 'joist-nav']); | ||
} | ||
}, | ||
handleHotUpdate({ file, server }) { | ||
if (file.includes('elements') && (file.endsWith('.html') || file.endsWith('.css'))) { | ||
console.log(`${file} updated...`); | ||
|
||
server.ws.send({ | ||
type: 'full-reload', | ||
path: '*' | ||
}); | ||
} | ||
} | ||
} | ||
] | ||
}); |