Skip to content

Commit

Permalink
fix: refactor the ScrollProps type for maintainability and readability (
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaic4o committed Apr 2, 2024
1 parent 5410889 commit 7607bb0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/web/ScrollControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,19 @@ const ScrollHtml: ForwardRefComponent<{ children?: React.ReactNode; style?: Reac
}
)

type ScrollProps =
| { children?: React.ReactNode } & (
| {
html?: false
style?: never
}
| { html: true; style?: React.CSSProperties }
)
interface ScrollPropsWithFalseHtml {
children?: React.ReactNode
html?: false
style?: never
}

interface ScrollPropsWithTrueHtml {
children?: React.ReactNode
html: true
style?: React.CSSProperties
}

type ScrollProps = ScrollPropsWithFalseHtml | ScrollPropsWithTrueHtml

export const Scroll: ForwardRefComponent<ScrollProps, THREE.Group & HTMLDivElement> = /* @__PURE__ */ React.forwardRef(
({ html, ...props }: ScrollProps, ref) => {
Expand Down

0 comments on commit 7607bb0

Please sign in to comment.