Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/okikio/solid-motion-experiments.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import { expectTypeOf } from "expect-type";import type { Component, JSX } from "solid-js";import type { Variants } from "motion-dom";
import { AnimatePresence, Presence, motion, type MotionComponent, type MotionComponentProps, type MotionProps,} from "../index.ts";
declare const isOpen: () => boolean;
type CardProps = { title: string; class?: string;};
declare const Card: Component<CardProps>;
const MotionCard = motion.create(Card);
const variants: Variants = { closed: { opacity: 0, y: 16 }, open: () => ({ opacity: 1, y: 0 }),};
expectTypeOf(motion.div).toMatchTypeOf<MotionComponent<"div">>();expectTypeOf(motion.svg).toMatchTypeOf<MotionComponent<"svg">>();expectTypeOf(MotionCard).toMatchTypeOf<MotionComponent<typeof Card>>();expectTypeOf(Presence).toEqualTypeOf(AnimatePresence);expectTypeOf<MotionComponentProps<"div">["animate"]>().toMatchTypeOf< MotionProps["animate"]>();expectTypeOf<MotionComponentProps<"div">["style"]>().toMatchTypeOf<MotionProps["style"]>();
expectTypeOf(<motion.div id="card" class="card" data-state="open" />).toMatchTypeOf<JSX.Element>();expectTypeOf( <motion.button type="button" disabled whileTap={{ scale: 0.96 }} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <motion.div style={{ x: 12, y: "1rem", scale: 1.05, rotate: 45, opacity: 0.8, }} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <motion.div animate={() => ({ opacity: isOpen() ? 1 : 0, x: isOpen() ? 0 : -24, })} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <motion.div variants={variants} initial="closed" animate="open" custom={{ direction: 1 }} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <motion.svg viewBox="0 0 10 10" animate={{ opacity: 1 }}> <motion.path d="M0 0 L10 10" pathLength={1} style={{ pathLength: 1 }} /> </motion.svg>,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <MotionCard title="Card" class="card" animate={{ opacity: 1 }} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <MotionCard title="Card" forwardMotionProps animate={() => ({ opacity: isOpen() ? 1 : 0 })} />,).toMatchTypeOf<JSX.Element>();
expectTypeOf( <Presence initial={false} mode="sync"> <motion.div presenceKey="child" exit={{ opacity: 0 }} /> </Presence>,).toMatchTypeOf<JSX.Element>();
// @ts-expect-error href is not a valid div prop.<motion.div href="/nope" />;
// @ts-expect-error intrinsic SVG path props should stay SVG-specific.<motion.path href="/nope" />;
// @ts-expect-error custom components should keep their required props.<MotionCard />;
// @ts-expect-error custom components should reject props outside their public surface.<MotionCard title="Card" href="/nope" />;