@meith/theme-raidframe 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE.md +165 -0
  2. package/package.json +33 -0
  3. package/src/index.ts +3 -0
  4. package/src/shared.tsx +133 -0
  5. package/src/slots/announcement.tsx +40 -0
  6. package/src/slots/auth-page.tsx +53 -0
  7. package/src/slots/board-index.tsx +35 -0
  8. package/src/slots/board-stats.tsx +52 -0
  9. package/src/slots/category-block.tsx +37 -0
  10. package/src/slots/discovery-view.tsx +122 -0
  11. package/src/slots/error-notice.tsx +26 -0
  12. package/src/slots/footer.tsx +34 -0
  13. package/src/slots/forum-display.tsx +81 -0
  14. package/src/slots/forum-jump.tsx +45 -0
  15. package/src/slots/forum-row.tsx +66 -0
  16. package/src/slots/header.tsx +67 -0
  17. package/src/slots/latest-posts.tsx +42 -0
  18. package/src/slots/latest-threads.tsx +42 -0
  19. package/src/slots/member-profile.tsx +102 -0
  20. package/src/slots/navigation.tsx +31 -0
  21. package/src/slots/notice.tsx +32 -0
  22. package/src/slots/pagination.tsx +48 -0
  23. package/src/slots/panel-nav.tsx +110 -0
  24. package/src/slots/panel-page.tsx +72 -0
  25. package/src/slots/panel-shell.tsx +33 -0
  26. package/src/slots/post-actions.tsx +29 -0
  27. package/src/slots/post-bit.tsx +225 -0
  28. package/src/slots/post-form.tsx +44 -0
  29. package/src/slots/redirect-notice.tsx +26 -0
  30. package/src/slots/search-form.tsx +102 -0
  31. package/src/slots/search-results.tsx +108 -0
  32. package/src/slots/shell.tsx +40 -0
  33. package/src/slots/subforum-list.tsx +26 -0
  34. package/src/slots/thread-row.tsx +74 -0
  35. package/src/slots/thread-view.tsx +75 -0
  36. package/src/slots/user-panel.tsx +118 -0
  37. package/src/slots/who-is-online.tsx +64 -0
  38. package/src/theme.ts +84 -0
  39. package/src/tokens.ts +104 -0
