2022-06-07 10:48:47 +00:00
|
|
|
import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons"
|
|
|
|
import { useTranslation } from "next-i18next"
|
2022-06-11 03:08:49 +00:00
|
|
|
import { useDefinedContext } from "../../../utils/definedContext"
|
|
|
|
import { FestaIcon } from "../../generic/renderers/fontawesome"
|
|
|
|
import { Tool } from "../../generic/toolbar/tool"
|
|
|
|
import { PostcardContext, PostcardVisibility } from "../base"
|
2022-06-07 10:48:47 +00:00
|
|
|
|
2022-06-11 03:08:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Toolbar tool which toggles the {@link PostcardVisibility} state of its wrapping context.
|
|
|
|
*/
|
|
|
|
export function ToolToggleVisibility() {
|
2022-06-09 21:43:38 +00:00
|
|
|
const { t } = useTranslation()
|
|
|
|
const { visibility, setVisibility } = useDefinedContext(PostcardContext)
|
2022-06-07 10:48:47 +00:00
|
|
|
|
2022-06-09 21:43:38 +00:00
|
|
|
if (visibility === PostcardVisibility.BACKGROUND) {
|
|
|
|
return (
|
2022-06-11 03:08:49 +00:00
|
|
|
<Tool
|
2022-06-09 21:43:38 +00:00
|
|
|
aria-label={t("toggleVisibleShow")}
|
|
|
|
onClick={() => setVisibility(PostcardVisibility.FOREGROUND)}
|
|
|
|
>
|
|
|
|
<FestaIcon icon={faEye} />
|
2022-06-11 03:08:49 +00:00
|
|
|
</Tool>
|
2022-06-09 21:43:38 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (
|
2022-06-11 03:08:49 +00:00
|
|
|
<Tool
|
2022-06-09 21:43:38 +00:00
|
|
|
aria-label={t("toggleVisibleHide")}
|
|
|
|
onClick={() => setVisibility(PostcardVisibility.BACKGROUND)}
|
|
|
|
>
|
|
|
|
<FestaIcon icon={faEyeSlash} />
|
2022-06-11 03:08:49 +00:00
|
|
|
</Tool>
|
2022-06-09 21:43:38 +00:00
|
|
|
)
|
|
|
|
}
|
2022-06-11 03:08:49 +00:00
|
|
|
}
|