Skip to content

Commit 81f717a

Browse files
committed
Fix type errors
1 parent 3a5d042 commit 81f717a

File tree

3 files changed

+43
-30
lines changed

3 files changed

+43
-30
lines changed

packages/sdk-components-animation/src/scroll.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const Story = {
7575
padding: 0,
7676
"&:hover": {
7777
color: "red",
78+
transform: "scale(1.1)",
7879
},
7980
}}
8081
>
@@ -83,8 +84,7 @@ const Story = {
8384
</Scroll>
8485
<Box css={{ height: "200px", backgroundColor: "#eee", p: 4 }}>
8586
Start scrolling, and when the current box scrolls out, the “HELLO
86-
WORLD” header will fly in and become hoverable. (During the animation,
87-
it won’t be hoverable.)
87+
WORLD” header will finish animation
8888
</Box>
8989
<Box css={{ height: "200vh" }}></Box>
9090
<Box css={{ height: "200px", backgroundColor: "#eee", p: 4 }}>

packages/sdk-components-animation/src/scroll.tsx

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Suspense, useId, useLayoutEffect } from "react";
1+
import {
2+
forwardRef,
3+
Suspense,
4+
useId,
5+
useLayoutEffect,
6+
type ElementRef,
7+
} from "react";
28
import { ErrorBoundary } from "react-error-boundary";
39
import { ClientOnly } from "./shared/client-only";
410
import { PolyfillLoader } from "./shared/scroll-polyfill";
@@ -165,29 +171,35 @@ type ScrollProps = {
165171
action: AnimationAction;
166172
};
167173

168-
export const Scroll = ({ debug = false, children, action }: ScrollProps) => {
169-
const nakedId = useId();
170-
const id = escapeCssSpecifier(nakedId);
171-
172-
return (
173-
<>
174-
<ClientOnly fallback={<StylesBeforeAnimate id={id} action={action} />}>
175-
<Suspense fallback={<StylesBeforeAnimate id={id} action={action} />}>
176-
<ErrorBoundary
177-
fallback={null}
178-
onError={(error) => {
179-
console.error(`Polyfill loading error`, error);
180-
}}
181-
>
182-
<PolyfillLoader />
183-
{debug && <DebugDelayLoader />}
184-
</ErrorBoundary>
185-
<Animate id={id} action={action} />
186-
</Suspense>
187-
</ClientOnly>
188-
<div {...{ [componentAttributeId]: id }} style={{ display: "contents" }}>
189-
{children}
190-
</div>
191-
</>
192-
);
193-
};
174+
export const Scroll = forwardRef<ElementRef<"div">, ScrollProps>(
175+
({ debug = false, children, action }, ref) => {
176+
const nakedId = useId();
177+
const id = escapeCssSpecifier(nakedId);
178+
179+
return (
180+
<>
181+
<ClientOnly fallback={<StylesBeforeAnimate id={id} action={action} />}>
182+
<Suspense fallback={<StylesBeforeAnimate id={id} action={action} />}>
183+
<ErrorBoundary
184+
fallback={null}
185+
onError={(error) => {
186+
console.error(`Polyfill loading error`, error);
187+
}}
188+
>
189+
<PolyfillLoader />
190+
{debug && <DebugDelayLoader />}
191+
</ErrorBoundary>
192+
<Animate id={id} action={action} />
193+
</Suspense>
194+
</ClientOnly>
195+
<div
196+
ref={ref}
197+
{...{ [componentAttributeId]: id }}
198+
style={{ display: "contents" }}
199+
>
200+
{children}
201+
</div>
202+
</>
203+
);
204+
}
205+
);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "@webstudio-is/tsconfig/base.json",
3+
"include": ["src", "types"],
34
"compilerOptions": {
4-
"types": ["react/experimental", "react-dom/experimental"]
5+
"types": ["react/experimental", "react-dom/experimental", "@types/node"]
56
}
67
}

0 commit comments

Comments
 (0)