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"
|
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.
|
* 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 { t } = useTranslation()
|
||||||
const [editing, setEditing] = useDefinedContext(EditingContext)
|
const [editing, setEditing] = useDefinedContext(EditingContext)
|
||||||
|
|
||||||
|
@ -17,7 +25,11 @@ export function ToolToggleEditing() {
|
||||||
return (
|
return (
|
||||||
<Tool
|
<Tool
|
||||||
aria-label={t("toggleEditingView")}
|
aria-label={t("toggleEditingView")}
|
||||||
onClick={() => setEditing(EditingMode.VIEW)}
|
onClick={() => {
|
||||||
|
onEditEnd?.()
|
||||||
|
setEditing(EditingMode.VIEW)
|
||||||
|
onViewStart?.()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<FestaIcon icon={faBinoculars} />
|
<FestaIcon icon={faBinoculars} />
|
||||||
</Tool>
|
</Tool>
|
||||||
|
@ -27,7 +39,11 @@ export function ToolToggleEditing() {
|
||||||
return (
|
return (
|
||||||
<Tool
|
<Tool
|
||||||
aria-label={t("toggleEditingEdit")}
|
aria-label={t("toggleEditingEdit")}
|
||||||
onClick={() => setEditing(EditingMode.EDIT)}
|
onClick={() => {
|
||||||
|
onViewEnd?.()
|
||||||
|
setEditing(EditingMode.EDIT)
|
||||||
|
onEditStart?.()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<FestaIcon icon={faPencil} />
|
<FestaIcon icon={faPencil} />
|
||||||
</Tool>
|
</Tool>
|
||||||
|
|
Loading…
Reference in a new issue