estimated read

This commit is contained in:
TC
2026-06-14 21:00:38 +10:00
parent 57673d5d65
commit 4f1fbec868
2 changed files with 24 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
.editor-statusbar {
flex-shrink: 0;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
@@ -45,6 +46,17 @@
opacity: 0.5;
}
.statusbar-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
pointer-events: none;
}
.statusbar-readtime {
opacity: 0.8;
}
.statusbar-right {
margin-left: auto;
display: flex;

View File

@@ -1171,6 +1171,18 @@ export function MarkdownEditor(): JSX.Element {
) : sentenceWordCount > 0 ? (
<span className="statusbar-selection-wordcount">{sentenceWordCount} in sentence</span>
) : null}
<div className="statusbar-center">
{(() => {
const wc = countWords(activeFileContent)
const mins = wc / 238
if (wc < 10) return null
if (mins < 1) return <span className="statusbar-readtime">{'<'} 1 min read</span>
const h = Math.floor(mins / 60)
const m = Math.round(mins % 60)
const label = h > 0 ? `${h}h ${m}m read` : `${Math.round(mins)} min read`
return <span className="statusbar-readtime">{label}</span>
})()}
</div>
<div className="statusbar-right">
{(() => {
const docWc = countWords(activeFileContent)