@ginhotaru282/reader 0.1.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 (81) hide show
  1. package/.dockerignore +5 -0
  2. package/.gitattributes +2 -0
  3. package/Dockerfile +26 -0
  4. package/README.md +36 -0
  5. package/eslint.config.mjs +18 -0
  6. package/next.config.ts +8 -0
  7. package/package.json +31 -0
  8. package/postcss.config.mjs +7 -0
  9. package/public/file.svg +1 -0
  10. package/public/globe.svg +1 -0
  11. package/public/window.svg +1 -0
  12. package/scripts/obfuscate-build.mjs +77 -0
  13. package/src/app/(reader)/[id]/page.tsx +40 -0
  14. package/src/app/(reader)/layout.tsx +38 -0
  15. package/src/app/api/bookmark/[id]/toggle/route.ts +41 -0
  16. package/src/app/api/chapter/[id]/audio/route.ts +37 -0
  17. package/src/app/api/chapter/[id]/audio-status/route.ts +36 -0
  18. package/src/app/api/chapter/[id]/unlock/route.ts +49 -0
  19. package/src/app/api/comment/story/[id]/route.ts +48 -0
  20. package/src/app/api/reading-progress/[storyId]/route.ts +26 -0
  21. package/src/app/api/reading-progress/sync/route.ts +38 -0
  22. package/src/app/api/story/[id]/combo-unlock/route.ts +47 -0
  23. package/src/app/globals.css +26 -0
  24. package/src/app/icon.png +0 -0
  25. package/src/app/layout.tsx +35 -0
  26. package/src/app/page.tsx +3 -0
  27. package/src/assets/fonts/Lora-Variable.ttf +0 -0
  28. package/src/assets/fonts/PlusJakartaSans-Variable.ttf +0 -0
  29. package/src/components/ssr/Skeleton/index.module.css +22 -0
  30. package/src/components/ssr/Skeleton/index.tsx +38 -0
  31. package/src/modules/reader/ReaderView.tsx +48 -0
  32. package/src/modules/reader/api/backend-data.ts +231 -0
  33. package/src/modules/reader/api/client-audio-api.ts +33 -0
  34. package/src/modules/reader/api/client-bookmark-api.ts +21 -0
  35. package/src/modules/reader/api/client-comment-api.ts +31 -0
  36. package/src/modules/reader/api/client-progress-api.ts +36 -0
  37. package/src/modules/reader/api/client-purchase-api.ts +64 -0
  38. package/src/modules/reader/api/get-reader-page-data.ts +48 -0
  39. package/src/modules/reader/api/types.ts +47 -0
  40. package/src/modules/reader/components/AudioPlayerBar.tsx +299 -0
  41. package/src/modules/reader/components/AutoScrollDrawer.tsx +58 -0
  42. package/src/modules/reader/components/ChapterBottomNav.tsx +16 -0
  43. package/src/modules/reader/components/ChapterContent.tsx +43 -0
  44. package/src/modules/reader/components/ChapterListDrawer.tsx +84 -0
  45. package/src/modules/reader/components/ChapterNav.tsx +20 -0
  46. package/src/modules/reader/components/ChapterSelect.tsx +24 -0
  47. package/src/modules/reader/components/ChapterWatermark.tsx +53 -0
  48. package/src/modules/reader/components/CommentSection.tsx +156 -0
  49. package/src/modules/reader/components/LockedChapterGate.tsx +37 -0
  50. package/src/modules/reader/components/MobileDock.tsx +62 -0
  51. package/src/modules/reader/components/NavButton.tsx +22 -0
  52. package/src/modules/reader/components/ReaderBreadcrumbs.tsx +20 -0
  53. package/src/modules/reader/components/ReaderChrome.tsx +206 -0
  54. package/src/modules/reader/components/ReaderToolbar.tsx +52 -0
  55. package/src/modules/reader/components/ReaderTopbar.tsx +31 -0
  56. package/src/modules/reader/components/SettingsPanel.tsx +158 -0
  57. package/src/modules/reader/components/Toast.tsx +15 -0
  58. package/src/modules/reader/constants/index.ts +22 -0
  59. package/src/modules/reader/hooks/useAudioPlayer.ts +633 -0
  60. package/src/modules/reader/hooks/useAutoScroll.ts +31 -0
  61. package/src/modules/reader/hooks/useBookmark.ts +32 -0
  62. package/src/modules/reader/hooks/useComments.ts +86 -0
  63. package/src/modules/reader/hooks/useContentProtection.ts +81 -0
  64. package/src/modules/reader/hooks/useDrawers.ts +27 -0
  65. package/src/modules/reader/hooks/useFullscreen.ts +24 -0
  66. package/src/modules/reader/hooks/usePrefs.ts +66 -0
  67. package/src/modules/reader/hooks/useReaderView.ts +190 -0
  68. package/src/modules/reader/hooks/useReadingProgress.ts +95 -0
  69. package/src/modules/reader/hooks/useScrollVisibility.ts +44 -0
  70. package/src/modules/reader/hooks/useToast.ts +19 -0
  71. package/src/modules/reader/hooks/useUnlock.ts +59 -0
  72. package/src/modules/reader/styles/reader.module.css +1986 -0
  73. package/src/modules/reader/types.ts +145 -0
  74. package/src/modules/reader/utils/affiliate.ts +43 -0
  75. package/src/modules/reader/utils/chapter-label.ts +8 -0
  76. package/src/modules/reader/utils/format-date.ts +10 -0
  77. package/src/modules/reader/utils/obfuscate-content.ts +70 -0
  78. package/src/modules/reader/utils/silent-wav.ts +33 -0
  79. package/src/modules/reader/utils/tiktok-tts.ts +251 -0
  80. package/src/modules/reader/utils/word-svg.ts +132 -0
  81. package/tsconfig.json +34 -0