package/LICENSE.md ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@meith/theme-raidframe",
3
+ "version": "0.2.0",
4
+ "description": "A gaming theme for Meith — guild, raid and match boards — built on the default theme's slots.",
5
+ "license": "LGPL-3.0-or-later",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/meith-dev/meith.git",
9
+ "directory": "themes/raidframe"
10
+ },
11
+ "type": "module",
12
+ "main": "./src/index.ts",
13
+ "types": "./src/index.ts",
14
+ "files": [
15
+ "src",
16
+ "!src/**/*.test.*",
17
+ "!src/**/*.type-test.*"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@meith/theme-default": "^0.2.0",
24
+ "@meith/theme-kit": "^0.2.0",
25
+ "@meith/ui": "^0.2.0"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^19.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.2.18"
32
+ }
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { LIGHT_TOKENS, DARK_TOKENS, BROWSER_THEME_COLOR } from './tokens'
2
+
3
+ export { raidframeTheme } from './theme'
package/src/shared.tsx ADDED
@@ -0,0 +1,133 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ import type { TimeModel, UserRefModel } from '@meith/theme-kit'
4
+
5
+ export const MICRO =
6
+ 'font-mono text-[0.625rem] font-semibold uppercase tracking-[0.18em] text-muted-foreground'
7
+
8
+ export const HEADING = 'font-heading font-bold uppercase tracking-[0.12em]'
9
+
10
+ export const NUMERIC = 'font-mono tabular-nums'
11
+
12
+ export const LINK = 'text-foreground hover:text-primary'
13
+
14
+ export const MUTED_LINK = 'text-muted-foreground hover:text-primary'
15
+
16
+ export const BUTTON =
17
+ 'inline-flex items-center gap-1.5 border border-border bg-secondary px-3 py-1.5 font-mono text-[0.6875rem] font-semibold uppercase tracking-[0.14em] text-secondary-foreground hover:border-primary/70 hover:text-primary'
18
+
19
+ export const BUTTON_PRIMARY =
20
+ 'inline-flex items-center gap-1.5 border border-primary bg-primary px-3 py-1.5 font-mono text-[0.6875rem] font-bold uppercase tracking-[0.14em] text-primary-foreground hover:bg-primary-hover hover:border-primary-hover'
21
+
22
+ export const CHIP =
23
+ 'inline-flex items-center gap-1 border border-border bg-surface px-1.5 py-0.5 font-mono text-[0.625rem] font-semibold uppercase tracking-[0.12em]'
24
+
25
+ export const RULE =
26
+ 'h-px w-full bg-gradient-to-r from-primary/70 via-primary/15 to-transparent'
27
+
28
+ export function Frame({
29
+ children,
30
+ className,
31
+ as: Element = 'section',
32
+ ...rest
33
+ }: {
34
+ children: ReactNode
35
+ className?: string
36
+ as?: 'section' | 'div' | 'article'
37
+ 'aria-labelledby'?: string
38
+ 'aria-label'?: string
39
+ }) {
40
+ return (
41
+ <Element
42
+ {...rest}
43
+ className={`relative border border-border bg-card text-card-foreground shadow-elevation ${className ?? ''}`}
44
+ >
45
+ <Corner className="-top-px -left-px border-t-2 border-l-2" />
46
+ <Corner className="-top-px -right-px border-t-2 border-r-2" />
47
+ <Corner className="-bottom-px -left-px border-b-2 border-l-2" />
48
+ <Corner className="-right-px -bottom-px border-r-2 border-b-2" />
49
+ {children}
50
+ </Element>
51
+ )
52
+ }
53
+
54
+ function Corner({ className }: { className: string }) {
55
+ return (
56
+ <span
57
+ aria-hidden="true"
58
+ className={`pointer-events-none absolute z-10 size-2 border-primary/70 ${className}`}
59
+ />
60
+ )
61
+ }
62
+
63
+ export function PanelHead({
64
+ id,
65
+ title,
66
+ href,
67
+ aside,
68
+ }: {
69
+ id?: string
70
+ title: string
71
+ href?: string | null
72
+ aside?: ReactNode
73
+ }) {
74
+ return (
75
+ <>
76
+ <div className="flex flex-wrap items-center justify-between gap-2 border-b border-border bg-surface px-3 py-2">
77
+ <h2 id={id} className={`${HEADING} text-sm text-foreground`}>
78
+ {href == null ? (
79
+ title
80
+ ) : (
81
+ <a href={href} className="hover:text-primary">
82
+ {title}
83
+ </a>
84
+ )}
85
+ </h2>
86
+ {aside}
87
+ </div>
88
+ <div className={RULE} aria-hidden="true" />
89
+ </>
90
+ )
91
+ }
92
+
93
+ export function ReadPip({ unread, className }: { unread: boolean; className?: string }) {
94
+ return (
95
+ <span
96
+ aria-hidden="true"
97
+ className={`inline-block size-1.5 shrink-0 rotate-45 ${
98
+ unread
99
+ ? 'bg-forum-unread shadow-[0_0_8px_var(--color-forum-unread)]'
100
+ : 'border border-forum-read'
101
+ } ${className ?? ''}`}
102
+ />
103
+ )
104
+ }
105
+
106
+ export function Stamp({ at, className }: { at: TimeModel; className?: string }) {
107
+ return (
108
+ <time dateTime={at.iso} className={`${NUMERIC} ${className ?? ''}`}>
109
+ {at.label}
110
+ </time>
111
+ )
112
+ }
113
+
114
+ export function UserRef({
115
+ user,
116
+ className,
117
+ linked = true,
118
+ }: {
119
+ user: UserRefModel
120
+ className?: string
121
+ linked?: boolean
122
+ }) {
123
+ const classes = [className, user.nameClass].filter(Boolean).join(' ') || undefined
124
+
125
+ if (!linked || user.profileHref === null) {
126
+ return <span className={classes}>{user.username}</span>
127
+ }
128
+ return (
129
+ <a href={user.profileHref} className={classes}>
130
+ {user.username}
131
+ </a>
132
+ )
133
+ }
@@ -0,0 +1,40 @@
1
+ import type { AnnouncementModel } from '@meith/theme-kit'
2
+
3
+ import { Frame, HEADING, MICRO, Stamp, UserRef } from '../shared'
4
+
5
+ export function Announcement({ title, bodyHtml, postedBy, postedAt, forum }: AnnouncementModel) {
6
+ return (
7
+ <Frame as="article">
8
+ <div className="flex flex-wrap items-center justify-between gap-2 border-b border-border bg-surface px-3 py-2">
9
+ <span className={`${MICRO} text-primary`}>announcement</span>
10
+ {forum !== null && (
11
+ <a href={forum.href} className={`${MICRO} hover:text-primary`}>
12
+ {forum.label}
13
+ </a>
14
+ )}
15
+ </div>
16
+
17
+ <div className="flex flex-col gap-2 px-4 py-3">
18
+ <h2 className={`${HEADING} text-base text-foreground`}>{title}</h2>
19
+
20
+ <div
21
+ className="prose-md text-sm text-foreground"
22
+ dangerouslySetInnerHTML={{ __html: bodyHtml }}
23
+ />
24
+
25
+ <p className={MICRO}>
26
+ {postedBy === null ? (
27
+ 'posted'
28
+ ) : (
29
+ <>
30
+ {'posted by '}
31
+ <UserRef user={postedBy} className="text-primary hover:underline" />
32
+ </>
33
+ )}
34
+ {' · '}
35
+ <Stamp at={postedAt} />
36
+ </p>
37
+ </div>
38
+ </Frame>
39
+ )
40
+ }
@@ -0,0 +1,53 @@
1
+ import type { AuthPageModel } from '@meith/theme-kit'
2
+
3
+ import { Frame, HEADING, MICRO } from '../shared'
4
+
5
+ export function AuthPage({ title, alert, links, regions }: AuthPageModel) {
6
+ return (
7
+ <main
8
+ id="board-content"
9
+ tabIndex={-1}
10
+ className="flex flex-1 flex-col items-center justify-center p-4"
11
+ >
12
+ <Frame className="w-full max-w-sm">
13
+ <div className="flex flex-col gap-5 px-5 py-5">
14
+ <div className="flex flex-col gap-1">
15
+ <p className={`${MICRO} text-primary`}>access</p>
16
+ <h1 className={`${HEADING} text-2xl text-foreground`}>{title}</h1>
17
+ {regions.lede !== undefined && (
18
+ <p className="text-sm text-muted-foreground">{regions.lede}</p>
19
+ )}
20
+ </div>
21
+
22
+ {alert !== null && (
23
+ <p
24
+ role="alert"
25
+ className="border border-l-[3px] border-border border-l-destructive bg-surface px-3 py-2 text-sm"
26
+ >
27
+ {alert}
28
+ </p>
29
+ )}
30
+
31
+ {regions.note !== undefined && (
32
+ <p className="text-sm text-muted-foreground">{regions.note}</p>
33
+ )}
34
+
35
+ {regions.form}
36
+
37
+ {links.length > 0 && (
38
+ <div className="flex flex-col gap-1 border-t border-border pt-3 text-sm text-muted-foreground">
39
+ {links.map((link) => (
40
+ <span key={link.href}>
41
+ {link.lead === null ? null : `${link.lead} `}
42
+ <a href={link.href} className="font-medium text-foreground hover:text-primary">
43
+ {link.label}
44
+ </a>
45
+ </span>
46
+ ))}
47
+ </div>
48
+ )}
49
+ </div>
50
+ </Frame>
51
+ </main>
52
+ )
53
+ }
@@ -0,0 +1,35 @@
1
+ import type { BoardIndexModel } from '@meith/theme-kit'
2
+
3
+ import { BUTTON } from '../shared'
4
+
5
+ export function BoardIndex({ markAllReadAction, regions }: BoardIndexModel) {
6
+ const latest = regions.latest ?? null
7
+
8
+ return (
9
+ <div className="flex flex-col gap-4 p-4">
10
+ {regions.announcements !== undefined && (
11
+ <div className="flex flex-col gap-4 empty:hidden">{regions.announcements}</div>
12
+ )}
13
+
14
+ <div className="flex flex-col gap-4 lg:flex-row lg:items-start">
15
+ <div className="flex min-w-0 flex-1 flex-col gap-4">{regions.categories}</div>
16
+
17
+ <aside className="flex flex-col gap-4 empty:hidden lg:w-80 lg:shrink-0">
18
+ {regions.online}
19
+ {regions.stats}
20
+ {latest}
21
+ </aside>
22
+ </div>
23
+
24
+ {regions.plugins}
25
+
26
+ {markAllReadAction !== null && (
27
+ <form action={markAllReadAction} method="post">
28
+ <button type="submit" className={BUTTON}>
29
+ mark all read
30
+ </button>
31
+ </form>
32
+ )}
33
+ </div>
34
+ )
35
+ }
@@ -0,0 +1,52 @@
1
+ import type { BoardStatsModel } from '@meith/theme-kit'
2
+
3
+ import { Frame, MICRO, NUMERIC, PanelHead, Stamp, UserRef } from '../shared'
4
+
5
+ function Stat({ label, value }: { label: string; value: number }) {
6
+ return (
7
+ <div className="border border-border bg-surface px-2 py-1.5">
8
+ <dt className={MICRO}>{label}</dt>
9
+ <dd className={`${NUMERIC} text-lg leading-tight font-semibold text-foreground`}>{value}</dd>
10
+ </div>
11
+ )
12
+ }
13
+
14
+ export function BoardStats({
15
+ threadCount,
16
+ postCount,
17
+ memberCount,
18
+ newestMember,
19
+ computedAt,
20
+ }: BoardStatsModel) {
21
+ return (
22
+ <Frame aria-labelledby="board-stats-heading">
23
+ <PanelHead id="board-stats-heading" title="Board statistics" />
24
+
25
+ <dl className="grid grid-cols-3 gap-1.5 px-3 py-3">
26
+ <Stat label="threads" value={threadCount} />
27
+ <Stat label="posts" value={postCount} />
28
+ <Stat label="members" value={memberCount} />
29
+ </dl>
30
+
31
+ <p className={`${MICRO} border-t border-border px-3 py-2 normal-case`}>
32
+ <span className="uppercase">newest member</span>
33
+ {': '}
34
+ {newestMember === null ? (
35
+ '—'
36
+ ) : (
37
+ <UserRef user={newestMember} className="text-primary hover:underline" />
38
+ )}
39
+ </p>
40
+
41
+ <p className={`${MICRO} border-t border-border px-3 py-1.5 normal-case`}>
42
+ {computedAt === null ? (
43
+ <span className="uppercase">not counted yet</span>
44
+ ) : (
45
+ <>
46
+ <span className="uppercase">counted</span> <Stamp at={computedAt} />
47
+ </>
48
+ )}
49
+ </p>
50
+ </Frame>
51
+ )
52
+ }
@@ -0,0 +1,37 @@
1
+ import type { CategoryBlockModel } from '@meith/theme-kit'
2
+
3
+ import { Frame, MICRO, PanelHead } from '../shared'
4
+
5
+ export function CategoryBlock({ category, children }: CategoryBlockModel) {
6
+ return (
7
+ <Frame>
8
+ <PanelHead title={category.title} href={category.href} />
9
+
10
+ {category.description !== null && (
11
+ <p className="border-b border-border px-3 py-1.5 text-xs text-muted-foreground">
12
+ {category.description}
13
+ </p>
14
+ )}
15
+
16
+ <table className="w-full border-collapse text-sm">
17
+ <thead>
18
+ <tr className={`${MICRO} text-left`}>
19
+ <th scope="col" className="px-3 py-1.5 font-semibold">
20
+ Forum
21
+ </th>
22
+ <th scope="col" className="w-16 px-2 py-1.5 text-right font-semibold">
23
+ Threads
24
+ </th>
25
+ <th scope="col" className="w-16 px-2 py-1.5 text-right font-semibold">
26
+ Posts
27
+ </th>
28
+ <th scope="col" className="hidden w-60 px-3 py-1.5 font-semibold sm:table-cell">
29
+ Last post
30
+ </th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>{children}</tbody>
34
+ </table>
35
+ </Frame>
36
+ )
37
+ }
@@ -0,0 +1,122 @@
1
+ import type { DiscoveryViewModel, TabModel } from '@meith/theme-kit'
2
+
3
+ import { Frame, HEADING, MICRO, NUMERIC, RULE, Stamp } from '../shared'
4
+
5
+ const TAB =
6
+ 'inline-flex items-center border px-3 py-1.5 font-mono text-[0.6875rem] font-semibold uppercase tracking-[0.14em] whitespace-nowrap'
7
+
8
+ const CURRENT = 'border-primary bg-primary text-primary-foreground'
9
+ const OTHER = 'border-border bg-card text-muted-foreground hover:border-primary/60 hover:text-primary'
10
+
11
+ function Tabs({ label, tabs }: { label: string; tabs: readonly TabModel[] }) {
12
+ if (tabs.length === 0) return null
13
+
14
+ return (
15
+ <nav aria-label={label}>
16
+ <ul className="flex flex-wrap items-center gap-1.5">
17
+ {tabs.map((tab) => (
18
+ <li key={tab.href}>
19
+ <a
20
+ href={tab.href}
21
+ {...(tab.isCurrent ? { 'aria-current': 'page' as const } : {})}
22
+ className={`${TAB} ${tab.isCurrent ? CURRENT : OTHER}`}
23
+ >
24
+ {tab.label}
25
+ </a>
26
+ </li>
27
+ ))}
28
+ </ul>
29
+ </nav>
30
+ )
31
+ }
32
+
33
+ export function DiscoveryView({
34
+ title,
35
+ blurb,
36
+ tabsLabel,
37
+ tabs,
38
+ rows,
39
+ nextHref,
40
+ nextLabel,
41
+ emptyMessage,
42
+ refusal,
43
+ }: DiscoveryViewModel) {
44
+ return (
45
+ <main
46
+ id="board-content"
47
+ tabIndex={-1}
48
+ className="mx-auto flex w-full max-w-5xl flex-1 flex-col gap-4 p-4"
49
+ >
50
+ <div className="border border-border bg-card shadow-elevation">
51
+ <div className="px-4 py-3">
52
+ <p className={MICRO}>listing</p>
53
+ <h1 className={`${HEADING} text-xl text-foreground`}>{title}</h1>
54
+ <p className="mt-1 text-xs text-muted-foreground">{blurb}</p>
55
+ </div>
56
+ <div className={RULE} aria-hidden="true" />
57
+ </div>
58
+
59
+ <Tabs label={tabsLabel} tabs={tabs} />
60
+
61
+ {refusal !== null ? (
62
+ <p
63
+ role="alert"
64
+ className="border border-l-[3px] border-border border-l-primary bg-card px-3 py-2 text-sm"
65
+ >
66
+ {refusal.message}{' '}
67
+ <a href={refusal.signInHref} className="font-medium text-foreground hover:text-primary">
68
+ {refusal.signInLabel}
69
+ </a>
70
+ </p>
71
+ ) : rows.length === 0 ? (
72
+ <Frame>
73
+ <p className="px-4 py-6 text-center text-sm text-muted-foreground">{emptyMessage}</p>
74
+ </Frame>
75
+ ) : (
76
+ <Frame>
77
+ <ul className="divide-y divide-border">
78
+ {rows.map((row) => (
79
+ <li
80
+ key={row.threadId}
81
+ className="flex flex-col gap-1.5 px-4 py-3 hover:bg-secondary/50 sm:flex-row sm:items-center sm:justify-between sm:gap-6"
82
+ >
83
+ <div className="flex min-w-0 flex-col gap-1">
84
+ <a
85
+ href={row.href}
86
+ className="truncate text-sm font-medium text-foreground hover:text-primary"
87
+ >
88
+ {row.title}
89
+ </a>
90
+ <p className={`${MICRO} truncate normal-case`}>
91
+ <a href={row.forum.href} className="uppercase hover:text-primary">
92
+ {row.forum.label}
93
+ </a>
94
+ <span className="text-border">{' | '}</span>
95
+ <span className="uppercase">started by</span> {row.authorUsername}
96
+ </p>
97
+ </div>
98
+
99
+ <p className={`${MICRO} shrink-0 normal-case sm:text-right`}>
100
+ <span className={`${NUMERIC} text-foreground`}>{row.replyCount}</span>{' '}
101
+ <span className="uppercase">{row.replyCount === 1 ? 'reply' : 'replies'}</span>
102
+ <span className="block">
103
+ <Stamp at={row.lastPostAt} />
104
+ {row.lastPostUsername === null ? null : ` by ${row.lastPostUsername}`}
105
+ </span>
106
+ </p>
107
+ </li>
108
+ ))}
109
+ </ul>
110
+ </Frame>
111
+ )}
112
+
113
+ {nextHref !== null && (
114
+ <p>
115
+ <a href={nextHref} className={`${MICRO} hover:text-primary`}>
116
+ {nextLabel} →
117
+ </a>
118
+ </p>
119
+ )}
120
+ </main>
121
+ )
122
+ }