feature: initial commit

This commit is contained in:
Andy Burke 2025-06-24 15:40:30 -07:00
commit 2c27f003c9
15 changed files with 1601 additions and 0 deletions

819
public/index.html Normal file
View file

@ -0,0 +1,819 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Social UX</title>
<style>
/* Dark mode default */
:root {
--bg: #121212;
--text: #f0f0f0;
--accent: #4caf50;
--icon-scale: 1.25;
}
@media (prefers-color-scheme: light) {
:root {
--bg: #f0f0f0;
--text: #121212;
--accent: #4caf50;
}
}
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Remove default margin in favour of better control in authored CSS */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
margin-block-end: 0;
}
/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role="list"],
ol[role="list"] {
list-style: none;
}
/* Set core body defaults */
body {
min-height: 100vh;
line-height: 1.5;
}
/* Set shorter line heights on headings and interactive elements */
h1,
h2,
h3,
h4,
button,
input,
label {
line-height: 1.1;
}
/* Balance text wrapping on headings */
h1,
h2,
h3,
h4 {
text-wrap: balance;
}
/* A elements that don't have a class get default styles */
a:not([class]) {
text-decoration-skip-ink: auto;
color: currentColor;
}
/* Make images easier to work with */
img,
picture {
max-width: 100%;
display: block;
}
/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
font-family: inherit;
font-size: inherit;
}
/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
min-height: 10em;
}
/* Anything that has been anchored to should have extra scroll margin */
:target {
scroll-margin-block: 5ex;
}
* {
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: sans-serif;
color: var(--text);
background-color: var(--bg);
display: flex;
flex-direction: column;
height: 100vh; // fixed height?
}
.tabs-container {
position: relative;
height: 100%;
}
.tabs {
position: relative;
height: 100%;
width: 100%;
}
.tabs::before,
.tabs::after {
content: "";
display: table;
}
.tabs::after {
clear: both;
}
.tab {
float: left;
}
.tab-switch {
display: none;
}
.tab-label {
position: relative;
width: 8rem;
height: 5rem;
cursor: pointer;
transition: all 0.25s;
display: flex;
align-items: center;
justify-content: end;
flex-direction: column;
}
.tab-label .label {
margin: 0.75rem 0;
}
.tab-content {
position: absolute;
z-index: 1;
top: 5rem;
left: 0;
right: 0;
bottom: 0;
padding: 1rem 1rem 0 1rem;
opacity: 0;
transition: all 0.35s;
}
.tab-switch:checked + .tab-label {
margin-top: 1px;
border-bottom: 1px solid #888;
transition: all 0.35s;
z-index: 1;
}
.tab-switch:checked + label + .tab-content {
z-index: 2;
opacity: 1;
transition: all 0.35s;
}
@media screen and (max-width: 800px) {
.tab-label {
width: 4rem;
}
.tab-label .label {
font-size: small;
}
}
@media screen and (max-width: 480px) {
.tab-label {
width: 2.75rem;
}
.tab-label .label {
font-size: x-small;
}
}
.resizable {
resize: horizontal;
overflow: hidden;
border-right: 4px solid #444;
}
/* ICONS */
.icon {
width: 24px;
height: 24px;
transform: scale(var(--icon-scale, 1));
stroke: white;
fill: transparent;
stroke-width: 1pt;
stroke-miterlimit: 10;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 400;
}
/* ICON - CALENDAR */
.icon.calendar,
.icon.calendar::before {
display: block;
box-sizing: border-box;
}
.icon.calendar {
position: relative;
transform: scale(var(--icon-scale, 1));
width: 18px;
height: 18px;
border: 2px solid;
border-top: 4px solid;
border-radius: 3px;
}
.icon.calendar::before {
content: "";
position: absolute;
width: 10px;
border-radius: 3px;
left: 2px;
background: currentColor;
height: 2px;
top: 2px;
}
/* ICON - EXCHANGE */
.icon.exchange,
.icon.exchange::after,
.icon.exchange::before {
display: block;
box-sizing: border-box;
width: 8px;
height: 8px;
}
.icon.exchange {
position: relative;
transform: scale(var(--icon-scale, 1));
box-shadow:
-3px 3px 0 -1px,
3px -3px 0 -1px;
}
.icon.exchange::after,
.icon.exchange::before {
content: "";
position: absolute;
border: 2px solid;
}
.icon.exchange::before {
top: -5px;
left: -5px;
}
.icon.exchange::after {
bottom: -5px;
right: -5px;
}
/* ICON - HOME */
.icon.home {
background:
linear-gradient(to left, currentColor 5px, transparent 0) no-repeat 0 bottom/4px
2px,
linear-gradient(to left, currentColor 5px, transparent 0) no-repeat right
bottom/4px 2px;
box-sizing: border-box;
position: relative;
display: block;
transform: scale(var(--icon-scale, 1));
width: 18px;
height: 14px;
border: 2px solid;
border-top: 0;
border-bottom: 0;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
margin-bottom: -2px;
}
.icon.home::after,
.icon.home::before {
content: "";
display: block;
box-sizing: border-box;
position: absolute;
}
.icon.home::before {
border-top: 2px solid;
border-left: 2px solid;
border-top-left-radius: 4px;
transform: rotate(45deg);
top: -5px;
border-radius: 3px;
width: 14px;
height: 14px;
left: 0;
}
.icon.home::after {
width: 8px;
height: 10px;
border: 2px solid;
border-radius: 100px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-bottom: 0;
left: 3px;
bottom: 0;
}
/* ICON - RESOURCES */
.icon.resources,
.icon.resources::after {
display: block;
box-sizing: border-box;
border-radius: 22px;
}
.icon.resources {
position: relative;
transform: scale(var(--icon-scale, 1));
width: 20px;
height: 20px;
border: 2px solid transparent;
}
.icon.resources::after {
content: "";
position: absolute;
width: 4px;
height: 4px;
background: currentColor;
top: 6px;
left: 6px;
box-shadow:
0 7px 0 1px,
0 -7px 0 1px,
-7px 0 0 1px,
7px 0 0 1px;
}
/* ICON - TALK */
.icon.talk {
transform: scale(var(--icon-scale, 1));
}
.icon.talk,
.icon.talk::after {
box-sizing: border-box;
position: relative;
display: block;
width: 20px;
height: 20px;
border-radius: 100px;
border: 2px dotted currentColor;
}
.icon.talk::after {
content: "";
position: absolute;
width: 8px;
height: 8px;
border: 1px solid transparent;
top: 4px;
left: 4px;
box-shadow:
0 0 0 2px,
inset 0 0 0 2px currentColor;
}
/* ICON - USER */
.icon.user,
.icon.user::after,
.icon.user::before {
display: block;
box-sizing: border-box;
border: 2px solid;
border-radius: 100px;
}
.icon.user {
overflow: hidden;
transform: scale(var(--icon-scale, 1));
width: 22px;
height: 22px;
position: relative;
}
.icon.user::after,
.icon.user::before {
content: "";
position: absolute;
top: 2px;
left: 5px;
width: 8px;
height: 8px;
}
.icon.user::after {
border-radius: 200px;
top: 11px;
left: 0px;
width: 18px;
height: 18px;
}
/* ICON - WORK */
.icon.work {
box-sizing: border-box;
position: relative;
display: block;
transform: scale(var(--icon-scale, 1));
width: 20px;
height: 20px;
border: 2px solid;
border-radius: 22px;
}
.icon.work::after,
.icon.work::before {
content: "";
display: block;
box-sizing: border-box;
position: absolute;
}
.icon.work::before {
width: 12px;
height: 6px;
border: 2px solid;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
top: 2px;
left: 2px;
border-bottom: 0;
}
.icon.work::after {
width: 18px;
height: 2px;
background: currentColor;
left: -1px;
top: 8px;
}
</style>
</head>
<body>
<div id="signup-login-wall">
<style>
#signup-login-wall {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10000;
background: var(--bg);
visibility: visible;
opacity: 1;
transition: all 0.33s;
}
body[data-user] #signup-login-wall {
visibility: hidden;
opacity: 0;
}
#signup-login-wall .limiter {
width: 95%;
position: relative;
background: rgba(128, 128, 128, 0.5);
max-width: 40em;
min-height: 22rem;
}
#signup-login-wall form {
width: 100%;
}
form div {
position: relative;
display: flex;
margin-bottom: 1em;
}
form label {
position: absolute;
top: 10px;
font-size: 30px;
margin: 10px;
padding: 0 10px;
background-color: var(--bg);
-webkit-transition:
top 0.2s ease-in-out,
font-size 0.2s ease-in-out;
transition:
top 0.2s ease-in-out,
font-size 0.2s ease-in-out;
}
form input:focus ~ label,
form input:valid ~ label {
top: -25px;
font-size: 20px;
}
form input {
width: 100%;
padding: 20px;
border: 1px solid var(--text);
font-size: 20px;
background-color: var(--bg);
color: var(--text);
}
form input:focus {
outline: none;
}
form button {
width: 100%;
padding: 20px;
border: 1px solid var(--text);
font-size: 20px;
background-color: var(--bg);
color: var(--text);
}
form button.primary {
background-color: var(--accent);
}
</style>
<div class="limiter">
<div class="tabs">
<div id="login-tab" class="tab">
<input
type="radio"
name="signup-login-tabs"
id="login-tab-input"
class="tab-switch"
checked="checked"
/>
<label for="login-tab-input" class="tab-label">
<div class="label">Log In</div>
</label>
<div class="tab-content">
<form
id="login-form"
action="/api/auth"
onreply="(user)=>{ document.body.dataset.user = user; }"
>
<div>
<input
id="login-username"
type="text"
name="username"
required
/>
<label for="login-username">username</label>
</div>
<div>
<input
id="login-password"
type="password"
name="password"
required
/>
<label for="login-password">password</label>
</div>
<div>
<button id="login-submit" type="submit" class="primary">
Log In
</button>
</div>
</form>
</div>
</div>
<div id="signup-tab" class="tab">
<input
type="radio"
name="signup-login-tabs"
id="signup-tab-input"
class="tab-switch"
/>
<label for="signup-tab-input" class="tab-label">
<div class="label">Sign Up</div>
</label>
<div class="tab-content">
<form id="signup-form" action="/api/users">
<script>
const form = document.currentScript.closest("form");
form.on_response = (response) => {
document.body.dataset.user = response.user;
console.dir({ response });
};
</script>
<div>
<input
id="signup-username"
type="text"
name="username"
required
/>
<label for="signup-username">username</label>
</div>
<div>
<input
id="signup-password"
type="password"
name="password"
required
/>
<label for="signup-password">password</label>
</div>
<button id="signup-submit" type="submit" class="primary">
Sign Up
</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- MAIN -->
<div class="tabs">
<div id="home" class="tab">
<input
type="radio"
name="top-level-tabs"
id="home-tab-input"
checked="checked"
class="tab-switch"
/>
<label for="home-tab-input" class="tab-label">
<div class="icon home"></div>
<div class="label">Home</div>
</label>
<div class="tab-content">This is the home tab.</div>
</div>
<div id="talk" class="tab">
<input type="radio" name="top-level-tabs" id="talk-tab-input" class="tab-switch" />
<label for="talk-tab-input" class="tab-label"
><div class="icon talk"></div>
<div class="label">Talk</div>
</label>
<div class="tab-content">
<style>
#talk .tab-content {
display: grid;
grid-template-columns: auto 1fr;
}
#talk .sidebar {
min-width: 100px;
}
#talk .room {
padding: 1rem;
}
</style>
<div class="sidebar resizable">
<ul>
<li>#one</li>
<li>#two</li>
<li>#three</li>
</ul>
</div>
<div class="room">This is a talk room.</div>
</div>
</div>
<div id="exchange" class="tab">
<input
type="radio"
name="top-level-tabs"
id="exchange-tab-input"
class="tab-switch"
/>
<label for="exchange-tab-input" class="tab-label"
><div class="icon exchange"></div>
<div class="label">Exchange</div></label
>
<div class="tab-content">This is the exchange tab.</div>
</div>
<div id="work" class="tab">
<input type="radio" name="top-level-tabs" id="work-tab-input" class="tab-switch" />
<label for="work-tab-input" class="tab-label"
><div class="icon work"></div>
<div class="label">Work</div>
</label>
<div class="tab-content">This is the work tab.</div>
</div>
<div id="resources" class="tab">
<input
type="radio"
name="top-level-tabs"
id="resources-tab-input"
class="tab-switch"
/>
<label for="resources-tab-input" class="tab-label"
><div class="icon resources"></div>
<div class="label">Resources</div></label
>
<div class="tab-content">This is the resources tab.</div>
</div>
<div id="calendar" class="tab">
<input
type="radio"
name="top-level-tabs"
id="calendar-tab-input"
class="tab-switch"
/>
<label for="calendar-tab-input" class="tab-label"
><div class="icon calendar"></div>
<div class="label">Calendar</div></label
>
<div class="tab-content">This is the calendar tab.</div>
</div>
<div id="user" class="tab">
<input type="radio" name="top-level-tabs" id="user-tab-input" class="tab-switch" />
<label for="user-tab-input" class="tab-label"
><div class="icon user"></div>
<div class="label">Profile</div></label
>
<div class="tab-content">This is the profile tab.</div>
</div>
</div>
</body>
<script>
document.addEventListener("DOMContentLoaded", () => {
const forms = document.querySelectorAll("form");
for (const form of forms) {
const script = form.querySelector("script");
form.onsubmit = async (event) => {
event.preventDefault();
const form_data = new FormData(form);
const body = Object.fromEntries(form_data.entries());
const url = form.action;
try {
// TODO: send session header
const response = await fetch(url, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!response.ok) {
const error_body = await response.json();
const error = error_body?.error;
if (form.on_error) {
return form.on_error(error);
}
alert(error.message ?? "Unknown error!");
return;
}
const response_body = await response.json();
if (form.on_response) {
return form.on_response(response_body);
}
} catch (error) {
console.dir({
error,
});
if (form.onerror) {
return form.onerror(error);
}
alert(error);
}
};
}
});
</script>
</html>