-
Notifications
You must be signed in to change notification settings - Fork 571
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
1 parent
3b89d77
commit c7a1510
Showing
34 changed files
with
894 additions
and
121 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
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
44 changes: 44 additions & 0 deletions
44
client/src/Project/CurrentTabContent/DocTab/ActionsDropdown.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { memo, useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import DropdownSection from '../../../components/Dropdown/Section'; | ||
import SectionItem from '../../../components/Dropdown/Section/SectionItem'; | ||
import { SplitViewIcon, StudioPlusSignIcon } from '../../../icons'; | ||
import { | ||
addToStudioShortcut, | ||
openInSplitViewShortcut, | ||
} from '../../../consts/shortcuts'; | ||
|
||
type Props = { | ||
handleMoveToAnotherSide: () => void; | ||
handleAddToStudio: () => void; | ||
}; | ||
|
||
const ActionsDropdown = ({ | ||
handleMoveToAnotherSide, | ||
handleAddToStudio, | ||
}: Props) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div> | ||
<DropdownSection borderBottom> | ||
<SectionItem | ||
label={t('Add to studio')} | ||
onClick={handleAddToStudio} | ||
shortcut={addToStudioShortcut} | ||
icon={<StudioPlusSignIcon sizeClassName="w-4 h-4" />} | ||
/> | ||
</DropdownSection> | ||
<DropdownSection> | ||
<SectionItem | ||
label={t('Open in split view')} | ||
shortcut={openInSplitViewShortcut} | ||
onClick={handleMoveToAnotherSide} | ||
icon={<SplitViewIcon sizeClassName="w-4 h-4" />} | ||
/> | ||
</DropdownSection> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(ActionsDropdown); |
90 changes: 90 additions & 0 deletions
90
client/src/Project/CurrentTabContent/DocTab/DocSection.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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React, { | ||
Dispatch, | ||
memo, | ||
SetStateAction, | ||
useCallback, | ||
MouseEvent, | ||
} from 'react'; | ||
import { Trans } from 'react-i18next'; | ||
import Button from '../../../components/Button'; | ||
import { DocSectionType } from '../../../types/api'; | ||
import RenderedSection from './RenderedSection'; | ||
|
||
type Props = DocSectionType & { | ||
isSelected: boolean; | ||
isNothingSelected: boolean; | ||
isEditingSelection: boolean; | ||
setSelectedSections: Dispatch<SetStateAction<string[]>>; | ||
}; | ||
|
||
const DocSection = ({ | ||
text, | ||
isSelected, | ||
setSelectedSections, | ||
point_id, | ||
isNothingSelected, | ||
doc_source, | ||
isEditingSelection, | ||
}: Props) => { | ||
const setSelected = useCallback( | ||
(b: boolean) => { | ||
setSelectedSections((prev) => { | ||
if (b) { | ||
return [...prev, point_id]; | ||
} | ||
return prev.filter((r) => r !== point_id); | ||
}); | ||
}, | ||
[point_id, setSelectedSections], | ||
); | ||
|
||
const handleClick = useCallback( | ||
(e: MouseEvent) => { | ||
if (isEditingSelection) { | ||
e.stopPropagation(); | ||
setSelected(!isSelected); | ||
} | ||
}, | ||
[isSelected, isEditingSelection], | ||
); | ||
return ( | ||
<div | ||
data-section-id={point_id} | ||
className={`body-s relative group ${ | ||
isSelected | ||
? 'bg-bg-selected opacity-100' | ||
: isEditingSelection | ||
? `hover:bg-bg-sub-hover ${ | ||
isNothingSelected ? '' : 'opacity-50 hover:opacity-100' | ||
}` | ||
: '' | ||
} ${ | ||
isEditingSelection ? 'cursor-pointer' : '' | ||
} pl-8 pr-4 py-3 transition-opacity duration-150 ease-in-out`} | ||
onClick={handleClick} | ||
> | ||
{isEditingSelection && ( | ||
<div | ||
className={`absolute top-2 right-2 z-10 ${ | ||
isSelected ? 'opacity-100' : 'opacity-0 group-hover:opacity-100' | ||
} transition-opacity duration-150 ease-in-out`} | ||
> | ||
<Button size="mini" variant="secondary" onClick={handleClick}> | ||
{!isSelected ? ( | ||
<Trans>Select section</Trans> | ||
) : ( | ||
<Trans>Clear section</Trans> | ||
)} | ||
</Button> | ||
</div> | ||
)} | ||
<RenderedSection | ||
text={text} | ||
baseUrl={doc_source} | ||
isEditingSelection={isEditingSelection} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(DocSection); |
Oops, something went wrong.