Scratch space for learning atproto app development

Finish the UI

Changed files
+58 -59
src
+17 -52
src/pages/home.ts
···
<button type="submit">Log out</button>
</div>
</form>`
-
: html`<p><a href="/login">Log in</a> to set your status!</p>`}
+
: html`<div class="session-form">
+
<div><a href="/login">Log in</a> to set your status!</div>
+
<div>
+
<a href="/login" class="button">Log in</a>
+
</div>
+
</div>`}
</div>
-
<div class="">
-
<div class="status-options">
-
${STATUS_OPTIONS.map(
-
(status) =>
-
html`<div class="status-option" data-value="${status}">
-
${status}
-
</div>`
-
)}
-
</div>
-
</div>
-
<div class="status-line no-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
-
</div>
-
<div class="status-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
-
</div>
-
<div class="status-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
-
</div>
-
<div class="status-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
-
</div>
-
<div class="status-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
-
</div>
-
<div class="status-line">
-
<div class="status">๐Ÿ‘</div>
-
<div class="desc">
-
<a class="author" href="/">@pfrazee.com</a>
-
is feeling ๐Ÿ‘ on Aug 12, 2024
-
</div>
+
<div class="status-options">
+
${STATUS_OPTIONS.map(
+
(status) =>
+
html`<div
+
class="status-option"
+
data-value="${status}"
+
data-authed=${profile ? '1' : '0'}
+
>
+
${status}
+
</div>`
+
)}
</div>
${statuses.map((status, i) => {
const handle = didHandleMap[status.authorDid] || status.authorDid
+16 -5
src/pages/login.ts
···
function content({ error }: Props) {
return html`<div id="root">
-
<form action="/login" method="post">
-
<input type="text" name="handle" placeholder="handle" required />
-
<button type="submit">Log in.</button>
-
${error ? html`<p>Error: <i>${error}</i></p>` : undefined}
-
</form>
+
<div id="header">
+
<h1>Statusphere</h1>
+
<p>Set your status on the Atmosphere.</p>
+
</div>
+
<div class="container">
+
<form action="/login" method="post" class="login-form">
+
<input
+
type="text"
+
name="handle"
+
placeholder="Enter your handle (eg alice.bsky.social)"
+
required
+
/>
+
<button type="submit">Log in</button>
+
${error ? html`<p>Error: <i>${error}</i></p>` : undefined}
+
</form>
+
</div>
</div>`
}
+6
src/public/home.js
···
Array.from(document.querySelectorAll('.status-option'), (el) => {
el.addEventListener('click', async (ev) => {
setError('')
+
+
if (el.dataset.authed !== '1') {
+
window.location = '/login'
+
return
+
}
+
const res = await fetch('/status', {
method: 'POST',
headers: { 'content-type': 'application/json' },
+19 -2
src/public/styles.css
···
/*
Common components
*/
-
button {
+
button, .button {
+
display: inline-block;
border: 0;
background-color: var(--primary-500);
border-radius: 50px;
color: #fff;
padding: 2px 10px;
cursor: pointer;
+
text-decoration: none;
}
-
button:hover {
+
button:hover, .button:hover {
background: var(--primary-400);
}
···
flex-direction: row;
align-items: center;
justify-content: space-between;
+
}
+
+
.login-form {
+
display: flex;
+
flex-direction: row;
+
gap: 6px;
+
border: 1px solid var(--border-color);
+
border-radius: 6px;
+
padding: 10px 16px;
+
background-color: #fff;
+
}
+
+
.login-form input {
+
flex: 1;
+
border: 0;
}
.status-options {