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
16 changes: 7 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ import logo from './logo.svg';
import './App.css';
import { SplitScreen } from './SplitScreen/SplitScreen';

const LeftHandComponent = () => {
return <h1 style={{backgroundColor: 'green'}}>Left Component!</h1>;
const LeftHandComponent = ({name}) => {
return <h1 style={{backgroundColor: 'green'}}>{name}</h1>;
}

const RightHandComponent = () => {
return <p style={{backgroundColor: 'yellow'}}>Right Component!</p>
const RightHandComponent = ({message}) => {
return <p style={{backgroundColor: 'yellow'}}>{message}</p>
}

function App() {
return (
<SplitScreen left={LeftHandComponent}
right={RightHandComponent}
leftWeight={1}
rightWeight={3}>

<SplitScreen leftWeight={1} rightWeight={3}>
<LeftHandComponent name="Nadee Sansari"/>
<RightHandComponent message="Try your best"/>
</SplitScreen>
);
}
Expand Down
11 changes: 7 additions & 4 deletions src/SplitScreen/SplitScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ const Pane = styled.div`
`;

export const SplitScreen = ({
left: Left,
right: Right,
children,
leftWeight = 1,
rightWeight = 1
}) => {

const [left, right] = children;

return (

<Container>
<Pane weight={leftWeight}>
<Left />
{left}
</Pane>
<Pane weight={rightWeight}>
<Right />
{right}
</Pane>
</Container>
)
Expand Down