Scratch space for learning atproto app development

Highlight current status

Changed files
+26 -4
src
pages
public
routes
+5 -2
src/pages/home.ts
···
statuses: Status[]
didHandleMap: Record<string, string>
profile?: { displayName?: string; handle: string }
}
export function home(props: Props) {
···
})
}
-
function content({ statuses, didHandleMap, profile }: Props) {
return html`<div id="root">
<div class="error"></div>
<div id="header">
···
${STATUS_OPTIONS.map(
(status) =>
html`<div
-
class="status-option"
data-value="${status}"
data-authed=${profile ? '1' : '0'}
>
···
statuses: Status[]
didHandleMap: Record<string, string>
profile?: { displayName?: string; handle: string }
+
myStatus?: Status
}
export function home(props: 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=${myStatus?.status === status
+
? 'status-option selected'
+
: 'status-option'}
data-value="${status}"
data-authed=${profile ? '1' : '0'}
>
+13 -1
src/public/styles.css
···
--gray-100: #fafafa;
--gray-500: #666;
--gray-700: #333;
--primary-400: #2e8fff;
--primary-500: #0078ff;
--primary-600: #0066db;
···
}
.status-option:hover {
-
background-color: var(--gray-100);
}
.status-line {
···
--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(--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 {
+8 -1
src/routes/index.ts
···
.orderBy('indexedAt', 'desc')
.limit(10)
.execute()
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 })))
})
)
···
.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, myStatus })))
})
)