Skip to content

Commit 1369532

Browse files
committed
fix(demo): fix React 19 type issues and reproduction for much overflow
release-npm
1 parent e8822c3 commit 1369532

File tree

6 files changed

+39
-31
lines changed

6 files changed

+39
-31
lines changed

arrow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CSSProperties, JSX, ReactNode } from 'react'
1+
import type React from 'react'
22
import type { FadeDirection } from './types'
33

44
type ArrowIcon = 'arrow-rounded' | 'pointer-rounded' | 'arrow' | 'pointer'
@@ -9,7 +9,7 @@ export interface ArrowProps {
99
icon: ArrowIcon
1010
color: string
1111
image?: string
12-
markup?: JSX.Element | ReactNode
12+
markup?: React.JSX.Element | React.ReactNode
1313
}
1414

1515
export const defaultArrowProps: ArrowProps = {
@@ -26,7 +26,7 @@ const directionToRotation = {
2626
}
2727

2828
export function Arrow({ icon, color, markup, image, direction }: ArrowProps & { direction: FadeDirection }) {
29-
const style: CSSProperties = {
29+
const style: React.CSSProperties = {
3030
width: 12,
3131
height: 12,
3232
display: 'block',

demo/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,13 @@ const MyGrid = () => (
309309
<Box />
310310
<Box />
311311
</Scroll>
312+
<Heading as="h3">Tons of overflow</Heading>
313+
<Paragraph>Fade in takes a long time to appear.</Paragraph>
314+
<Scroll overflowStyle={{ gap: scale(10) }}>
315+
{Array.from({ length: 200 }).map((_, i) => (
316+
<Box key={i} />
317+
))}
318+
</Scroll>
312319
<Heading as="h3">Dynamic Content Size</Heading>
313320
<Scroll style={{ maxWidth: 360 }} overflowStyle={{ gap: scale(10) }}>
314321
<DynamicContent>

demo/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
"types": "tsc"
77
},
88
"dependencies": {
9-
"@biomejs/biome": "^1.8.3",
10-
"@rsbuild/core": "^1.0.1-beta.11",
11-
"@rsbuild/plugin-react": "^1.0.1-beta.11",
12-
"@types/react": "^18.3.3",
13-
"@types/react-dom": "^18.3.0",
14-
"optica": "^3.0.0",
15-
"react": "^18.3.1",
16-
"react-dom": "^18.3.1",
17-
"sugar-high": "^0.7.0",
18-
"typescript": "^5.5.4"
9+
"@biomejs/biome": "^1.9.4",
10+
"@rsbuild/core": "^1.3.21",
11+
"@rsbuild/plugin-react": "^1.3.1",
12+
"@types/react": "^19.1.4",
13+
"@types/react-dom": "^19.1.5",
14+
"optica": "^3.0.1",
15+
"react": "^19.1.0",
16+
"react-dom": "^19.1.0",
17+
"sugar-high": "^0.9.3",
18+
"typescript": "^5.8.3"
1919
},
2020
"localDependencies": {
2121
"overflow-scroll-fade": ".."

index.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
import { type CSSProperties, type Dispatch, type JSX, type SetStateAction, useEffect, useRef, useState } from 'react'
1+
import type React from 'react'
2+
import { useEffect, useRef, useState } from 'react'
23
import { Arrow, type ArrowProps, defaultArrowProps, getArrowPosition } from './arrow'
34
import type { FadeDirection, Props, ScrollDirection } from './types'
45

56
const supportsScrollTimeline = 'scrollTimeline' in document.documentElement.style
67

7-
const wrapperStyles: CSSProperties = {
8+
const wrapperStyles: React.CSSProperties = {
89
position: 'relative',
910
}
1011

11-
const overflowStyles = (direction: ScrollDirection): CSSProperties => ({
12+
const overflowStyles = (direction: ScrollDirection): React.CSSProperties => ({
1213
display: 'flex',
1314
overflow: 'auto',
1415
height: direction === 'vertical' ? '100%' : 'auto',
1516
scrollTimelineName: '--indicate-scroll-element',
1617
scrollTimelineAxis: direction === 'horizontal' ? 'x' : 'y',
1718
})
1819

19-
const fadeStyles = (direction: FadeDirection, horizontal: boolean, color: string): CSSProperties => ({
20+
const fadeStyles = (direction: FadeDirection, horizontal: boolean, color: string): React.CSSProperties => ({
2021
display: 'flex',
2122
position: 'absolute',
2223
outline: 'none',
@@ -74,7 +75,7 @@ function checkOverflow(
7475
element: HTMLDivElement,
7576
direction: ScrollDirection,
7677
hasOverflow: boolean,
77-
setHasOverflow: Dispatch<SetStateAction<boolean>>,
78+
setHasOverflow: React.Dispatch<React.SetStateAction<boolean>>,
7879
) {
7980
if (element) {
8081
if (direction === 'horizontal') {
@@ -102,7 +103,7 @@ function getUserNodes(element: HTMLDivElement) {
102103
return nodes
103104
}
104105

105-
function Fallback<T extends keyof JSX.IntrinsicElements = 'div'>({
106+
function Fallback<T extends keyof React.JSX.IntrinsicElements = 'div'>({
106107
children,
107108
overflowStyle,
108109
style,
@@ -134,7 +135,7 @@ function Fade({
134135
arrow,
135136
}: {
136137
direction: FadeDirection
137-
style?: CSSProperties
138+
style?: React.CSSProperties
138139
color: string
139140
arrow: ArrowProps | boolean
140141
}) {
@@ -165,7 +166,7 @@ function Fade({
165166
)
166167
}
167168

168-
export function Scroll<T extends keyof JSX.IntrinsicElements = 'div'>({
169+
export function Scroll<T extends keyof React.JSX.IntrinsicElements = 'div'>({
169170
direction = 'horizontal',
170171
color = '#FFF',
171172
style = {},
@@ -201,7 +202,7 @@ export function Scroll<T extends keyof JSX.IntrinsicElements = 'div'>({
201202
observer.observe(element, { childList: true, subtree: true })
202203

203204
// Observe if any of the children change their size.
204-
if (userNodes.length) {
205+
if (userNodes.length > 0) {
205206
for (const node of userNodes) {
206207
resizeObserver.observe(node)
207208
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"demo"
1515
],
1616
"devDependencies": {
17-
"@biomejs/biome": "^1.8.3",
18-
"@types/react": "^18.3.3",
19-
"typescript": "^5.5.4",
20-
"zero-configuration": "^0.17.2"
17+
"@biomejs/biome": "^1.9.4",
18+
"@types/react": "^19.1.4",
19+
"typescript": "^5.8.3",
20+
"zero-configuration": "^0.19.0"
2121
},
2222
"peerDependencies": {
2323
"react": ">= 18",

types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { CSSProperties, JSX } from 'react'
1+
import type React from 'react'
22
import type { ArrowProps } from './arrow'
33

44
export type FadeDirection = 'top' | 'right' | 'bottom' | 'left'
55
export type ScrollDirection = 'horizontal' | 'vertical'
66

7-
export type Props<T extends keyof JSX.IntrinsicElements = 'div'> = JSX.IntrinsicElements[T] & {
7+
export type Props<T extends keyof React.JSX.IntrinsicElements = 'div'> = React.JSX.IntrinsicElements[T] & {
88
as?: T
99
direction?: ScrollDirection
1010
color?: string
11-
overflowStyle?: CSSProperties
12-
indicatorStyle?: CSSProperties
13-
fallbackStyle?: CSSProperties
11+
overflowStyle?: React.CSSProperties
12+
indicatorStyle?: React.CSSProperties
13+
fallbackStyle?: React.CSSProperties
1414
arrow?: ArrowProps | boolean
1515
}

0 commit comments

Comments
 (0)