Scratch space for learning atproto app development

Merge pull request #4 from bluesky-social/paul/improvements

Some improvements to the UI

Changed files
+42 -5
src
pages
public
routes
+11 -3
src/pages/home.ts
···
import { html } from '../view'
import { shell } from './shell'
+
const TODAY = new Date().toDateString()
+
const STATUS_OPTIONS = [
'👍',
'👎',
···
statuses: Status[]
didHandleMap: Record<string, string>
profile?: { displayName?: string; handle: string }
+
myStatus?: Status
}
export function home(props: Props) {
···
})
}
-
function content({ statuses, didHandleMap, profile }: Props) {
+
function content({ statuses, didHandleMap, profile, myStatus }: Props) {
return html`<div id="root">
<div class="error"></div>
<div id="header">
···
${STATUS_OPTIONS.map(
(status) =>
html`<div
-
class="status-option"
+
class=${myStatus?.status === status
+
? 'status-option selected'
+
: 'status-option'}
data-value="${status}"
data-authed=${profile ? '1' : '0'}
>
···
</div>
${statuses.map((status, i) => {
const handle = didHandleMap[status.authorDid] || status.authorDid
+
const date = ts(status)
return html`
<div class=${i === 0 ? 'status-line no-line' : 'status-line'}>
<div>
···
</div>
<div class="desc">
<a class="author" href=${toBskyLink(handle)}>@${handle}</a>
-
is feeling ${status.status} on ${ts(status)}
+
${date === TODAY
+
? `is feeling ${status.status} today`
+
: `was feeling ${status.status} on ${date}`}
</div>
</div>
`
+4
src/pages/login.ts
···
<button type="submit">Log in</button>
${error ? html`<p>Error: <i>${error}</i></p>` : undefined}
</form>
+
<div class="signup-cta">
+
Don't have an account on the Atmosphere?
+
<a href="https://bsky.app">Sign up for Bluesky</a> to create one now!
+
</div>
</div>
</div>`
}
+19 -1
src/public/styles.css
···
--gray-100: #fafafa;
--gray-500: #666;
--gray-700: #333;
+
--primary-100: #d2e7ff;
+
--primary-200: #b1d3fa;
--primary-400: #2e8fff;
--primary-500: #0078ff;
--primary-600: #0066db;
···
}
.status-option:hover {
-
background-color: var(--gray-100);
+
background-color: var(--primary-100);
+
box-shadow: 0 0 0 1px var(--primary-400);
+
}
+
+
.status-option.selected {
+
box-shadow: 0 0 0 1px var(--primary-500);
+
background-color: var(--primary-100);
+
}
+
+
.status-option.selected:hover {
+
background-color: var(--primary-200);
}
.status-line {
···
.status-line .author:hover {
text-decoration: underline;
+
}
+
+
.signup-cta {
+
text-align: center;
+
text-wrap: balance;
+
margin-top: 1rem;
}
+8 -1
src/routes/index.ts
···
.orderBy('indexedAt', 'desc')
.limit(10)
.execute()
+
const myStatus = agent
+
? await ctx.db
+
.selectFrom('status')
+
.selectAll()
+
.where('authorDid', '=', agent.accountDid)
+
.executeTakeFirst()
+
: undefined
const didHandleMap = await ctx.resolver.resolveDidsToHandles(
statuses.map((s) => s.authorDid)
)
···
const { data: profile } = await agent.getProfile({ actor: session.did })
return res
.type('html')
-
.send(page(home({ statuses, didHandleMap, profile })))
+
.send(page(home({ statuses, didHandleMap, profile, myStatus })))
})
)