-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…plicate-page Feature/#495 allow the user duplicate page also closes #503 Allow the user delete a page
- Loading branch information
Showing
10 changed files
with
285 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const PencilIcon = () => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="1.2em" | ||
height="1.2em" | ||
viewBox="0 0 256 256" | ||
> | ||
<path | ||
fill="currentColor" | ||
d="m225.9 74.78l-44.69-44.69a14 14 0 0 0-19.8 0L38.1 153.41a13.94 13.94 0 0 0-4.1 9.9V208a14 14 0 0 0 14 14h44.69a13.94 13.94 0 0 0 9.9-4.1L225.9 94.58a14 14 0 0 0 0-19.8M48.49 160L136 72.48L155.51 92L68 179.51ZM46 208v-33.52L81.51 210H48a2 2 0 0 1-2-2m50-.49L76.49 188L164 100.48L183.51 120ZM217.41 86.1L192 111.51L144.49 64l25.41-25.42a2 2 0 0 1 2.83 0l44.68 44.69a2 2 0 0 1 0 2.83" | ||
/> | ||
</svg> | ||
); | ||
}; |
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
40 changes: 40 additions & 0 deletions
40
src/pods/thumb-pages/components/context-menu/context-menu.component.module.css
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,40 @@ | ||
.context-menu { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 80%; | ||
height: auto; | ||
transform: translate(-50%, -50%); | ||
border: 1px solid var(--primary-500); | ||
background-color: var(--primary-100); | ||
opacity: 0.9; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
gap: 0.5em; | ||
align-items: center; | ||
font-size: var(--fs-xs); | ||
padding: var(--space-xs) var(--space-md); | ||
border-bottom: 1px solid var(--primary-300); | ||
cursor: pointer; | ||
} | ||
|
||
.container :first-child { | ||
flex: 1; | ||
} | ||
|
||
.container:hover { | ||
background-color: var(--primary-200); | ||
} | ||
|
||
.disabled { | ||
cursor: not-allowed; | ||
opacity: 0.5; | ||
background-color: var(--primary-200); | ||
} | ||
|
||
.shortcut { | ||
color: var(--primary-400); | ||
font-weight: 500; | ||
} |
75 changes: 75 additions & 0 deletions
75
src/pods/thumb-pages/components/context-menu/context-menu.component.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,75 @@ | ||
import React from 'react'; | ||
import { useCanvasContext } from '@/core/providers'; | ||
import classes from './context-menu.component.module.css'; | ||
import { CopyIcon, DeleteIcon } from '@/common/components/icons'; | ||
|
||
interface ThumbPageContextMenuProps { | ||
contextMenuRef: React.RefObject<HTMLDivElement>; | ||
setShowContextMenu: (show: boolean) => void; | ||
pageIndex: number; | ||
} | ||
|
||
export const ThumbPageContextMenu: React.FunctionComponent< | ||
ThumbPageContextMenuProps | ||
> = props => { | ||
const { contextMenuRef, setShowContextMenu, pageIndex } = props; | ||
const { | ||
setIsThumbnailContextMenuVisible, | ||
fullDocument, | ||
duplicatePage, | ||
deletePage, | ||
} = useCanvasContext(); | ||
|
||
enum ContextButtonType { | ||
'Duplicate', | ||
'Rename', | ||
'Delete', | ||
} | ||
|
||
const handleClickOnContextButton = ( | ||
event: React.MouseEvent, | ||
buttonClicked: ContextButtonType | ||
) => { | ||
event.stopPropagation(); | ||
switch (buttonClicked) { | ||
case ContextButtonType.Duplicate: | ||
duplicatePage(pageIndex); | ||
break; | ||
case ContextButtonType.Rename: | ||
console.log('Rename'); | ||
break; | ||
case ContextButtonType.Delete: | ||
deletePage(pageIndex); | ||
break; | ||
} | ||
setShowContextMenu(false); | ||
setIsThumbnailContextMenuVisible(false); | ||
}; | ||
|
||
return ( | ||
<div ref={contextMenuRef} className={classes['context-menu']}> | ||
<div | ||
onClick={event => | ||
handleClickOnContextButton(event, ContextButtonType.Duplicate) | ||
} | ||
className={classes.container} | ||
> | ||
<p>Duplicate</p> | ||
<CopyIcon /> | ||
</div> | ||
<div | ||
onClick={event => | ||
handleClickOnContextButton(event, ContextButtonType.Delete) | ||
} | ||
className={ | ||
fullDocument.pages.length === 1 | ||
? `${classes.container} ${classes.disabled}` | ||
: `${classes.container}` | ||
} | ||
> | ||
<p>Delete</p> | ||
<DeleteIcon /> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.