Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+90
@@ -0,0 +1,90 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { cleanup, render } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { Description as RadixDialogDescription, Title as RadixDialogTitle } from "@radix-ui/react-dialog";
|
||||
import { Drawer } from "../Drawer";
|
||||
import { FullscreenDialog } from "../FullscreenDialog";
|
||||
import { ModalBlank } from "../ModalBlank";
|
||||
import { Select } from "../Select";
|
||||
import { Dialog } from ".";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
function expectModalLayer() {
|
||||
const layer = document.querySelector<HTMLElement>('[data-ui-layer="modal"]');
|
||||
expect(layer).not.toBeNull();
|
||||
expect(layer).toHaveClass("z-[60]");
|
||||
return layer!;
|
||||
}
|
||||
|
||||
describe("Subframe modal layering", () => {
|
||||
it("places dialogs above the app sidebar", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<Dialog.Content>Dialog content</Dialog.Content>
|
||||
</Dialog>,
|
||||
);
|
||||
|
||||
const layer = expectModalLayer();
|
||||
expect(layer).toHaveClass("bg-black/35", "backdrop-blur-[4px]", "data-[state=open]:duration-300");
|
||||
expect(document.querySelector('[data-state="open"][role="dialog"]')).toHaveClass(
|
||||
"data-[state=open]:zoom-in-[0.98]",
|
||||
"data-[state=open]:slide-in-from-bottom-1",
|
||||
"motion-reduce:animate-none",
|
||||
);
|
||||
});
|
||||
|
||||
it("uses the same modal layer for blank modals, drawers and fullscreen dialogs", () => {
|
||||
const { unmount: unmountModal } = render(
|
||||
<ModalBlank open>
|
||||
<ModalBlank.Content>Modal content</ModalBlank.Content>
|
||||
</ModalBlank>,
|
||||
);
|
||||
expectModalLayer();
|
||||
unmountModal();
|
||||
|
||||
const { unmount: unmountDrawer } = render(
|
||||
<Drawer open>
|
||||
<Drawer.Content>Drawer content</Drawer.Content>
|
||||
</Drawer>,
|
||||
);
|
||||
const drawerLayer = expectModalLayer();
|
||||
expect(drawerLayer).toHaveClass("hg-drawer-backdrop", "backdrop-blur-[4px]");
|
||||
expect(drawerLayer).not.toHaveClass("data-[state=closed]:fade-out-0");
|
||||
expect(document.querySelector('[data-state="open"][role="dialog"]')).toHaveClass(
|
||||
"data-[state=open]:slide-in-from-right",
|
||||
"data-[state=closed]:slide-out-to-right",
|
||||
"data-[state=open]:duration-[360ms]",
|
||||
"motion-reduce:animate-none",
|
||||
);
|
||||
unmountDrawer();
|
||||
|
||||
render(
|
||||
<FullscreenDialog open>
|
||||
<div>
|
||||
<RadixDialogTitle className="sr-only">Fullscreen title</RadixDialogTitle>
|
||||
<RadixDialogDescription className="sr-only">Fullscreen description</RadixDialogDescription>
|
||||
Fullscreen content
|
||||
</div>
|
||||
</FullscreenDialog>,
|
||||
);
|
||||
expectModalLayer();
|
||||
});
|
||||
|
||||
it("keeps portalled select menus above an open modal", () => {
|
||||
render(
|
||||
<Dialog open>
|
||||
<Dialog.Content>
|
||||
<Select open value="one" onValueChange={() => undefined}>
|
||||
<Select.Item value="one">One</Select.Item>
|
||||
</Select>
|
||||
</Dialog.Content>
|
||||
</Dialog>,
|
||||
);
|
||||
|
||||
const floatingLayer = document.querySelector<HTMLElement>('[data-ui-layer="modal-floating"]');
|
||||
expect(floatingLayer).not.toBeNull();
|
||||
expect(floatingLayer).toHaveClass("z-[70]");
|
||||
});
|
||||
});
|
||||
+29
-1
@@ -1,5 +1,10 @@
|
||||
// @subframe/sync-disable
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { Dialog as DialogComponent } from "./Dialog";
|
||||
import { MODAL_LAYER_CLASS } from "../../layers";
|
||||
import { MODAL_CONTENT_MOTION_CLASS, MODAL_OVERLAY_MOTION_CLASS } from "../../modal-motion";
|
||||
import * as SubframeUtils from "../../utils";
|
||||
|
||||
/**
|
||||
* Add wrapper components and business logic here.
|
||||
@@ -7,4 +12,27 @@ import { Dialog as DialogComponent } from "./Dialog";
|
||||
* Learn more: https://docs.subframe.com/concepts/syncing-components#wrapping-components
|
||||
*/
|
||||
|
||||
export const Dialog = DialogComponent;
|
||||
const DialogRoot = React.forwardRef<
|
||||
React.ElementRef<typeof DialogComponent>,
|
||||
React.ComponentProps<typeof DialogComponent>
|
||||
>(function DialogRoot({ className, ...otherProps }, ref) {
|
||||
return (
|
||||
<DialogComponent
|
||||
className={SubframeUtils.twClassNames(MODAL_LAYER_CLASS, MODAL_OVERLAY_MOTION_CLASS, className)}
|
||||
data-ui-layer="modal"
|
||||
ref={ref}
|
||||
{...otherProps}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogComponent.Content>,
|
||||
React.ComponentProps<typeof DialogComponent.Content>
|
||||
>(function DialogContent({ className, ...otherProps }, ref) {
|
||||
return <DialogComponent.Content className={SubframeUtils.twClassNames(MODAL_CONTENT_MOTION_CLASS, className)} ref={ref} {...otherProps} />;
|
||||
});
|
||||
|
||||
export const Dialog = Object.assign(DialogRoot, {
|
||||
Content: DialogContent,
|
||||
});
|
||||
Reference in new issue
Block a user