🎒🎖 Checkpoint
./README.md:1954897/2857 ./server.js:1954897/4286 ./package.json:1954897/1034 ./index.html:1954897/1440 ./public/index.js:1954897/4254 ./public/style.css:1954897/5185
This commit is contained in:
1 parent
f7de9ecf60
commit
951dff8682
12 files changed
+421
-1267
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Made with love by MindfulMinun
|
||||
https://benjic.xyz/
|
||||
-->
|
||||
<html lang="en-US" class="no-js">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Density map</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,500;1,300&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/>
|
||||
<!-- scripts -->
|
||||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
|
||||
</head>
|
||||
<body class="card--active">
|
||||
<div id="map"></div>
|
||||
<div id="card" style="--region: ''">
|
||||
<p>Tap a region to get started.</p>
|
||||
</div>
|
||||
</body>
|
||||
<script src="./index.js"></script>
|
||||
</html>
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
const buildings = {
|
||||
"MC": {
|
||||
name: "McDermott Library",
|
||||
bounds: [
|
||||
[32.98732, -96.74801],
|
||||
[32.98732, -96.74723],
|
||||
[32.98660, -96.74723],
|
||||
[32.98660, -96.74801]
|
||||
],
|
||||
},
|
||||
"SU": {
|
||||
name: "Student Union",
|
||||
bounds: [
|
||||
[32.98711, -96.74909],
|
||||
[32.98711, -96.74848],
|
||||
[32.98661, -96.74849],
|
||||
[32.98661, -96.74910]
|
||||
]
|
||||
},
|
||||
"ECSW": {
|
||||
name: "Engineering and Computer Science West",
|
||||
bounds: [
|
||||
[32.98639, -96.75217],
|
||||
[32.98638, -96.75128],
|
||||
[32.98579, -96.75119],
|
||||
[32.98581, -96.75217]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const map = L.map('map', {
|
||||
minZoom: 15,
|
||||
maxZoom: 18
|
||||
}).setView([32.98649, -96.7485], 18)
|
||||
|
||||
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
|
||||
maxZoom: 18,
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
id: 'mapbox/dark-v10',
|
||||
// id: 'mapbox/streets-v11',
|
||||
tileSize: 512,
|
||||
zoomOffset: -1
|
||||
}).addTo(map)
|
||||
|
||||
|
||||
for (const [id, building] of Object.entries(buildings)) {
|
||||
console.log(id, building)
|
||||
const poly = L.polygon(building.bounds)
|
||||
|
||||
poly.on('click', ev => {
|
||||
console.log(ev)
|
||||
map.panTo(poly.getCenter())
|
||||
displayCard(id)
|
||||
}).addTo(map)
|
||||
|
||||
if (id === "MC") {
|
||||
poly.setStyle({
|
||||
color: "#00e676",
|
||||
opacity: .5
|
||||
})
|
||||
} else if (id === "SU"){
|
||||
poly.setStyle({
|
||||
color: "yellow",
|
||||
opacity: .5
|
||||
})
|
||||
}
|
||||
|
||||
// const label = new L.marker(poly.getCenter(), { opacity: 0.00 }) //opacity may be set to zero
|
||||
// label.bindTooltip(id, {permanent: true, className: "my-label", offset: [0, 0] });
|
||||
// label.addTo(map)
|
||||
}
|
||||
|
||||
async function displayCard(id) {
|
||||
const card = document.getElementById("card")
|
||||
await card.animate([
|
||||
{ transform: 'translateY(50px)', opacity: "0" },
|
||||
], {
|
||||
duration: 200,
|
||||
fill: 'forwards',
|
||||
easing: 'cubic-bezier(0.4, 0.0, 1, 1)'
|
||||
}).finished
|
||||
card.innerHTML = `
|
||||
<h1>${buildings[id].name}</h1>
|
||||
<p>Busier than usual</p>
|
||||
<canvas id="myChart" height="80"></canvas>
|
||||
`
|
||||
card.style.setProperty("--region", `'${id}'`)
|
||||
updateChart()
|
||||
await card.animate([
|
||||
{ transform: 'translateY(0%)', opacity: "1" },
|
||||
], {
|
||||
duration: 200,
|
||||
fill: 'forwards',
|
||||
easing: 'cubic-bezier(0.0, 0.0, 0.2, 1)'
|
||||
}).finished
|
||||
}
|
||||
|
||||
|
||||
function updateChart() {
|
||||
const ctx = document.getElementById('myChart').getContext('2d')
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ['Now', '1h ago', '2h ago', '3h ago', '4h ago', '5h ago'].reverse(),
|
||||
datasets: [{
|
||||
label: 'Density',
|
||||
data: [12, 19, 3, 5, 2, 3],
|
||||
// backgroundColor: [
|
||||
// 'rgba(255, 99, 132, 0.2)',
|
||||
// 'rgba(54, 162, 235, 0.2)',
|
||||
// 'rgba(255, 206, 86, 0.2)',
|
||||
// 'rgba(75, 192, 192, 0.2)',
|
||||
// 'rgba(153, 102, 255, 0.2)',
|
||||
// 'rgba(255, 159, 64, 0.2)'
|
||||
// ],
|
||||
// borderColor: [
|
||||
// 'rgba(255, 99, 132, 1)',
|
||||
// 'rgba(54, 162, 235, 1)',
|
||||
// 'rgba(255, 206, 86, 1)',
|
||||
// 'rgba(75, 192, 192, 1)',
|
||||
// 'rgba(153, 102, 255, 1)',
|
||||
// 'rgba(255, 159, 64, 1)'
|
||||
// ],
|
||||
borderColor: '#55aadd',
|
||||
backgroundColor: '#55aadd',
|
||||
// borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const mediaQuery = window.matchMedia("(min-width: 720px)")
|
||||
mediaQuery.addEventListener("change", updateSize)
|
||||
requestAnimationFrame(updateSize)
|
||||
|
||||
function updateSize() {
|
||||
map.invalidateSize(true)
|
||||
console.log("updatesize!")
|
||||
}
|
||||
// map.invalidateSize()
|
||||
+49
-184
@@ -1,201 +1,66 @@
|
||||
/******************************************************************************
|
||||
START Glitch hello-app default styles
|
||||
|
||||
The styles in this section do some minimal CSS resets, set default fonts and
|
||||
colors, and handle the layout for our footer and "Remix on Glitch" button. If
|
||||
you're new to CSS they may seem a little complicated, but you can scroll down
|
||||
to this section's matching END comment to see page-specific styles.
|
||||
******************************************************************************/
|
||||
/* Our default values set as CSS variables */
|
||||
:root {
|
||||
--color-bg: #BDC9FF;
|
||||
--color-text-main: #000000;
|
||||
--color-primary: #AFECE0;
|
||||
--wrapper-height: 87vh;
|
||||
--image-max-width: 300px;
|
||||
--image-margin: 3rem;
|
||||
--font-family: "HK Grotesk";
|
||||
--font-family-header: "HK Grotesk";
|
||||
*, *::before, *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Basic page style resets */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Import fonts */
|
||||
@font-face {
|
||||
font-family: HK Grotesk;
|
||||
src: url("https://cdn.glitch.me/605e2a51-d45f-4d87-a285-9410ad350515%2FHKGrotesk-Regular.otf?v=1603136326027")
|
||||
format("opentype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: HK Grotesk;
|
||||
font-weight: bold;
|
||||
src: url("https://cdn.glitch.me/605e2a51-d45f-4d87-a285-9410ad350515%2FHKGrotesk-Bold.otf?v=1603136323437")
|
||||
format("opentype");
|
||||
}
|
||||
|
||||
/* Our remix on glitch button */
|
||||
.btn--remix {
|
||||
font-family: HK Grotesk;
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 1.1rem;
|
||||
line-height: 1rem;
|
||||
font-weight: 500;
|
||||
height: 2.75rem;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #000000;
|
||||
box-sizing: border-box;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
margin-left: auto;
|
||||
}
|
||||
.btn--remix img {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
.btn--remix:hover {
|
||||
background-color: #D0FFF1;
|
||||
}
|
||||
|
||||
/* Navigation grid */
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 1rem auto 0;
|
||||
padding: 1rem 0 0.75rem 0;
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
border-top: 4px solid #fff;
|
||||
}
|
||||
|
||||
.footer a:not(.btn--remix):link,
|
||||
a:not(.btn--remix):visited {
|
||||
font-family: HK Grotesk;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-size: 1.1rem;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
border-style: none;
|
||||
}
|
||||
.footer a:hover {
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.footer .links {
|
||||
padding: 0.5rem 1rem 1.5rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.divider {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
/******************************************************************************
|
||||
END Glitch hello-app default styles
|
||||
******************************************************************************/
|
||||
|
||||
body {
|
||||
font-family: HK Grotesk;
|
||||
background-color: var(--color-bg);
|
||||
font-family: "IBM Plex Sans", sans-serif;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
/* Page structure */
|
||||
.wrapper {
|
||||
min-height: var(--wrapper-height);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: left;
|
||||
justify-content: left;
|
||||
#map {
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.25rem;
|
||||
#card {
|
||||
position: fixed;
|
||||
bottom: 0; left: 0; right: 0;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
max-width: 920px;
|
||||
background: #1e1e1e;
|
||||
border: 2px solid white;
|
||||
border-radius: 0 4em 0 0;
|
||||
border-bottom: 0;
|
||||
padding: 1em 1em 0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Title h1 style */
|
||||
.title {
|
||||
color: #2800FF;
|
||||
font-family: HK Grotesk;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
font-size: 100px;
|
||||
line-height: 105%;
|
||||
margin: 2rem 0 0;
|
||||
#card::before {
|
||||
content: var(--region);
|
||||
pointer-events: none;
|
||||
display: block;
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
left: 1rem;
|
||||
opacity: .12;
|
||||
font-size: 6em;
|
||||
}
|
||||
|
||||
/* Very light scaling for our illustration */
|
||||
.illo-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.illustration {
|
||||
max-width: 100%;
|
||||
max-height: 150px;
|
||||
margin-top: 1rem;
|
||||
.card--active #card {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* Styles for our custom color form and its results */
|
||||
.color-info {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.color-search {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
.color-form {
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.color-form a:not(.btn--remix) {
|
||||
font-weight: bold;
|
||||
color: var(--color-text-main);
|
||||
margin-top: 8px;
|
||||
}
|
||||
.color-form button {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.color-form button:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: -8px 4px 20px #9BE7D8;
|
||||
}
|
||||
form {
|
||||
margin: 0.75rem 0;
|
||||
}
|
||||
button,
|
||||
input {
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #000000;
|
||||
box-sizing: border-box;
|
||||
border-radius: 4px;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
label {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
@media only screen and (min-width: 720px) {
|
||||
#card {
|
||||
right: auto;
|
||||
/* min-height: 300px; */
|
||||
left: 2em;
|
||||
/* max-width: 50%; */
|
||||
width: 480px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Instructions */
|
||||
.instructions {
|
||||
margin: 1rem auto 0;
|
||||
}
|
||||
.instructions p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
h2 {
|
||||
color: #2800FF;
|
||||
}
|
||||
|
||||
h1, p, canvas { margin: 0 0 1rem; font-weight: 300; }
|
||||
Reference in new issue
Block a user