Skip to content

Commit d4d98f5

Browse files
committed
feat(example): add vanillaJS to example
1 parent 170b869 commit d4d98f5

File tree

13 files changed

+243
-0
lines changed

13 files changed

+243
-0
lines changed

examples/vanilla/.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Custom app url
2+
# APP_URL=
3+
4+
# Filter debug logs
5+
# VITE_DEBUG_FILTER=

examples/vanilla/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
<!-- if development -->
9+
<script type="module" src="http://localhost:5173/@vite/client"></script>
10+
<script type="module" src="http://localhost:5173/main.js"></script>
11+
</head>
12+
<body>
13+
<div id="app"></div>
14+
<script type="module" src="/src/main.ts"></script>
15+
</body>
16+
</html>

examples/vanilla/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vanilla",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "",
6+
"author": "",
7+
"license": "ISC",
8+
"keywords": [],
9+
"main": "index.js",
10+
"scripts": {
11+
"dev": "vite",
12+
"build": "vite build",
13+
"serve": "vite preview"
14+
},
15+
"devDependencies": {
16+
"vite-plugin-java": "link:../../packages/vite-plugin-java"
17+
}
18+
}

examples/vanilla/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.example</groupId>
8+
<artifactId>my-spring-mvc-app</artifactId>
9+
<version>1.0.0</version>
10+
11+
<properties>
12+
<java.version>11</java.version>
13+
</properties>
14+
15+
<dependencies>
16+
<!-- Add Spring MVC dependencies here -->
17+
</dependencies>
18+
19+
<build>
20+
<plugins>
21+
<!-- Add Maven plugins here -->
22+
</plugins>
23+
</build>
24+
25+
</project>

examples/vanilla/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

examples/vanilla/src/counter.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function setupCounter(element: HTMLButtonElement) {
2+
let counter = 0
3+
const setCounter = (count: number) => {
4+
counter = count
5+
element.innerHTML = `count is ${counter}`
6+
}
7+
element.addEventListener('click', () => setCounter(counter + 1))
8+
setCounter(0)
9+
}

examples/vanilla/src/main.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import './style.css'
2+
import typescriptLogo from './typescript.svg'
3+
import viteLogo from '/vite.svg'
4+
import { setupCounter } from './counter'
5+
6+
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
7+
<div>
8+
<a href="https://vitejs.dev" target="_blank">
9+
<img src="${viteLogo}" class="logo" alt="Vite logo" />
10+
</a>
11+
<a href="https://www.typescriptlang.org/" target="_blank">
12+
<img src="${typescriptLogo}" class="logo vanilla" alt="TypeScript logo" />
13+
</a>
14+
<h1>Vite + TypeScript</h1>
15+
<div class="card">
16+
<button id="counter" type="button"></button>
17+
</div>
18+
<p class="read-the-docs">
19+
Click on the Vite and TypeScript logos to learn more
20+
</p>
21+
</div>
22+
`
23+
24+
setupCounter(document.querySelector<HTMLButtonElement>('#counter')!)

examples/vanilla/src/style.css

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
:root {
2+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
}
15+
16+
a {
17+
font-weight: 500;
18+
color: #646cff;
19+
text-decoration: inherit;
20+
}
21+
a:hover {
22+
color: #535bf2;
23+
}
24+
25+
body {
26+
margin: 0;
27+
display: flex;
28+
place-items: center;
29+
min-width: 320px;
30+
min-height: 100vh;
31+
}
32+
33+
h1 {
34+
font-size: 3.2em;
35+
line-height: 1.1;
36+
}
37+
38+
#app {
39+
max-width: 1280px;
40+
margin: 0 auto;
41+
padding: 2rem;
42+
text-align: center;
43+
}
44+
45+
.logo {
46+
height: 6em;
47+
padding: 1.5em;
48+
will-change: filter;
49+
transition: filter 300ms;
50+
}
51+
.logo:hover {
52+
filter: drop-shadow(0 0 2em #646cffaa);
53+
}
54+
.logo.vanilla:hover {
55+
filter: drop-shadow(0 0 2em #3178c6aa);
56+
}
57+
58+
.card {
59+
padding: 2em;
60+
}
61+
62+
.read-the-docs {
63+
color: #888;
64+
}
65+
66+
button {
67+
border-radius: 8px;
68+
border: 1px solid transparent;
69+
padding: 0.6em 1.2em;
70+
font-size: 1em;
71+
font-weight: 500;
72+
font-family: inherit;
73+
background-color: #1a1a1a;
74+
cursor: pointer;
75+
transition: border-color 0.25s;
76+
}
77+
button:hover {
78+
border-color: #646cff;
79+
}
80+
button:focus,
81+
button:focus-visible {
82+
outline: 4px auto -webkit-focus-ring-color;
83+
}
84+
85+
@media (prefers-color-scheme: light) {
86+
:root {
87+
color: #213547;
88+
background-color: #ffffff;
89+
}
90+
a:hover {
91+
color: #747bff;
92+
}
93+
button {
94+
background-color: #f9f9f9;
95+
}
96+
}
Lines changed: 1 addition & 0 deletions
Loading

examples/vanilla/src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

0 commit comments

Comments
 (0)