mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
chore: add missing translations
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_BUILDER_LAYOUT,
|
||||
DESKTOP_BUILDER_SIDEBAR_COLLAPSED_SIZE,
|
||||
DESKTOP_BUILDER_SIDEBAR_MIN_SIZE,
|
||||
getBuilderSidebarResizeConfig,
|
||||
mapPanelLayoutToBuilderLayout,
|
||||
parseBuilderLayoutCookie,
|
||||
useBuilderSidebarStore,
|
||||
@@ -64,6 +67,25 @@ describe("mapPanelLayoutToBuilderLayout", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getBuilderSidebarResizeConfig", () => {
|
||||
it("uses a desktop minimum width that is larger than the collapsed rail", () => {
|
||||
const config = getBuilderSidebarResizeConfig({ isMobile: false, width: 1280 });
|
||||
|
||||
expect(config.minSidebarSize).toBe(DESKTOP_BUILDER_SIDEBAR_MIN_SIZE);
|
||||
expect(config.collapsedSidebarSize).toBe(DESKTOP_BUILDER_SIDEBAR_COLLAPSED_SIZE);
|
||||
expect(config.minSidebarSize).toBeGreaterThan(config.collapsedSidebarSize);
|
||||
expect(config.groupResizeBehavior).toBe("preserve-pixel-size");
|
||||
});
|
||||
|
||||
it("allows mobile sidebars to collapse fully without a desktop minimum", () => {
|
||||
const config = getBuilderSidebarResizeConfig({ isMobile: true, width: 390 });
|
||||
|
||||
expect(config.minSidebarSize).toBe(0);
|
||||
expect(config.collapsedSidebarSize).toBe(0);
|
||||
expect(config.maxSidebarSize).toBe("95%");
|
||||
});
|
||||
});
|
||||
|
||||
describe("useBuilderSidebarStore", () => {
|
||||
it("starts with default layout and null panel refs", () => {
|
||||
const state = useBuilderSidebarStore.getState();
|
||||
|
||||
@@ -20,6 +20,22 @@ export const DEFAULT_BUILDER_LAYOUT: BuilderLayout = {
|
||||
right: 22,
|
||||
};
|
||||
|
||||
export const DESKTOP_BUILDER_SIDEBAR_COLLAPSED_SIZE = 48;
|
||||
export const DESKTOP_BUILDER_SIDEBAR_MIN_SIZE = 320;
|
||||
|
||||
type BuilderSidebarResizeConfigInput = {
|
||||
isMobile: boolean;
|
||||
width: number;
|
||||
};
|
||||
|
||||
export const getBuilderSidebarResizeConfig = ({ isMobile, width }: BuilderSidebarResizeConfigInput) => ({
|
||||
maxSidebarSize: !width ? 0 : isMobile ? "95%" : "45%",
|
||||
minSidebarSize: !width ? 0 : isMobile ? 0 : DESKTOP_BUILDER_SIDEBAR_MIN_SIZE,
|
||||
collapsedSidebarSize: !width ? 0 : isMobile ? 0 : DESKTOP_BUILDER_SIDEBAR_COLLAPSED_SIZE,
|
||||
expandSize: isMobile ? "95%" : "30%",
|
||||
groupResizeBehavior: "preserve-pixel-size" as const,
|
||||
});
|
||||
|
||||
export const mapPanelLayoutToBuilderLayout = (layout: Layout): BuilderLayout => {
|
||||
const left = layout.left;
|
||||
const artboard = layout.artboard;
|
||||
@@ -78,7 +94,9 @@ export const useBuilderSidebarStore = create<BuilderSidebar>((set) => ({
|
||||
|
||||
type UseBuilderSidebarReturn = {
|
||||
maxSidebarSize: string | number;
|
||||
minSidebarSize: number;
|
||||
collapsedSidebarSize: number;
|
||||
groupResizeBehavior: "preserve-pixel-size";
|
||||
isCollapsed: (side: "left" | "right") => boolean;
|
||||
toggleSidebar: (side: "left" | "right", forceState?: boolean) => void;
|
||||
};
|
||||
@@ -87,9 +105,8 @@ export function useBuilderSidebar<T = UseBuilderSidebarReturn>(selector?: (build
|
||||
const isMobile = useIsMobile();
|
||||
const { width } = useWindowSize();
|
||||
|
||||
const maxSidebarSize: string | number = !width ? 0 : isMobile ? "95%" : "45%";
|
||||
const collapsedSidebarSize = !width ? 0 : isMobile ? 0 : 48;
|
||||
const expandSize = isMobile ? "95%" : "30%";
|
||||
const { maxSidebarSize, minSidebarSize, collapsedSidebarSize, expandSize, groupResizeBehavior } =
|
||||
getBuilderSidebarResizeConfig({ isMobile, width });
|
||||
|
||||
const isCollapsed = useCallback((side: "left" | "right") => {
|
||||
const sidebar =
|
||||
@@ -121,11 +138,13 @@ export function useBuilderSidebar<T = UseBuilderSidebarReturn>(selector?: (build
|
||||
const state = useMemo(() => {
|
||||
return {
|
||||
maxSidebarSize,
|
||||
minSidebarSize,
|
||||
collapsedSidebarSize,
|
||||
groupResizeBehavior,
|
||||
isCollapsed,
|
||||
toggleSidebar,
|
||||
};
|
||||
}, [maxSidebarSize, collapsedSidebarSize, isCollapsed, toggleSidebar]);
|
||||
}, [maxSidebarSize, minSidebarSize, collapsedSidebarSize, groupResizeBehavior, isCollapsed, toggleSidebar]);
|
||||
|
||||
return selector ? selector(state) : (state as T);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user