Skip to content

Commit

Permalink
add text highlighting for draft section
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewldesousa committed Jul 8, 2024
1 parent 2b6da58 commit 0fc4d9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
23 changes: 8 additions & 15 deletions frontend/src/components/DraftCards/SectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ const useStyles = makeStyles({
// margin top and bottom
margin: '0.5rem 0',
padding: '0.5rem',

// make text selectable
userSelect: 'text',

// highlight color
'&::selection': {
backgroundColor: '#FFD6A5',
}
},

popoverGenerateButton: {
Expand Down Expand Up @@ -80,10 +72,9 @@ const useStyles = makeStyles({
sectionContentTextarea: {
width: '100%',
height: '100%',
padding: '0.5rem',

// make text selectable
userSelect: 'text',

// selection
'&::selection': {
backgroundColor: '#FFD6A5',
}
Expand All @@ -109,10 +100,10 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
async function fetchSectionContent(sectionTitle: string, sectionDescription: string) {
setIsLoading(true)
const sectionGenerateRequest: SectionGenerateRequest = { sectionTitle, sectionDescription }
const response = await sectionGenerate(sectionGenerateRequest)


const response = await sectionGenerate(sectionGenerateRequest)
const responseBody = await response.json()

const updatedSection: Section = { title: sectionTitle, description: sectionDescription, content: responseBody.section_content }
appStateContext?.dispatch({ type: 'UPDATE_SECTION', payload: { sectionIdx: sectionIdx, section: updatedSection } })

Expand Down Expand Up @@ -184,12 +175,14 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
appearance="outline"
size="large"
defaultValue={sectionContent}

onChange={(e, data) => {
const updatedSection: Section = { title: sectionTitle, description: sectionDescription, content: data.value || '' }
appStateContext?.dispatch({ type: 'UPDATE_SECTION', payload: { sectionIdx: sectionIdx, section: updatedSection } })
}}

className={classes.sectionContentTextarea}
textarea={{ className: classes.sectionContentTextarea }}
style={{ width: '100%', height: '100%' }}
/>
)
}
Expand All @@ -198,4 +191,4 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
)
}

export default SectionCard
export default SectionCard
2 changes: 1 addition & 1 deletion frontend/src/components/DraftCards/TitleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const TitleCard = () => {
)
}

export default TitleCard
export default TitleCard

0 comments on commit 0fc4d9f

Please sign in to comment.