Skip to content

Commit

Permalink
feat(dashboard): add notes section
Browse files Browse the repository at this point in the history
  • Loading branch information
marespopa committed Apr 1, 2024
1 parent be6734b commit ee7bbfa
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
helpText?: string
customStyles?: string
isDisabled?: boolean
handleCursorPositionUpdate: (_position: number) => void
handleCursorPositionUpdate?: (_position: number) => void
}
const DEFAULT_TEXTAREA_ROWS = 4

Expand Down Expand Up @@ -44,6 +44,7 @@ const Textarea = forwardRef(function Textarea(props: Props, ref: any) {
autoComplete="off"
rows={DEFAULT_TEXTAREA_ROWS}
onBlur={(e) =>
props.handleCursorPositionUpdate &&
props.handleCursorPositionUpdate(e.target.selectionStart)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DescriptionField = () => {
label="Task Details"
value={description}
handleCursorPositionUpdate={(pos: number) => setCursorPosition(pos)}
helpText="A brief overview of what needs to be accomplished, in which you can
helpText="* A brief overview of what needs to be accomplished, in which you can
use markdown for detailed formatting."
/>
</section>
Expand Down
47 changes: 47 additions & 0 deletions client/components/overview/NotesSection/NotesSections.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useAtom } from 'jotai'
import { atom_notes } from 'jotai/atoms'

import React, { useRef, useState } from 'react'
import SectionHeading from '../common/SectionHeading.component'
import Textarea from '@/components/forms/input/Textarea'

type Props = {}

export default function NotesSection({}: Props) {
const [notes, setNotes] = useAtom(atom_notes)
const [isExpanded, setisExpanded] = useState(true)
const textareaRef = useRef<HTMLTextAreaElement>(null)

return (
<section className="mt-8">
<SectionHeading
title="Notes"
description={
'Use this space for brainstorming, saving research links, or noting questions that pop up during your session.'
}
subHeading={
'* Jot down distracting but important thoughts to revisit later.'
}
isExpanded={isExpanded}
handleToggle={() => setisExpanded(!isExpanded)}
/>
{isExpanded && renderTextarea()}
</section>
)

function renderTextarea() {
return (
<Textarea
handleChange={handleUpdateField}
ref={textareaRef}
id="taskNotes"
label="Write your notes"
value={notes}
/>
)
}

function handleUpdateField(value: string) {
setNotes(value)
}
}
3 changes: 3 additions & 0 deletions client/components/overview/NotesSection/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import NotesSection from './NotesSections'

export default NotesSection
6 changes: 5 additions & 1 deletion client/components/overview/OverviewSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TaskDetails from './TaskDetails'
import SubtasksSection from './SubtasksSection'
import Greeting from '../common/Greeting'
import TemplateSection from './TemplateSection'
import NotesSection from './NotesSection'

type Props = {
handleReset: () => void
Expand Down Expand Up @@ -72,7 +73,10 @@ const OverviewSection = ({ handleReset }: Props) => {
activeTab={activeTab}
handleTabChange={(tab) => setActiveTab(tab)}
/>
<SubtasksSection />
<div className="grid md:grid-cols-2 md:gap-8">
<SubtasksSection />
<NotesSection />
</div>
<SnippetsSection />
<Timer />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SubtasksSection = () => {
handleToggle={() => setisExpanded(!isExpanded)}
/>
{isExpanded && (
<div className={`sm:relative sm:z-0 min-h-full w-full md:w-1/2`}>
<div className={`sm:relative sm:z-0 min-h-full w-full`}>
<SubtasksList />
</div>
)}
Expand Down
2 changes: 2 additions & 0 deletions client/jotai/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const KEYS = {
description: 'description',
snippets: 'snippets',
subTasks: 'subtasks',
notes: 'notes',
}

export const atom_snippets = atomWithStorage<Array<Snippet>>(KEYS.snippets, [])
export const atom_title = atomWithStorage(
KEYS.title,
DEFAULT_TEMPLATES.blank.title,
)
export const atom_notes = atomWithStorage(KEYS.notes, '')
export const atom_description = atomWithStorage(
KEYS.description,
DEFAULT_TEMPLATES.blank.description,
Expand Down

0 comments on commit ee7bbfa

Please sign in to comment.