Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-ears-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vortexjs/move": minor
---

Add layout animations
76 changes: 60 additions & 16 deletions packages/example/src/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
list,
render,
useDerived,
useHookLifetime,
useState,
when,
} from "@vortexjs/core";
import { html } from "@vortexjs/dom";
import { useSpring } from "@vortexjs/move";
import { layout } from "@vortexjs/move";

const TestingContext = createContext<string>("TestingContext");

Expand All @@ -18,26 +19,69 @@ function TestingComponent() {
return <p>This is a testing component. Context data: {ctxData}</p>;
}

function SpringSliders() {
function LayoutTest() {
const targetValue = useState(0);
const spring = useSpring(targetValue);
const height = useDerived((get) => `${get(spring.signal)}px`);
const width = useDerived((get) => `${10000 / get(spring.signal)}px`);
const lt = useHookLifetime();

return (
<>
<input type="range" min="25" max="125" bind:value={targetValue} />
<div
style={{
backgroundColor: "red",
width,
height,
position: "fixed",
left: "50vw",
top: "50vh",
transform: "translate(-50%, -50%)",
display: "flex",
justifyContent: "center",
alignItems: "center",
width: "200px",
height: "200px",
backgroundColor: "#eee",
}}
/>
>
<button type="button" use={layout()}>
Test
</button>
</div>
<div className="resizer">
{list(
"Fugiat reprehenderit occaecat aute id esse enim ea labore do minim amet velit deserunt exercitation. Minim esse voluptate fugiat est non et fugiat amet duis.".split(
" ",
),
).show((x, _i) => (
<>
<span
className="inline-char"
use={layout({ spring: { weight: 0.05 } })}
>
{x}
</span>
<span> </span>
</>
))}
</div>
</>
);
}

function PopupTest() {
const isOpen = useState(false);

return (
<>
<button
type="button"
on:click={() => {
isOpen.set(!getImmediateValue(isOpen));
}}
use={layout({ id: "popupButton", spring: { weight: 0.5 } })}
>
Toggle Popup
</button>
{when(isOpen, () => (
<div
className="popup"
use={layout({ startsFrom: "popupButton" })}
>
This is a popup!
</div>
))}
</>
);
}
Expand Down Expand Up @@ -67,7 +111,6 @@ function App() {
on:click={() => {
counter.set(getImmediateValue(counter) + 100);
}}
use={({ ref: element }) => console.log("button element: ", element)}
type="button"
>
Increment
Expand All @@ -86,7 +129,8 @@ function App() {
</p>
))}

<SpringSliders />
<LayoutTest />
<PopupTest />
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/example/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bun + React</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div id="root"></div>
Expand Down
34 changes: 34 additions & 0 deletions packages/example/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
button {
padding: 10px;
}

.resizer {
padding: 30px;
border: 1px solid #ccc;
resize: both;
font-size: 200%;
width: 500px;
overflow: auto;
}

.inline-char {
display: inline-block;
}

.popup {
padding: 30px;
background: #f0f0f0;
border: 1px solid #ccc;
width: 50%;
margin: 20px;
transition:
opacity,
filter ease-out 0.2s;
}

@starting-style {
.popup {
opacity: 0;
filter: blur(40px);
}
}
42 changes: 25 additions & 17 deletions packages/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "bundler",
"jsx": "react-jsx",
"jsxImportSource": "@vortexjs/dom",
"allowJs": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["dist", "node_modules"]
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"moduleResolution": "bundler",
"jsx": "react-jsx",
"jsxImportSource": "@vortexjs/dom",
"allowJs": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
},
"exclude": [
"dist",
"node_modules"
]
}
59 changes: 30 additions & 29 deletions packages/vortex-move/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
{
"name": "@vortexjs/move",
"type": "module",
"license": "MIT-0",
"repository": {
"url": "https://github.com/rectangle-run/vortex"
},
"devDependencies": {
"@types/bun": "catalog:",
"tsdown": "catalog:"
},
"dependencies": {
"@vortexjs/core": "workspace:*",
"@vortexjs/dom": "workspace:*",
"@vortexjs/common": "workspace:*"
},
"peerDependencies": {
"typescript": "catalog:"
},
"scripts": {
"build": "tsdown ./src/index.ts --format esm --dts --out-dir dist"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"version": "0.0.0"
"name": "@vortexjs/move",
"type": "module",
"license": "MIT-0",
"repository": {
"url": "https://github.com/rectangle-run/vortex"
},
"devDependencies": {
"@types/bun": "catalog:",
"tsdown": "catalog:"
},
"dependencies": {
"@vortexjs/core": "workspace:*",
"@vortexjs/dom": "workspace:*",
"@vortexjs/common": "workspace:*"
},
"peerDependencies": {
"typescript": "catalog:"
},
"scripts": {
"build": "tsdown ./src/index.ts --format esm --dts --out-dir dist",
"test": "bun test"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"version": "0.0.0"
}
2 changes: 2 additions & 0 deletions packages/vortex-move/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from "./layout";
export * from "./projection";
export * from "./scheduler";
export * from "./spring";
Loading