💄 move the word counts to the bottom bar
This commit is contained in:
@@ -45,6 +45,22 @@
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.statusbar-right {
|
||||||
|
margin-left: auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusbar-wordcount {
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statusbar-sep {
|
||||||
|
opacity: 0.45;
|
||||||
|
margin: 0 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.statusbar-share-btn {
|
.statusbar-share-btn {
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@@ -685,7 +685,7 @@ export function MarkdownEditor(): JSX.Element {
|
|||||||
const [commentDraft, setCommentDraft] = useState('')
|
const [commentDraft, setCommentDraft] = useState('')
|
||||||
const [wordStats, setWordStats] = useState<{ atCursor: number; total: number }>({ atCursor: 0, total: 0 })
|
const [wordStats, setWordStats] = useState<{ atCursor: number; total: number }>({ atCursor: 0, total: 0 })
|
||||||
const wordTotalRef = useRef(0)
|
const wordTotalRef = useRef(0)
|
||||||
const { activeFilePath, activeFileContent, setContent, annotations, fontSize, theme, focusMode, scrollPositions, pendingScrollToLine, clearPendingScrollToLine, selectionWordCount } = useEditorStore()
|
const { activeFilePath, activeFileContent, setContent, annotations, fontSize, theme, focusMode, scrollPositions, pendingScrollToLine, clearPendingScrollToLine, selectionWordCount, projectWordCount } = useEditorStore()
|
||||||
|
|
||||||
function saveComment(): void {
|
function saveComment(): void {
|
||||||
if (!pendingComment || !commentDraft.trim()) return
|
if (!pendingComment || !commentDraft.trim()) return
|
||||||
@@ -1137,6 +1137,34 @@ export function MarkdownEditor(): JSX.Element {
|
|||||||
{selectionWordCount !== null && (
|
{selectionWordCount !== null && (
|
||||||
<span className="statusbar-selection-wordcount">{selectionWordCount.toLocaleString()} selected</span>
|
<span className="statusbar-selection-wordcount">{selectionWordCount.toLocaleString()} selected</span>
|
||||||
)}
|
)}
|
||||||
|
<div className="statusbar-right">
|
||||||
|
{(() => {
|
||||||
|
const docWc = countWords(activeFileContent)
|
||||||
|
const sentences = activeFileContent
|
||||||
|
.split(/[.!?]+/)
|
||||||
|
.map((s: string) => s.trim())
|
||||||
|
.filter((s: string) => s.length > 0 && /\w/.test(s))
|
||||||
|
const avgLen = sentences.length > 0
|
||||||
|
? Math.round((sentences.map((s: string) => countWords(s)).reduce((a: number, b: number) => a + b, 0) / sentences.length) * 10) / 10
|
||||||
|
: null
|
||||||
|
const fmt = (n: number) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n)
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="statusbar-wordcount"
|
||||||
|
title={`This document: ${docWc.toLocaleString()} words · Entire project: ${projectWordCount.toLocaleString()} words${avgLen !== null ? ` · Avg sentence: ${avgLen} words` : ''}`}
|
||||||
|
>
|
||||||
|
{fmt(docWc)}
|
||||||
|
<span className="statusbar-sep">/</span>
|
||||||
|
{fmt(projectWordCount)}
|
||||||
|
{avgLen !== null && (
|
||||||
|
<>
|
||||||
|
<span className="statusbar-sep">·</span>
|
||||||
|
{avgLen}w
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
})()}
|
||||||
<button
|
<button
|
||||||
className="statusbar-share-btn"
|
className="statusbar-share-btn"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -1148,6 +1176,7 @@ export function MarkdownEditor(): JSX.Element {
|
|||||||
⎙
|
⎙
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -373,9 +373,7 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
const critiqueCount = annotations.filter((a) => a.type === 'critique').length
|
const critiqueCount = annotations.filter((a) => a.type === 'critique').length
|
||||||
const totalCount = passiveCount + pastProgressiveCount + weakVerbsCount + clichesCount + consistencyCount + styleCount + showTellCount + critiqueCount
|
const totalCount = passiveCount + pastProgressiveCount + weakVerbsCount + clichesCount + consistencyCount + styleCount + showTellCount + critiqueCount
|
||||||
const anyActive = Boolean(analysisMode)
|
const anyActive = Boolean(analysisMode)
|
||||||
const docWordCount = countWords(activeFileContent)
|
|
||||||
const sentenceStats = activeFileContent ? computeSentenceStats(activeFileContent) : null
|
const sentenceStats = activeFileContent ? computeSentenceStats(activeFileContent) : null
|
||||||
const avgSentenceLen = sentenceStats ? Math.round(sentenceStats.avg * 10) / 10 : null
|
|
||||||
const paragraphRhythm = activeFileContent ? computeParagraphRhythm(activeFileContent) : []
|
const paragraphRhythm = activeFileContent ? computeParagraphRhythm(activeFileContent) : []
|
||||||
const maxParaWords = paragraphRhythm.length > 0 ? Math.max(...paragraphRhythm.map(p => p.words)) : 1
|
const maxParaWords = paragraphRhythm.length > 0 ? Math.max(...paragraphRhythm.map(p => p.words)) : 1
|
||||||
|
|
||||||
@@ -676,22 +674,6 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="toolbar-right">
|
<div className="toolbar-right">
|
||||||
{activeFilePath && (
|
|
||||||
<span
|
|
||||||
className="toolbar-wordcount"
|
|
||||||
title={`This document: ${docWordCount.toLocaleString()} words · Entire project: ${projectWordCount.toLocaleString()} words${avgSentenceLen !== null ? ` · Avg sentence: ${avgSentenceLen} words` : ''}`}
|
|
||||||
>
|
|
||||||
{formatWordCount(docWordCount)}
|
|
||||||
<span className="toolbar-wordcount-sep">/</span>
|
|
||||||
{formatWordCount(projectWordCount)}
|
|
||||||
{avgSentenceLen !== null && (
|
|
||||||
<>
|
|
||||||
<span className="toolbar-wordcount-sep">·</span>
|
|
||||||
{avgSentenceLen}w
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{isDirty && (
|
{isDirty && (
|
||||||
<span className="toolbar-dirty" title="Unsaved changes — press Cmd+S to save">
|
<span className="toolbar-dirty" title="Unsaved changes — press Cmd+S to save">
|
||||||
●
|
●
|
||||||
|
|||||||
Reference in New Issue
Block a user