Skip to content

FIX: #142 #143

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 30, 2024
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
9 changes: 8 additions & 1 deletion nextjs-demo/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Head from "next/head";
import { useState } from "react";
import * as Space from "react-spaces";

export default function Home() {
const [lsize, setLSize] = useState("10%"); // To check for the hover effect
return (
<>
<Space.SSR />
Expand All @@ -12,7 +14,12 @@ export default function Home() {
<link rel="icon" href="/favicon.ico" />
</Head>
<Space.ViewPort>
<Space.LeftResizable size="25%" centerContent={Space.CenterType.HorizontalVertical} style={{ backgroundColor: "white" }}>
<Space.LeftResizable
size={lsize}
onMouseEnter={() => setLSize("25%")}
onMouseLeave={() => setLSize("10%")}
centerContent={Space.CenterType.HorizontalVertical}
style={{ backgroundColor: "white", transition: "all 0.3s ease-in-out" }}>
<span style={{ color: "black" }}>Hello world</span>
</Space.LeftResizable>
<Space.RightResizable size="25%" centerContent={Space.CenterType.HorizontalVertical} style={{ backgroundColor: "white" }}>
Expand Down
8 changes: 5 additions & 3 deletions src/components/Space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
}

const {
style,
innerComponentStyle,
className,
onClick,
onDoubleClick,
Expand All @@ -55,6 +55,7 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
onTouchEnd,
children,
handleRender,
style,
} = props;

const events = {
Expand Down Expand Up @@ -103,10 +104,10 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =

const innerClasses = [...["spaces-space-inner"], ...userClasses];

let innerStyle = style;
let innerStyle = innerComponentStyle;
if (space.handlePlacement === ResizeHandlePlacement.Inside) {
innerStyle = {
...style,
...innerStyle,
...{
left: space.anchor === AnchorType.Right ? space.handleSize : undefined,
right: space.anchor === AnchorType.Left ? space.handleSize : undefined,
Expand All @@ -125,6 +126,7 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
className: outerClasses.join(" "),
},
...events,
style,
} as any;

return (
Expand Down
3 changes: 2 additions & 1 deletion src/core-react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ export interface IReactEvents {
}

export interface IReactSpaceCommonProps extends ICommonProps, IReactEvents {
style?: React.CSSProperties;
innerComponentStyle?: React.CSSProperties; // For people who like to modify the inner `as` component
as?: keyof React.ReactDOM | React.ComponentType<ICommonProps>;
children?: React.ReactNode;
style?: React.CSSProperties; // Normal styles for the wrapper itself as it is the main component that is resized
}

export interface IReactSpaceInnerProps extends IReactSpaceCommonProps, ISpaceProps, IReactEvents {
Expand Down