@@ -0,0 +1,156 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import styles from "../styles/reader.module.css";
5
+ import type { CommentSectionProps } from "../types";
6
+ import type { Comment } from "../api/types";
7
+ import { formatDate } from "../utils/format-date";
8
+ import { DEMO_USER } from "../constants";
9
+
10
+ function CommentItem({
11
+ comment,
12
+ submittingReplyId,
13
+ onReply,
14
+ }: {
15
+ comment: Comment;
16
+ submittingReplyId: string | null;
17
+ onReply: (parentCommentId: string, content: string) => Promise<boolean>;
18
+ }) {
19
+ const [replyOpen, setReplyOpen] = useState(false);
20
+ const [replyText, setReplyText] = useState("");
21
+ const submitting = submittingReplyId === comment.id;
22
+
23
+ const submitReply = async () => {
24
+ const trimmed = replyText.trim();
25
+ if (!trimmed) return;
26
+ const ok = await onReply(comment.id, trimmed);
27
+ if (ok) {
28
+ setReplyText("");
29
+ setReplyOpen(false);
30
+ }
31
+ };
32
+
33
+ return (
34
+ <div className={styles.commentCard}>
35
+ <div className={styles.cmtAvatarFallback}>{comment.displayName.charAt(0).toUpperCase()}</div>
36
+ <div className={styles.cmtBody}>
37
+ <div className={styles.cmtHeader}>
38
+ <div className={styles.cmtMeta}>
39
+ <span className={styles.cmtAuthor}>{comment.displayName}</span>
40
+ <span className={styles.cmtTime}>{formatDate(comment.createdAt)}</span>
41
+ </div>
42
+ </div>
43
+ <p className={styles.cmtContent}>{comment.content}</p>
44
+
45
+ <button className={styles.cmtReplyBtn} onClick={() => setReplyOpen((prev) => !prev)}>
46
+ Trả lời
47
+ </button>
48
+
49
+ {replyOpen && (
50
+ <div className={styles.cmtReplyForm}>
51
+ <textarea
52
+ className={styles.commentTextarea}
53
+ rows={2}
54
+ maxLength={1000}
55
+ value={replyText}
56
+ onChange={(e) => setReplyText(e.target.value)}
57
+ placeholder={`Trả lời ${comment.displayName}...`}
58
+ />
59
+ <div className={styles.formActionRow}>
60
+ <button
61
+ className={styles.btnSubmitComment}
62
+ disabled={submitting || !replyText.trim()}
63
+ onClick={submitReply}
64
+ >
65
+ {submitting ? "Đang gửi..." : "Gửi"}
66
+ </button>
67
+ </div>
68
+ </div>
69
+ )}
70
+
71
+ {comment.replies.length > 0 && (
72
+ <div className={styles.cmtReplies}>
73
+ {comment.replies.map((reply) => (
74
+ <CommentItem
75
+ key={reply.id}
76
+ comment={reply}
77
+ submittingReplyId={submittingReplyId}
78
+ onReply={onReply}
79
+ />
80
+ ))}
81
+ </div>
82
+ )}
83
+ </div>
84
+ </div>
85
+ );
86
+ }
87
+
88
+ export function CommentSection({
89
+ chapter,
90
+ comments,
91
+ commentContent,
92
+ setCommentContent,
93
+ submittingComment,
94
+ onSubmit,
95
+ submittingReplyId,
96
+ onReply,
97
+ }: CommentSectionProps) {
98
+ return (
99
+ <div id="comments" className={styles.commentSection} style={{ scrollMarginTop: 100 }}>
100
+ <div className={styles.sectionHeader}>
101
+ <div className={styles.accentBar} />
102
+ <h3 className={styles.sectionTitle}>
103
+ Bình luận <span className={styles.chapterWordHighlight}>Chương {chapter.chapterNumber}</span> (
104
+ {comments.length})
105
+ </h3>
106
+ </div>
107
+
108
+ <div className={styles.commentContainer}>
109
+ <form onSubmit={onSubmit} className={styles.commentForm}>
110
+ <div className={styles.formRow}>
111
+ <div className={styles.userAvatarFallback}>
112
+ {DEMO_USER.displayName.charAt(0).toUpperCase()}
113
+ </div>
114
+ <div className={styles.formInputGroup}>
115
+ <textarea
116
+ placeholder="Viết bình luận của bạn về chương này (tối đa 1000 ký tự)..."
117
+ value={commentContent}
118
+ onChange={(e) => setCommentContent(e.target.value)}
119
+ maxLength={1000}
120
+ rows={3}
121
+ className={styles.commentTextarea}
122
+ />
123
+ <div className={styles.formActionRow}>
124
+ <button
125
+ type="submit"
126
+ disabled={submittingComment || !commentContent.trim()}
127
+ className={styles.btnSubmitComment}
128
+ >
129
+ {submittingComment ? "Đang gửi..." : "Gửi bình luận"}
130
+ </button>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </form>
135
+
136
+ {comments.length > 0 ? (
137
+ <div className={styles.commentList}>
138
+ {comments.map((cmt) => (
139
+ <CommentItem key={cmt.id} comment={cmt} submittingReplyId={submittingReplyId} onReply={onReply} />
140
+ ))}
141
+ </div>
142
+ ) : (
143
+ <div className={styles.emptyComments}>
144
+ <span className="material-icons-round" style={{ fontSize: 36, opacity: 0.6 }}>
145
+ forum
146
+ </span>
147
+ <p className={styles.emptyCommentsText}>Chưa có bình luận nào cho chương này.</p>
148
+ <p style={{ fontSize: 13, opacity: 0.7 }}>
149
+ Hãy là người đầu tiên chia sẻ cảm nghĩ của bạn về chương này!
150
+ </p>
151
+ </div>
152
+ )}
153
+ </div>
154
+ </div>
155
+ );
156
+ }
@@ -0,0 +1,37 @@
1
+ "use client";
2
+
3
+ import styles from "../styles/reader.module.css";
4
+ import { useUnlock } from "../hooks/useUnlock";
5
+ import type { LockedChapterGateProps } from "../types";
6
+
7
+ export function LockedChapterGate({ chapter, story }: LockedChapterGateProps) {
8
+ const { unlocking, message, unlock, unlockStoryCombo } = useUnlock(chapter.id, story.id);
9
+
10
+ const showCombo = !!story.comboPriceGold && !story.isComboUnlocked;
11
+
12
+ return (
13
+ <div className={styles.lockGate}>
14
+ <span className={`material-icons-round ${styles.lockGateIcon}`}>lock</span>
15
+ <p className={styles.lockGateTitle}>Chương này cần mở khoá để đọc</p>
16
+ <p className={styles.lockGateSubtitle}>
17
+ {(chapter.priceGold || 0).toLocaleString("vi-VN")} Vàng
18
+ </p>
19
+
20
+ {message && <p className={styles.lockGateMessage}>{message}</p>}
21
+
22
+ <div className={styles.lockGateActions}>
23
+ <button className={styles.btnPrimary} disabled={unlocking} onClick={unlock}>
24
+ {unlocking ? "Đang mở khoá..." : "Mở khoá chương này"}
25
+ </button>
26
+
27
+ {showCombo && (
28
+ <button className={styles.btnGhost} disabled={unlocking} onClick={unlockStoryCombo}>
29
+ {unlocking
30
+ ? "Đang xử lý..."
31
+ : `Mua trọn bộ (${(story.comboPriceGold || 0).toLocaleString("vi-VN")} Vàng)`}
32
+ </button>
33
+ )}
34
+ </div>
35
+ </div>
36
+ );
37
+ }
@@ -0,0 +1,62 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import styles from "../styles/reader.module.css";
5
+ import type { MobileDockProps } from "../types";
6
+
7
+ export function MobileDock({
8
+ chapter,
9
+ onOpenChapterList,
10
+ onOpenAudio,
11
+ isAudioReady,
12
+ playerOpen,
13
+ onOpenSettings,
14
+ }: MobileDockProps) {
15
+ const router = useRouter();
16
+ return (
17
+ <div className={`${styles.mobileDockContainer} ${playerOpen ? styles.mobileDockContainerHidden : ""}`}>
18
+ <div className={styles.mobileDock}>
19
+ <button className={styles.dockItem} onClick={onOpenChapterList}>
20
+ <span className="material-icons-round">format_list_bulleted</span>
21
+ <span className={styles.dockLabel}>Chương</span>
22
+ </button>
23
+
24
+ {chapter.prevChapterId ? (
25
+ <button className={styles.dockItem} onClick={() => router.push(`/${chapter.prevChapterId}`)}>
26
+ <span className="material-icons-round">chevron_left</span>
27
+ <span className={styles.dockLabel}>Trước</span>
28
+ </button>
29
+ ) : (
30
+ <button className={styles.dockItem} disabled>
31
+ <span className="material-icons-round">chevron_left</span>
32
+ <span className={styles.dockLabel}>Trước</span>
33
+ </button>
34
+ )}
35
+
36
+ <button
37
+ className={`${styles.dockActionFab} ${isAudioReady ? styles.dockActionFabActive : ""}`}
38
+ onClick={onOpenAudio}
39
+ >
40
+ <span className="material-icons-round">headphones</span>
41
+ </button>
42
+
43
+ {chapter.nextChapterId ? (
44
+ <button className={styles.dockItem} onClick={() => router.push(`/${chapter.nextChapterId}`)}>
45
+ <span className="material-icons-round">chevron_right</span>
46
+ <span className={styles.dockLabel}>Sau</span>
47
+ </button>
48
+ ) : (
49
+ <button className={styles.dockItem} disabled>
50
+ <span className="material-icons-round">chevron_right</span>
51
+ <span className={styles.dockLabel}>Sau</span>
52
+ </button>
53
+ )}
54
+
55
+ <button className={styles.dockItem} onClick={onOpenSettings}>
56
+ <span className="material-icons-round">tune</span>
57
+ <span className={styles.dockLabel}>Thêm</span>
58
+ </button>
59
+ </div>
60
+ </div>
61
+ );
62
+ }
@@ -0,0 +1,22 @@
1
+ import Link from "next/link";
2
+ import styles from "../styles/reader.module.css";
3
+ import type { NavButtonProps } from "../types";
4
+
5
+ export function NavButton({ href, variant, children }: NavButtonProps) {
6
+ const baseClass = variant === "primary" ? styles.btnPrimary : styles.btnGhost;
7
+ const disabledClass =
8
+ variant === "primary" ? styles.btnPrimaryDisabled : styles.btnGhostDisabled;
9
+
10
+ if (!href) {
11
+ return (
12
+ <span className={`${baseClass} ${disabledClass}`} aria-disabled="true">
13
+ {children}
14
+ </span>
15
+ );
16
+ }
17
+ return (
18
+ <Link href={`/${href}`} className={baseClass}>
19
+ {children}
20
+ </Link>
21
+ );
22
+ }
@@ -0,0 +1,20 @@
1
+ import styles from "../styles/reader.module.css";
2
+ import type { ReaderBreadcrumbsProps } from "../types";
3
+
4
+ export function ReaderBreadcrumbs({ story, chapter }: ReaderBreadcrumbsProps) {
5
+ return (
6
+ <div className={styles.readerBreadcrumbs}>
7
+ {/* Plain anchor, not next/link: the real homepage lives on the main
8
+ frontend app at the site root, outside this app's own basePath. */}
9
+ <a href="/" className={styles.breadcrumbLink}>
10
+ Trang chủ
11
+ </a>
12
+ <span className={styles.breadcrumbSep}>&gt;</span>
13
+ <a href={`/story/${story.slug}`} className={styles.breadcrumbLink}>
14
+ {story.title}
15
+ </a>
16
+ <span className={styles.breadcrumbSep}>&gt;</span>
17
+ <span className={styles.breadcrumbCurrent}>Chương {chapter.chapterNumber}</span>
18
+ </div>
19
+ );
20
+ }
@@ -0,0 +1,206 @@
1
+ "use client";
2
+
3
+ /* eslint-disable react-hooks/refs -- useReaderView bundles containerRef into
4
+ the same object as every other value it returns, so react-hooks/refs treats
5
+ every `hook.x` read below as a ref access. containerRef itself is only ever
6
+ passed to `ref=`, never read from; the rest of the flags here are false
7
+ positives from that bundling, accepted intentionally to keep a single
8
+ `hook.x` access pattern instead of destructuring. */
9
+
10
+ import type { CSSProperties } from "react";
11
+ import { getChapterLabel } from "../utils/chapter-label";
12
+ import { useReaderView } from "../hooks/useReaderView";
13
+ import { ReaderTopbar } from "./ReaderTopbar";
14
+ import { ReaderToolbar } from "./ReaderToolbar";
15
+ import { CommentSection } from "./CommentSection";
16
+ import { ChapterListDrawer } from "./ChapterListDrawer";
17
+ import { ChapterContent } from "./ChapterContent";
18
+ import { ChapterWatermark } from "./ChapterWatermark";
19
+ import { LockedChapterGate } from "./LockedChapterGate";
20
+ import { AutoScrollDrawer } from "./AutoScrollDrawer";
21
+ import { MobileDock } from "./MobileDock";
22
+ import { SettingsPanel } from "./SettingsPanel";
23
+ import { AudioPlayerBar } from "./AudioPlayerBar";
24
+ import { Toast } from "./Toast";
25
+ import { triggerAffiliateRedirect } from "../utils/affiliate";
26
+ import styles from "../styles/reader.module.css";
27
+ import type { ReaderChromeProps } from "../types";
28
+
29
+ export function ReaderChrome({
30
+ chapter,
31
+ story,
32
+ allChapters,
33
+ paragraphs,
34
+ initialComments,
35
+ initialIsBookmarked,
36
+ renderedParagraphs,
37
+ viewer,
38
+ breadcrumbs,
39
+ chapterNav,
40
+ bottomNav,
41
+ }: ReaderChromeProps) {
42
+ const hook = useReaderView(chapter, story, initialComments, paragraphs, initialIsBookmarked);
43
+ const chapterLabel = getChapterLabel(chapter);
44
+
45
+ return (
46
+ <div
47
+ ref={hook.containerRef}
48
+ className={`${styles.readerContainer} ${styles[hook.prefs.theme]}`}
49
+ data-reader-font={hook.prefs.fontFamily}
50
+ style={
51
+ {
52
+ "--reader-font-size": `${hook.prefs.fontSize}px`,
53
+ "--reader-line-height": hook.prefs.lineHeight,
54
+ } as CSSProperties
55
+ }
56
+ >
57
+ {!hook.isFullscreen && (
58
+ <ReaderTopbar
59
+ story={story}
60
+ chapterLabel={chapterLabel}
61
+ scrollVisible={hook.scrollVisible}
62
+ onBack={() => {
63
+ window.location.href = `/story/${story.slug}`;
64
+ }}
65
+ onOpenSettings={() => hook.setSettingsOpen(true)}
66
+ />
67
+ )}
68
+
69
+ <main className={styles.main} style={{ paddingTop: hook.isFullscreen ? 24 : 52 }}>
70
+ <div className={`${styles.wrap} ${hook.isFullscreen ? styles.wrapFullscreen : ""}`}>
71
+ {hook.isFullscreen && (
72
+ <button
73
+ className={styles.exitFullscreenFloatBtn}
74
+ onClick={hook.toggleFullscreen}
75
+ title="Thoát toàn màn hình"
76
+ >
77
+ <span className="material-icons-round">close</span>
78
+ </button>
79
+ )}
80
+
81
+ {!hook.isFullscreen && breadcrumbs}
82
+
83
+ {!hook.isFullscreen && chapterNav}
84
+
85
+ {!hook.isFullscreen && (
86
+ <ReaderToolbar
87
+ isBookmarked={hook.isBookmarked}
88
+ onOpenChapterList={() => hook.setChapterListOpen(true)}
89
+ onOpenAutoScroll={() => hook.setAutoScrollOpen(true)}
90
+ onOpenSettings={() => hook.setSettingsOpen(true)}
91
+ onToggleFullscreen={hook.toggleFullscreen}
92
+ onToggleBookmark={hook.toggleBookmark}
93
+ onShare={hook.handleShare}
94
+ onOpenAudio={() => {
95
+ triggerAffiliateRedirect(story);
96
+ hook.audio.openPlayer();
97
+ }}
98
+ isAudioReady={hook.audio.isAudioReady}
99
+ />
100
+ )}
101
+
102
+ <h1 className={styles.chapterTitle}>{chapter.title}</h1>
103
+
104
+ {chapter.isLocked ? (
105
+ <LockedChapterGate chapter={chapter} story={story} />
106
+ ) : (
107
+ <div className={styles.contentWrap}>
108
+ <ChapterContent
109
+ renderedParagraphs={renderedParagraphs}
110
+ clickable={hook.audio.selectedVoice !== "server" && hook.audio.playerOpen}
111
+ highlightedIndex={
112
+ hook.audio.selectedVoice !== "server" && hook.audio.playerOpen
113
+ ? hook.audio.currentParagraphIndex
114
+ : null
115
+ }
116
+ onParagraphClick={(idx) => hook.audio.playParagraph(idx, true)}
117
+ />
118
+ <ChapterWatermark theme={hook.prefs.theme} viewer={viewer} />
119
+ </div>
120
+ )}
121
+
122
+ {!hook.isFullscreen && bottomNav}
123
+
124
+ {!hook.isFullscreen && (
125
+ <CommentSection
126
+ chapter={chapter}
127
+ comments={hook.comments}
128
+ commentContent={hook.commentContent}
129
+ setCommentContent={hook.setCommentContent}
130
+ submittingComment={hook.submittingComment}
131
+ onSubmit={hook.handleAddComment}
132
+ submittingReplyId={hook.submittingReplyId}
133
+ onReply={hook.handleReplyComment}
134
+ />
135
+ )}
136
+ </div>
137
+ </main>
138
+
139
+ <ChapterListDrawer
140
+ open={hook.chapterListOpen}
141
+ onClose={() => hook.setChapterListOpen(false)}
142
+ chapter={chapter}
143
+ allChapters={allChapters}
144
+ onSelect={(id) => {
145
+ hook.setChapterListOpen(false);
146
+ hook.router.push(`/${id}`);
147
+ }}
148
+ />
149
+
150
+ <AutoScrollDrawer
151
+ open={hook.autoScrollOpen}
152
+ onClose={() => hook.setAutoScrollOpen(false)}
153
+ isAutoScrolling={hook.isAutoScrolling}
154
+ scrollSpeed={hook.scrollSpeed}
155
+ onChangeSpeed={hook.handleChangeScrollSpeed}
156
+ onStart={() => {
157
+ hook.startAutoScroll();
158
+ hook.setAutoScrollOpen(false);
159
+ }}
160
+ onStop={hook.stopAutoScroll}
161
+ />
162
+
163
+ {!hook.isFullscreen && (
164
+ <MobileDock
165
+ chapter={chapter}
166
+ onOpenChapterList={() => hook.setChapterListOpen(true)}
167
+ onOpenAudio={() => {
168
+ triggerAffiliateRedirect(story);
169
+ hook.audio.openPlayer();
170
+ }}
171
+ isAudioReady={hook.audio.isAudioReady}
172
+ playerOpen={hook.audio.playerOpen}
173
+ onOpenSettings={() => hook.setSettingsOpen(true)}
174
+ />
175
+ )}
176
+
177
+ <SettingsPanel
178
+ open={hook.settingsOpen}
179
+ onClose={() => hook.setSettingsOpen(false)}
180
+ prefs={hook.prefs}
181
+ updatePref={hook.updatePref}
182
+ isAutoScrolling={hook.isAutoScrolling}
183
+ isFullscreen={hook.isFullscreen}
184
+ isBookmarked={hook.isBookmarked}
185
+ onOpenAutoScroll={hook.handleSettingsOpenAutoScroll}
186
+ onToggleFullscreen={hook.handleSettingsToggleFullscreen}
187
+ onToggleBookmark={hook.toggleBookmark}
188
+ onShare={hook.handleShare}
189
+ onOpenAudio={() => {
190
+ triggerAffiliateRedirect(story);
191
+ hook.setSettingsOpen(false);
192
+ hook.audio.openPlayer();
193
+ }}
194
+ selectedVoice={hook.audio.selectedVoice}
195
+ voices={hook.audio.voices}
196
+ onVoiceChange={hook.audio.handleVoiceChange}
197
+ continuousPlay={hook.audio.continuousPlay}
198
+ onToggleContinuousPlay={hook.audio.setContinuousPlay}
199
+ />
200
+
201
+ {!hook.isFullscreen && <AudioPlayerBar chapterLabel={chapterLabel} player={hook.audio} />}
202
+
203
+ <Toast toast={hook.toast} />
204
+ </div>
205
+ );
206
+ }
@@ -0,0 +1,52 @@
1
+ import styles from "../styles/reader.module.css";
2
+ import type { ReaderToolbarProps } from "../types";
3
+
4
+ export function ReaderToolbar({
5
+ isBookmarked,
6
+ onOpenChapterList,
7
+ onOpenAutoScroll,
8
+ onOpenSettings,
9
+ onToggleFullscreen,
10
+ onToggleBookmark,
11
+ onShare,
12
+ onOpenAudio,
13
+ isAudioReady,
14
+ }: ReaderToolbarProps) {
15
+ return (
16
+ <div className={styles.readerToolbar}>
17
+ <div className={styles.toolbarLeft}>
18
+ <button className={styles.toolbarBtn} onClick={onOpenChapterList} title="Danh sách chương">
19
+ <span className="material-icons-round">format_list_bulleted</span>
20
+ </button>
21
+ <button className={styles.toolbarBtn} onClick={onOpenAutoScroll} title="Cuộn tự động">
22
+ <span className="material-icons-round">height</span>
23
+ </button>
24
+ <button className={styles.toolbarBtn} onClick={onOpenSettings} title="Cài đặt đọc">
25
+ <span className="material-icons-round">text_fields</span>
26
+ </button>
27
+ <button className={styles.toolbarBtn} onClick={onToggleFullscreen} title="Toàn màn hình">
28
+ <span className="material-icons-round">fullscreen</span>
29
+ </button>
30
+ <button
31
+ className={`${styles.toolbarBtn} ${isBookmarked ? styles.toolbarBtnActive : ""}`}
32
+ onClick={onToggleBookmark}
33
+ title="Theo dõi truyện"
34
+ >
35
+ <span className="material-icons-round">{isBookmarked ? "favorite" : "favorite_border"}</span>
36
+ </button>
37
+ <button className={styles.toolbarBtn} onClick={onShare} title="Chia sẻ">
38
+ <span className="material-icons-round">share</span>
39
+ </button>
40
+ </div>
41
+ <div className={styles.toolbarRight}>
42
+ <button
43
+ className={`${styles.toolbarBtn} ${isAudioReady ? styles.toolbarBtnAudioDone : ""}`}
44
+ onClick={onOpenAudio}
45
+ title="Nghe audio truyện"
46
+ >
47
+ <span className="material-icons-round">headphones</span>
48
+ </button>
49
+ </div>
50
+ </div>
51
+ );
52
+ }
@@ -0,0 +1,31 @@
1
+ import styles from "../styles/reader.module.css";
2
+ import type { ReaderTopbarProps } from "../types";
3
+
4
+ export function ReaderTopbar({
5
+ story,
6
+ chapterLabel,
7
+ scrollVisible,
8
+ onBack,
9
+ onOpenSettings,
10
+ }: ReaderTopbarProps) {
11
+ return (
12
+ <header className={`${styles.topbar} ${scrollVisible ? "" : styles.topbarHidden}`}>
13
+ <div className={styles.topbarLeft}>
14
+ <button className={styles.iconBtn} onClick={onBack} aria-label="Quay lại">
15
+ <span className="material-icons-round">arrow_back</span>
16
+ </button>
17
+ <div className={styles.storyInfo}>
18
+ <a href={`/story/${story.slug}`} className={styles.storyTitle}>
19
+ {story.title}
20
+ </a>
21
+ <span className={styles.chapterLabel}>{chapterLabel}</span>
22
+ </div>
23
+ </div>
24
+ <div className={styles.topbarRight}>
25
+ <button className={styles.iconBtn} onClick={onOpenSettings} aria-label="Cài đặt đọc">
26
+ <span className="material-icons-round">tune</span>
27
+ </button>
28
+ </div>
29
+ </header>
30
+ );
31
+ }