Something went wrong. Try again.
Tea journaling on ATProto (alpha)
Something went wrong. Try again.
21 kB · 662 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663package components
import ( "fmt" "tangled.org/arabica.social/arabica/internal/entities/arabica" "tangled.org/arabica.social/arabica/internal/web/assets" "tangled.org/arabica.social/arabica/internal/web/bff" "tangled.org/pdewey.com/atp")
// BeanSummaryProps defines props for displaying bean metadata inline.// Used in both bean feed cards and brew feed cards.type BeanSummaryProps struct { Bean *arabica.Bean CoffeeAmount int // if > 0, shows scale icon + "Xg" (brew context)}
// BeanSummary renders the bean name, roaster, and attribute tags.templ BeanSummary(props BeanSummaryProps) { if props.Bean != nil { <div class="font-bold text-primary text-base"> if props.Bean.Name != "" { { props.Bean.Name } } else { { props.Bean.Origin } } </div> if props.Bean.Roaster != nil && props.Bean.Roaster.Name != "" { <div class="text-sm text-emphasis mt-0.5"> <span class="inline-flex items-center gap-1 font-medium"> @IconStore() { props.Bean.Roaster.Name } </span> </div> } <div class="text-xs text-muted mt-1 flex flex-wrap gap-x-2 gap-y-1"> if props.Bean.Origin != "" { <span class="inline-flex items-center gap-1"> @IconMapPin() { props.Bean.Origin } </span> } if props.Bean.RoastLevel != "" { <span class="inline-flex items-center gap-1"> @IconFlame() { props.Bean.RoastLevel } </span> } if props.Bean.Variety != "" { <span class="inline-flex items-center gap-1"> @IconLeaf() { props.Bean.Variety } </span> } if props.Bean.Process != "" { <span class="inline-flex items-center gap-1"> @IconSprout() { props.Bean.Process } </span> } if props.Bean.Rating != nil { <span class="inline-flex items-center gap-1"> @IconStar() { bff.FormatBeanRating(props.Bean.Rating) } </span> } if props.CoffeeAmount > 0 { <span class="inline-flex items-center gap-1"> @IconScale() { fmt.Sprintf("%dg", props.CoffeeAmount) } </span> } </div> }}
// TypeBadge renders a colored pill with an icon and type label for record type identification.templ TypeBadge(recordType string) { switch recordType { case "brew": <span class="type-badge type-badge-brew"> @IconCoffee() Brew </span> case "bean": <span class="type-badge type-badge-bean"> @IconBean() Bean </span> case "recipe": <span class="type-badge type-badge-recipe"> @IconFileText() Recipe </span> case "roaster": <span class="type-badge type-badge-roaster"> @IconStore() Roaster </span> case "grinder": <span class="type-badge type-badge-grinder"> @IconGear() Grinder </span> case "brewer": <span class="type-badge type-badge-brewer"> @IconBrewer() Brewer </span> }}
// RecordViewHeaderProps defines properties for the shared record view header.type RecordViewHeaderProps struct { RecordType string // "brew", "bean", "roaster", "grinder", "brewer", "recipe" Title string Timestamp string // formatted date string TimestampISO string // ISO 8601 for <time> element AuthorDID string AuthorHandle string AuthorDisplay string AuthorAvatar string}
// RecordViewHeader renders the tinted header region with author attribution and type badge.templ RecordViewHeader(props RecordViewHeaderProps) { <div class={ "record-view-header", "record-view-header-" + props.RecordType }> if props.AuthorHandle != "" { <div class="record-view-author"> <a href={ templ.SafeURL("/profile/" + props.AuthorHandle) } class="flex-shrink-0"> @Avatar(AvatarProps{ AvatarURL: props.AuthorAvatar, DisplayName: props.AuthorDisplay, Size: "md", }) </a> <div class="record-view-author-info"> <div class="record-view-author-names"> if props.AuthorDisplay != "" { <a href={ templ.SafeURL("/profile/" + props.AuthorHandle) } class="record-view-author-displayname"> { props.AuthorDisplay } </a> } <a href={ templ.SafeURL("/profile/" + props.AuthorHandle) } class="record-view-author-handle"> { "@" + atp.DisplayHandle(props.AuthorHandle) } </a> </div> <div class="record-view-meta"> <time datetime={ props.TimestampISO } data-local="long">{ props.Timestamp }</time> </div> </div> @TypeBadge(props.RecordType) </div> } else { <div class="record-view-meta mb-3"> @TypeBadge(props.RecordType) <time datetime={ props.TimestampISO } data-local="long">{ props.Timestamp }</time> </div> } if props.Title != "" { <h2 class="record-view-title">{ props.Title }</h2> } </div>}
// EmptyStateProps defines properties for empty state messagingtype EmptyStateProps struct { Message string SubMessage string ActionURL string ActionText string}
// EmptyState renders an empty state cardtempl EmptyState(props EmptyStateProps) { @Card(CardProps{InnerCard: true, Class: "text-center"}, emptyStateContent(props))}
templ emptyStateContent(props EmptyStateProps) { <p class="text-secondary text-lg mb-4 font-medium">{ props.Message }</p> if props.SubMessage != "" { <p class="text-sm text-emphasis mb-4">{ props.SubMessage }</p> } if props.ActionURL != "" && props.ActionText != "" { <a href={ templ.SafeURL(props.ActionURL) } class="inline-block btn-primary py-3 px-6 rounded-lg" > { props.ActionText } </a> }}
// DetailFieldProps defines properties for a labeled detail fieldtype DetailFieldProps struct { Label string Value string LinkHref string // Optional: wraps value in a link Icon templ.Component // Optional: icon rendered before the label}
// DetailField renders a labeled value with a "Not specified" fallbacktempl DetailField(props DetailFieldProps) { <div class="section-box"> <h3 class="text-sm font-medium text-muted uppercase tracking-wider mb-2"> if props.Icon != nil { <span class="inline-flex items-center gap-1"> @props.Icon { props.Label } </span> } else { { props.Label } } </h3> if props.Value != "" && props.LinkHref != "" { <a href={ templ.SafeURL(props.LinkHref) } class="font-semibold text-primary hover:underline">{ props.Value }</a> } else if props.Value != "" { <div class="font-semibold text-primary">{ props.Value }</div> } else { <span class="text-placeholder">Not specified</span> } </div>}
// DetailStackedProps defines properties for the typography-driven detail components.type DetailStackedProps struct { Label string Value string LinkHref string // Optional: wraps value in a link Icon templ.Component // Optional: icon rendered before the label Large bool // Uses detail-value-lg for primary details}
// DetailStacked renders a label above a value with no container box.templ DetailStacked(props DetailStackedProps) { if props.Value != "" || props.LinkHref == "" { <div class="detail-stacked"> <span class="detail-label"> if props.Icon != nil { <span class="inline-flex items-center gap-1"> @props.Icon { props.Label } </span> } else { { props.Label } } </span> if props.Value != "" && props.LinkHref != "" { <a href={ templ.SafeURL(props.LinkHref) } class={ templ.Classes( templ.KV("detail-value-lg", props.Large), templ.KV("detail-value", !props.Large), ) } > { props.Value } </a> } else if props.Value != "" { <span class={ templ.Classes( templ.KV("detail-value-lg", props.Large), templ.KV("detail-value", !props.Large), ) } > { props.Value } </span> } else { <span class="text-sm" style="color: var(--text-muted)">—</span> } </div> }}
// DetailInline renders a label and value side by side on one line.templ DetailInline(props DetailStackedProps) { if props.Value != "" { <div class="detail-inline"> <span class="detail-label"> if props.Icon != nil { <span class="inline-flex items-center gap-1"> @props.Icon { props.Label } </span> } else { { props.Label } } </span> if props.LinkHref != "" { <a href={ templ.SafeURL(props.LinkHref) } class="detail-value">{ props.Value }</a> } else { <span class="detail-value">{ props.Value }</span> } </div> }}
// JournalField renders a ledger-style row: label left, value right, with a faint separator.templ JournalField(props DetailStackedProps) { if props.Value != "" { <div class="journal-field"> <span class="detail-label"> if props.Icon != nil { <span class="inline-flex items-center gap-1"> @props.Icon { props.Label } </span> } else { { props.Label } } </span> if props.LinkHref != "" { <a href={ templ.SafeURL(props.LinkHref) } class="detail-value hover:underline">{ props.Value }</a> } else { <span class="detail-value">{ props.Value }</span> } </div> }}
type PageHeaderProps struct { Title string BackURL string ActionURL string ActionText string ActionClass string // Optional custom class for action button}
templ PageHeader(props PageHeaderProps) { <div class="mb-6 flex items-center justify-between"> <div class="flex items-center gap-3"> if props.BackURL != "" { @BackButton() } <h2 class="page-title">{ props.Title }</h2> </div> if props.ActionURL != "" && props.ActionText != "" { <a href={ templ.SafeURL(props.ActionURL) } class={ templ.Classes( templ.KV("btn-primary", props.ActionClass == ""), templ.KV(props.ActionClass, props.ActionClass != ""), ) } > { props.ActionText } </a> } </div>}
type WelcomeCardProps struct { IsAuthenticated bool UserDID string AppName string // "arabica" or "oolong" — toggles per-app copy + buttons}
// WelcomeCard renders the authenticated welcome with action buttons (used on home page)templ WelcomeCard(props WelcomeCardProps) { if props.IsAuthenticated { if props.AppName == "oolong" { @welcomeAuthenticatedOolong(props.UserDID) } else { @welcomeAuthenticatedArabica(props.UserDID) } }}
// WelcomeAuthenticated is the legacy two-arg entry point retained for// any caller still using it. New callers should pass WelcomeCardProps// (with AppName) so the per-app variants render.templ WelcomeAuthenticated(userDID string) { @welcomeAuthenticatedArabica(userDID)}
templ welcomeAuthenticatedArabica(userDID string) { <div class="text-center mb-8 pt-4"> <h1 class="text-3xl sm:text-4xl font-semibold text-primary mb-6">Your coffee journey, documented.</h1> <div class="grid grid-cols-2 sm:grid-cols-4 gap-3 max-w-xl mx-auto"> <a href="/brews/new" class="home-action-primary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">Log Brew</span> </a> <a href="/my-coffee" class="home-action-secondary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">My Coffee</span> </a> <a href="/recipes" class="home-action-secondary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">Recipes</span> </a> <a href={ templ.SafeURL("/profile/" + userDID) } class="home-action-secondary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">Profile</span> </a> </div> </div>}
templ welcomeAuthenticatedOolong(userDID string) { <div class="text-center mb-8 pt-4"> <h1 class="text-3xl sm:text-4xl font-semibold text-primary mb-6">Your tea journey, documented.</h1> <div class="grid grid-cols-3 gap-3 max-w-xl mx-auto"> <a href="/brews/new" class="home-action-primary block text-center py-4 px-4 rounded-xl" > <span class="text-base font-semibold">Log Steep</span> </a> <a href="/my-tea" class="home-action-secondary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">My Tea</span> </a> <a href={ templ.SafeURL("/profile/" + userDID) } class="home-action-secondary block text-center py-4 px-4 rounded-xl"> <span class="text-base font-semibold">Profile</span> </a> </div> </div>}
// WelcomeHero renders the landing hero for unauthenticated users.// Currently a single coffee-flavored variant. Per-app messaging on// the hero (and the per-app /about / /terms pages) lands in Phase 4e.templ WelcomeHero() { <div class="text-center mb-8 pt-4"> <h1 class="text-3xl sm:text-4xl font-semibold text-primary mb-3">Your coffee journey, documented.</h1> <p class="text-lg text-emphasis max-w-xl mx-auto mb-3">Log every brew, track your beans and equipment, and share your coffee story with the community.</p> <p class="text-sm text-faint"> <a href="/atproto" class="hover:text-emphasis transition-colors">Built on AT Protocol</a> — you own your data. </p> </div>}
// WelcomeHeroFor returns the hero matching the running app. Unauth'd// homepage callers pass the app name so the tea variant lands in// oolong without an extra page-per-app.templ WelcomeHeroFor(appName string) { if appName == "oolong" { <div class="text-center mb-8 pt-4"> <h1 class="text-3xl sm:text-4xl font-semibold text-primary mb-3">Your tea journey, documented.</h1> <p class="text-lg text-emphasis max-w-xl mx-auto mb-3">Log every steep, track your teaware and vendors, and share your tea story with the community.</p> <p class="text-sm text-faint"> <a href="/atproto" class="hover:text-emphasis transition-colors">Built on AT Protocol</a> — you own your data. </p> </div> } else { @WelcomeHero() }}
// WelcomeLoginCard renders a compact login card for unauthenticated userstempl WelcomeLoginCard() { <div class="card p-6 mb-8 max-w-md mx-auto"> <h2 class="text-lg font-semibold text-primary mb-4 text-center">Log in to get started</h2> <form method="POST" action="/auth/login"> <div class="relative"> <input type="text" id="handle" name="handle" placeholder="your-handle.bsky.social" autocomplete="off" required class="w-full form-input-lg" /> <div id="autocomplete-results" class="hidden handle-dropdown"></div> </div> <button type="submit" class="btn-primary w-full mt-3 py-3 px-8 font-semibold" > Log In </button> </form> <div class="mt-4 text-sm text-muted text-center"> <a href="/join/create" class="font-medium text-secondary hover:text-primary transition-colors hover:underline">Create an account</a> <span class="mx-1.5 text-placeholder">·</span> <a href="/about" class="text-muted hover:text-secondary transition-colors hover:underline">Learn more</a> </div> <details class="mt-4"> <summary class="text-faint text-sm cursor-pointer hover:text-emphasis transition-colors text-center">What's an Atmosphere account?</summary> <p class="text-muted mt-2 text-sm leading-relaxed"> One account { "for" } the entire <a href="/atproto" class="link">AT Protocol</a> ecosystem. Sign up once and use it across Arabica, <a href="https://bsky.app" class="link" target="_blank" rel="noopener noreferrer">Bluesky</a>, <a href="https://leaflet.pub" class="link" target="_blank" rel="noopener noreferrer">Leaflet</a>, and more. Your data is portable — you own it. </p> </details> <script src={ assets.JSHrefFor("handle-autocomplete.js") }></script> </div>}
templ AboutInfoCard() { <div class="card p-6 mb-6"> <h3 class="text-lg font-bold text-primary mb-3">About Arabica</h3> <ul class="text-secondary space-y-2 leading-relaxed mb-3"> <li>Add tasting notes and ratings to each brew</li> <li>Track brewing variables like temperature, time, and grind size</li> <li>Organize beans by origin and roaster</li> <li><strong>Portable:</strong> Own your coffee brewing history</li> <li><strong>Decentralized:</strong> Your data lives in your Personal Data Server (PDS)</li> </ul> <a href="/about" class="text-sm text-emphasis hover:text-primary transition-colors hover:underline">Learn more</a> </div>}
// UserBadgeProps defines properties for user badge (avatar + name + handle)type UserBadgeProps struct { ProfileURL string // URL to link to (e.g., "/profile/handle") AvatarURL string DisplayName string Handle string TimeAgo string // Optional timestamp to display Size string // "sm" or "md" - defaults to "md"}
// UserBadge renders a user avatar with display name and handle, properly alignedtempl UserBadge(props UserBadgeProps) { <div class="flex items-center gap-3"> <a href={ templ.SafeURL(props.ProfileURL) } class="flex-shrink-0"> @Avatar(AvatarProps{ AvatarURL: props.AvatarURL, DisplayName: props.DisplayName, Size: props.Size, }) </a> <div class="flex-1 min-w-0"> <div class={ templ.Classes( "flex items-center gap-2", templ.KV("flex-wrap", props.Size == "sm"), ) } > if props.DisplayName != "" { <a href={ templ.SafeURL(props.ProfileURL) } class={ templ.Classes( "text-primary truncate", templ.KV("font-medium hover:text-emphasis", props.Size == "sm"), templ.KV("link-bold", props.Size == "md" || props.Size == ""), ) } > { props.DisplayName } </a> } <a href={ templ.SafeURL(props.ProfileURL) } class={ templ.Classes( "truncate", templ.KV("text-sm text-muted hover:text-secondary", props.Size == "sm"), templ.KV("link text-sm", props.Size == "md" || props.Size == ""), ) } > { "@" + atp.DisplayHandle(props.Handle) } </a> if props.Size == "sm" && props.TimeAgo != "" { <span class="text-faint text-sm">{ props.TimeAgo }</span> } </div> if (props.Size == "md" || props.Size == "") && props.TimeAgo != "" { <span class="text-faint text-sm">{ props.TimeAgo }</span> } </div> </div>}
// AvatarProps defines properties for avatar renderingtype AvatarProps struct { AvatarURL string DisplayName string Size string // "sm", "md", "lg" - defaults to "md" if empty}
// Avatar renders a user avatar with safety checks and fallback// Supports three sizes: sm (w-8 h-8), md (w-12 h-12), lg (w-20 h-20)templ Avatar(props AvatarProps) { if props.AvatarURL != "" && bff.SafeAvatarURL(props.AvatarURL) != "" { <img src={ bff.SafeAvatarURL(props.AvatarURL) } alt="" class={ avatarClass(props.Size) } loading="lazy" width={ avatarDimension(props.Size) } height={ avatarDimension(props.Size) } /> } else { <div class={ avatarPlaceholderClass(props.Size) }> <span class={ avatarTextClass(props.Size) }> if props.DisplayName != "" && len(props.DisplayName) > 0 { { props.DisplayName[:1] } } else { ? } </span> </div> }}
// avatarClass returns the CSS class for avatar images based on sizefunc avatarClass(size string) string { switch size { case "sm": return "avatar-sm" case "lg": return "avatar-lg" default: return "avatar-md" }}
// avatarDimension returns the pixel dimension string for avatar images based on sizefunc avatarDimension(size string) string { switch size { case "sm": return "32" case "lg": return "80" default: return "48" }}
// avatarPlaceholderClass returns the CSS class for avatar placeholders based on sizefunc avatarPlaceholderClass(size string) string { switch size { case "sm": return "avatar-placeholder-sm" case "lg": return "avatar-placeholder-lg" default: return "avatar-placeholder-md" }}
// avatarTextClass returns the CSS class for avatar text based on sizefunc avatarTextClass(size string) string { switch size { case "sm": return "avatar-text-sm" case "lg": return "avatar-text-lg" default: return "avatar-text-md" }}
// RecipeAlphaWarning displays a warning banner about recipes being in early alpha.// TODO: remove this later once recipes are stabletempl RecipeAlphaWarning() { <div class="alert-warning mb-6"> <div class="flex items-start gap-3"> <span class="text-xl leading-none mt-0.5">⚠️</span> <div class="text-sm"> <p class="font-bold text-base mb-1">Recipes are in early alpha</p> <p class="mb-2"> The recipe format may change significantly as we figure out what works best (e.g. it may be completely redesigned from the ground up with a more powerful recipe creator system). If that happens, your brews won't break – brew fields are filled in from the recipe at creation time, so they stand on their own. Only the recipe record itself would need to be recreated. </p> <p class="mb-2"> Feedback is very welcome! Arabica has had a pourover bias so far (due to its developer's preferences), so input from espresso folks is especially appreciated. </p> <p class="text-xs alert-warning-muted"> If you have feedback or suggestions (or comments) reach out on Bluesky or open an issue on Tangled or GitHub. </p> </div> </div> </div>}