mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 22:54:22 +00:00
Add some events to ToolToggleEditing
This commit is contained in:
parent
5105ea9045
commit
3ce0b5698f
1 changed files with 19 additions and 3 deletions
|
@ -6,10 +6,18 @@ import { FestaIcon } from "../../generic/renderers/fontawesome"
|
|||
import { Tool } from "../../generic/toolbar/tool"
|
||||
|
||||
|
||||
export type ToolToggleEditingProps = {
|
||||
onViewStart?: () => void,
|
||||
onViewEnd?: () => void,
|
||||
onEditStart?: () => void,
|
||||
onEditEnd?: () => void,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ToolBar {@link Tool} which switches between {@link EditingMode}s of the surrounding context.
|
||||
*/
|
||||
export function ToolToggleEditing() {
|
||||
export function ToolToggleEditing({ onViewStart, onViewEnd, onEditStart, onEditEnd }: ToolToggleEditingProps) {
|
||||
const { t } = useTranslation()
|
||||
const [editing, setEditing] = useDefinedContext(EditingContext)
|
||||
|
||||
|
@ -17,7 +25,11 @@ export function ToolToggleEditing() {
|
|||
return (
|
||||
<Tool
|
||||
aria-label={t("toggleEditingView")}
|
||||
onClick={() => setEditing(EditingMode.VIEW)}
|
||||
onClick={() => {
|
||||
onEditEnd?.()
|
||||
setEditing(EditingMode.VIEW)
|
||||
onViewStart?.()
|
||||
}}
|
||||
>
|
||||
<FestaIcon icon={faBinoculars} />
|
||||
</Tool>
|
||||
|
@ -27,7 +39,11 @@ export function ToolToggleEditing() {
|
|||
return (
|
||||
<Tool
|
||||
aria-label={t("toggleEditingEdit")}
|
||||
onClick={() => setEditing(EditingMode.EDIT)}
|
||||
onClick={() => {
|
||||
onViewEnd?.()
|
||||
setEditing(EditingMode.EDIT)
|
||||
onEditStart?.()
|
||||
}}
|
||||
>
|
||||
<FestaIcon icon={faPencil} />
|
||||
</Tool>
|
||||
|
|
Loading…
Reference in a new issue