-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
97 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 44 additions & 17 deletions
61
projects/athena-web/src/patterns/components/content-details/content-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,62 @@ | ||
import React from "react"; | ||
import {ContentData} from "../../../state/features/ui/content/content-selctors"; | ||
import {ContentType} from "../../../state/features/ui/content/content-interface"; | ||
import {formatUTCString} from "../../../helpers/format-utc-string"; | ||
import {ApplicationState, useAppSelector} from "../../../state/store"; | ||
import {selectTasks} from "../../../state/features/current-vault/task-lists/tasks/task-selectors"; | ||
import {DatabaseTask, TaskStatus} from "../../../state/features/current-vault/task-lists/tasks/task-interface"; | ||
import {DatabaseTaskList} from "../../../state/features/current-vault/task-lists/task-lists-interface"; | ||
import {DatabaseNote} from "../../../state/features/current-vault/notes/notes-interface"; | ||
import {DatabaseNoteTemplate} from "../../../state/features/current-vault/note-templates/note-templates-interface"; | ||
|
||
|
||
export interface ContentDetailsProps { | ||
content: ContentData | ||
} | ||
|
||
export function ContentDetails(props: ContentDetailsProps) { | ||
let details; | ||
if (props.content.type === ContentType.TASK_LIST) { | ||
details = ( | ||
<p className="text-br-whiteGrey-700 text-center italic">0 open tasks | 0 complete tasks</p> | ||
) | ||
return <TaskListDetails taskList={props.content.data} /> | ||
} | ||
else { | ||
const wordCount = props.content.data.body | ||
.split(" ") | ||
.filter(word => word !== "") | ||
.length; | ||
const charCount = props.content.data.body.length; | ||
details = ( | ||
<div> | ||
<p className="text-br-whiteGrey-700 text-center italic">{wordCount} words | {charCount} chars</p> | ||
</div> | ||
) | ||
return <TextDetails content={props.content.data} /> | ||
} | ||
} | ||
|
||
|
||
export interface TextDetailsProps { | ||
content: DatabaseNote | DatabaseNoteTemplate | ||
} | ||
export function TextDetails(props: TextDetailsProps) { | ||
const wordCount = props.content.body | ||
.split(" ") | ||
.filter(word => word !== "") | ||
.length; | ||
const charCount = props.content.body.length; | ||
|
||
return ( | ||
<div className="overflow-x-scroll whitespace-nowrap"> | ||
{details} | ||
<p className="text-br-whiteGrey-700 text-center italic">{wordCount} words | {charCount} chars</p> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export interface TaskListDetailsProps { | ||
taskList: DatabaseTaskList | ||
} | ||
export function TaskListDetails(props: TaskListDetailsProps) { | ||
const tasks = useAppSelector((state: ApplicationState) => selectTasks(state, props.taskList.id)); | ||
const openTasks: DatabaseTask[] = []; | ||
const completedTasks: DatabaseTask[] = []; | ||
for (const task of tasks) { | ||
if (task.status === TaskStatus.OPEN) { | ||
openTasks.push(task); | ||
} | ||
else { | ||
completedTasks.push(task); | ||
} | ||
} | ||
|
||
return ( | ||
<p className="text-br-whiteGrey-700 text-center italic">{openTasks.length} open tasks | {completedTasks.length} complete tasks</p> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71cb554
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
athena – ./
athena-ben-ryder.vercel.app
athena-git-main-ben-ryder.vercel.app
ben-ryder-athena.vercel.app
athena.benryder.dev