Skip to content

Instantly share code, notes, and snippets.

@acidtone
Last active September 11, 2023 05:08
Show Gist options
  • Save acidtone/5bc52ca5c2c1c2e79511097baa560f2b to your computer and use it in GitHub Desktop.
Save acidtone/5bc52ca5c2c1c2e79511097baa560f2b to your computer and use it in GitHub Desktop.
Hello Vanilla web page example

Hello Vanilla

Welcome to a Hello Vanilla, a starter web app built with vanilla HTML, CSS and Javascript.

Attributions

function setupCounter(element) {
let counter = 0;
const setCounter = (count) => {
counter = count;
element.innerHTML = `count is ${counter}`;
}
element.addEventListener('click', () => setCounter(counter + 1))
setCounter(0)
}
setupCounter(document.querySelector('#counter'));
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path fill="#E44D26" d="M107.644 470.877 74.633 100.62h362.734l-33.046 370.199L255.778 512z"/>
<path fill="#F16529" d="m256 480.523 120.03-33.277 28.24-316.352H256z"/>
<path fill="#EBEBEB" d="M256 268.217h-60.09l-4.15-46.501H256v-45.411H142.132l1.087 12.183 11.161 125.139H256zM256 386.153l-.199.053-50.574-13.656-3.233-36.217h-45.585l6.362 71.301 93.02 25.823.209-.058z"/>
<path d="M108.382 0h23.077v22.8h21.11V0h23.078v69.044H152.57v-23.12h-21.11v23.12h-23.077V0zM205.994 22.896h-20.316V0h63.72v22.896h-20.325v46.148h-23.078V22.896zM259.511 0h24.063l14.802 24.26L313.163 0h24.072v69.044h-22.982V34.822l-15.877 24.549h-.397l-15.888-24.549v34.222h-22.58V0zM348.72 0h23.084v46.222h32.453v22.822H348.72V0z"/>
<path fill="#FFF" d="M255.843 268.217v45.41h55.918l-5.271 58.894-50.647 13.67v47.244l93.094-25.801.683-7.672 10.671-119.551 1.108-12.194h-12.237zM255.843 176.305V221.716h109.688l.911-10.207 2.069-23.021 1.086-12.183z"/>
</svg>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Vanilla App</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app">
<div>
<a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started"
target="_blank">
<img src="html.svg" class="logo content" alt="HTML logo" />
</a>
<a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/First_steps/Getting_started" target="_blank">
<img src="css.svg" class="logo presentation" alt="CSS logo" />
</a>
<a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript"
target="_blank">
<img src="javascript.svg" class="logo behaviour" alt="JavaScript logo" target="_blank" />
</a>
<h1>Hello Vanilla</h1>
<div class="card">
<button id="counter" type="button"></button>
</div>
<p class="read-the-docs">
Find the README in this project!
</p>
</div>
</div>
<script type="module" src="counter.js"></script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.behaviour {
height: 5em;
}
.logo.content:hover {
filter: drop-shadow(0 0 2em #fd6a02aa);
}
.logo.presentation:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.behaviour:hover {
filter: drop-shadow(0 0 2em #f7df1eaa);
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment