-
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 bdd39b5
Showing
36 changed files
with
1,201 additions
and
180 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
62 changes: 62 additions & 0 deletions
62
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,62 @@ | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import DropdownSection from '../../../components/Dropdown/Section'; | ||
import SectionItem from '../../../components/Dropdown/Section/SectionItem'; | ||
import { | ||
SplitViewIcon, | ||
StudioCloseSignIcon, | ||
StudioPlusSignIcon, | ||
} from '../../../icons'; | ||
import { | ||
addToStudioShortcut, | ||
openInSplitViewShortcut, | ||
removeFromStudioShortcut, | ||
} from '../../../consts/shortcuts'; | ||
|
||
type Props = { | ||
handleMoveToAnotherSide: () => void; | ||
handleAddToStudio: () => void; | ||
handleRemoveFromStudio: () => void; | ||
isDocInContext: boolean; | ||
}; | ||
|
||
const ActionsDropdown = ({ | ||
handleMoveToAnotherSide, | ||
handleAddToStudio, | ||
handleRemoveFromStudio, | ||
isDocInContext, | ||
}: Props) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div> | ||
<DropdownSection borderBottom> | ||
{isDocInContext ? ( | ||
<SectionItem | ||
label={t('Remove from studio')} | ||
onClick={handleRemoveFromStudio} | ||
shortcut={removeFromStudioShortcut} | ||
icon={<StudioCloseSignIcon sizeClassName="w-4 h-4" />} | ||
/> | ||
) : ( | ||
<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); |
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
import React, { Dispatch, memo, SetStateAction, useCallback } 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(() => { | ||
if (isEditingSelection) { | ||
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.