mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-10 12:32:28 +10:00
Merge branch 'infinia-yzl-main'
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import { SectionKey } from "@reactive-resume/schema";
|
import { SectionKey } from "@reactive-resume/schema";
|
||||||
import { pageSizeMap, Template } from "@reactive-resume/utils";
|
import { pageSizeMap, Template } from "@reactive-resume/utils";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
import { useEffect, useMemo, useRef } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { ReactZoomPanPinchRef, TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
|
import { ReactZoomPanPinchRef, TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
|
||||||
|
|
||||||
import { MM_TO_PX, Page } from "../components/page";
|
import { MM_TO_PX, Page } from "../components/page";
|
||||||
@ -14,6 +14,8 @@ export const BuilderLayout = () => {
|
|||||||
const layout = useArtboardStore((state) => state.resume.metadata.layout);
|
const layout = useArtboardStore((state) => state.resume.metadata.layout);
|
||||||
const template = useArtboardStore((state) => state.resume.metadata.template as Template);
|
const template = useArtboardStore((state) => state.resume.metadata.template as Template);
|
||||||
|
|
||||||
|
const [wheelPanning, setWheelPanning] = useState(true);
|
||||||
|
|
||||||
const Template = useMemo(() => getTemplate(template), [template]);
|
const Template = useMemo(() => getTemplate(template), [template]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -27,6 +29,9 @@ export const BuilderLayout = () => {
|
|||||||
transformRef.current?.resetTransform(0);
|
transformRef.current?.resetTransform(0);
|
||||||
setTimeout(() => transformRef.current?.centerView(0.8, 0), 10);
|
setTimeout(() => transformRef.current?.centerView(0.8, 0), 10);
|
||||||
}
|
}
|
||||||
|
if (event.data.type === "TOGGLE_PAN_MODE") {
|
||||||
|
setWheelPanning(event.data.panMode);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("message", handleMessage);
|
window.addEventListener("message", handleMessage);
|
||||||
@ -44,6 +49,12 @@ export const BuilderLayout = () => {
|
|||||||
minScale={0.4}
|
minScale={0.4}
|
||||||
initialScale={0.8}
|
initialScale={0.8}
|
||||||
limitToBounds={false}
|
limitToBounds={false}
|
||||||
|
panning={{
|
||||||
|
wheelPanning: wheelPanning,
|
||||||
|
}}
|
||||||
|
wheel={{
|
||||||
|
wheelDisabled: wheelPanning,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<TransformComponent
|
<TransformComponent
|
||||||
wrapperClass="!w-screen !h-screen"
|
wrapperClass="!w-screen !h-screen"
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { t } from "@lingui/macro";
|
|||||||
import {
|
import {
|
||||||
ArrowClockwise,
|
ArrowClockwise,
|
||||||
ArrowCounterClockwise,
|
ArrowCounterClockwise,
|
||||||
|
ArrowsOutCardinal,
|
||||||
CircleNotch,
|
CircleNotch,
|
||||||
ClockClockwise,
|
ClockClockwise,
|
||||||
CubeFocus,
|
CubeFocus,
|
||||||
@ -9,6 +10,7 @@ import {
|
|||||||
Hash,
|
Hash,
|
||||||
LineSegment,
|
LineSegment,
|
||||||
LinkSimple,
|
LinkSimple,
|
||||||
|
MagnifyingGlass,
|
||||||
MagnifyingGlassMinus,
|
MagnifyingGlassMinus,
|
||||||
MagnifyingGlassPlus,
|
MagnifyingGlassPlus,
|
||||||
} from "@phosphor-icons/react";
|
} from "@phosphor-icons/react";
|
||||||
@ -19,6 +21,7 @@ import { useToast } from "@/client/hooks/use-toast";
|
|||||||
import { usePrintResume } from "@/client/services/resume";
|
import { usePrintResume } from "@/client/services/resume";
|
||||||
import { useBuilderStore } from "@/client/stores/builder";
|
import { useBuilderStore } from "@/client/stores/builder";
|
||||||
import { useResumeStore, useTemporalResumeStore } from "@/client/stores/resume";
|
import { useResumeStore, useTemporalResumeStore } from "@/client/stores/resume";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
const openInNewTab = (url: string) => {
|
const openInNewTab = (url: string) => {
|
||||||
const win = window.open(url, "_blank");
|
const win = window.open(url, "_blank");
|
||||||
@ -31,6 +34,7 @@ export const BuilderToolbar = () => {
|
|||||||
const undo = useTemporalResumeStore((state) => state.undo);
|
const undo = useTemporalResumeStore((state) => state.undo);
|
||||||
const redo = useTemporalResumeStore((state) => state.redo);
|
const redo = useTemporalResumeStore((state) => state.redo);
|
||||||
const frameRef = useBuilderStore((state) => state.frame.ref);
|
const frameRef = useBuilderStore((state) => state.frame.ref);
|
||||||
|
const [panMode, setPanMode] = useState<boolean>(true);
|
||||||
|
|
||||||
const id = useResumeStore((state) => state.resume.id);
|
const id = useResumeStore((state) => state.resume.id);
|
||||||
const isPublic = useResumeStore((state) => state.resume.visibility === "public");
|
const isPublic = useResumeStore((state) => state.resume.visibility === "public");
|
||||||
@ -59,6 +63,10 @@ export const BuilderToolbar = () => {
|
|||||||
const onZoomOut = () => frameRef?.contentWindow?.postMessage({ type: "ZOOM_OUT" }, "*");
|
const onZoomOut = () => frameRef?.contentWindow?.postMessage({ type: "ZOOM_OUT" }, "*");
|
||||||
const onResetView = () => frameRef?.contentWindow?.postMessage({ type: "RESET_VIEW" }, "*");
|
const onResetView = () => frameRef?.contentWindow?.postMessage({ type: "RESET_VIEW" }, "*");
|
||||||
const onCenterView = () => frameRef?.contentWindow?.postMessage({ type: "CENTER_VIEW" }, "*");
|
const onCenterView = () => frameRef?.contentWindow?.postMessage({ type: "CENTER_VIEW" }, "*");
|
||||||
|
const onTogglePanMode = () => {
|
||||||
|
setPanMode(!panMode); // local button state
|
||||||
|
frameRef?.contentWindow?.postMessage({ type: "TOGGLE_PAN_MODE", panMode: !panMode }, "*"); // toggle artboard state
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div className="fixed inset-x-0 bottom-0 mx-auto hidden py-6 text-center md:block">
|
<motion.div className="fixed inset-x-0 bottom-0 mx-auto hidden py-6 text-center md:block">
|
||||||
@ -91,6 +99,20 @@ export const BuilderToolbar = () => {
|
|||||||
|
|
||||||
<Separator orientation="vertical" className="h-9" />
|
<Separator orientation="vertical" className="h-9" />
|
||||||
|
|
||||||
|
<Tooltip
|
||||||
|
content={
|
||||||
|
panMode
|
||||||
|
? t`Scroll to Pan (Click to switch to Zoom)`
|
||||||
|
: t`Scroll to Zoom (Click to switch to Pan)`
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Toggle className="rounded-none" pressed={panMode} onPressedChange={onTogglePanMode}>
|
||||||
|
{panMode ? <ArrowsOutCardinal /> : <MagnifyingGlass />}
|
||||||
|
</Toggle>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Separator orientation="vertical" className="h-9" />
|
||||||
|
|
||||||
<Tooltip content={t`Zoom In`}>
|
<Tooltip content={t`Zoom In`}>
|
||||||
<Button size="icon" variant="ghost" className="rounded-none" onClick={onZoomIn}>
|
<Button size="icon" variant="ghost" className="rounded-none" onClick={onZoomIn}>
|
||||||
<MagnifyingGlassPlus />
|
<MagnifyingGlassPlus />
|
||||||
|
|||||||
Reference in New Issue
Block a user