Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
karolkozer committed May 7, 2022
2 parents 00befd8 + c231019 commit ebdc300
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 12 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,37 @@ const ChannelItem = ({ channel }: ChannelItemProps) => {
</ChannelBox>
);
};


function App() {

...

const {
getEpgProps,
getLayoutProps,
} = useEpg({
epg,
channels,
startDate: '2022/02/02', // or 2022-02-02T00:00:00
});

return (
<div>
<div style={{ height: '600px', width: '1200px' }}>
<Epg {...getEpgProps()}>
<Layout
{...getLayoutProps()}
renderChannel={({ channel }) => (
<ChannelItem key={channel.uuid} channel={channel} />
)}
/>
</Epg>
</div>
</div>
);
}

```
## renderTimeline
Expand All @@ -436,6 +467,7 @@ import {
TimelineWrapper,
TimelineBox,
TimelineTime,
TimelineDivider,
TimelineDividers,
useTimeline,
} from 'planby';
Expand Down Expand Up @@ -488,6 +520,35 @@ export function Timeline({
</TimelineWrapper>
);
}

function App() {

...

const {
getEpgProps,
getLayoutProps,
} = useEpg({
epg,
channels,
startDate: '2022/02/02', // or 2022-02-02T00:00:00
});

return (
<div>
<div style={{ height: '600px', width: '1200px' }}>
<Epg {...getEpgProps()}>
<Layout
{...getLayoutProps()}
renderTimeline={(props) => <Timeline {...props} />}
/>
</Epg>
</div>
</div>
);
}

export default App;
```
## Theme
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "planby",
"author": "Karol Kozer",
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
21 changes: 10 additions & 11 deletions src/Epg/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from "react";

// Import types
import {
Expand All @@ -8,23 +8,25 @@ import {
DateTime,
Position,
BaseTimeFormat,
} from '../helpers/types';
} from "../helpers/types";

// Import helpers
import { getProgramOptions, isFutureTime } from '../helpers';
import { getProgramOptions, isFutureTime } from "../helpers";

// Import styles
import { EpgStyled, TimelineStyled } from '../styles';
import { EpgStyled } from "../styles";

// Import components
import { Timeline, Channels, Program, Line } from '../components';
import { Timeline, Channels, Program, Line } from "../components";

interface RenderTimeline {
sidebarWidth: number;
hourWidth: number;
numberOfHoursInDay: number;
offsetStartHoursRange: number;
isBaseTimeFormat: BaseTimeFormat;
isSidebar: boolean;
dayWidth: number;
}

interface LayoutProps {
Expand All @@ -47,7 +49,7 @@ interface LayoutProps {
isTimeline?: boolean;
isLine?: boolean;
isProgramVisible: (position: Position) => boolean;
isChannelVisible: (position: Pick<Position, 'top'>) => boolean;
isChannelVisible: (position: Pick<Position, "top">) => boolean;
renderProgram?: (v: {
program: ProgramItem;
isBaseTimeFormat: BaseTimeFormat;
Expand All @@ -57,7 +59,6 @@ interface LayoutProps {
}

const { ScrollBox, Content } = EpgStyled;
const { TimelineWrapper } = TimelineStyled;

export const Layout = React.forwardRef<HTMLDivElement, LayoutProps>(
(props, scrollBoxRef) => {
Expand Down Expand Up @@ -123,9 +124,7 @@ export const Layout = React.forwardRef<HTMLDivElement, LayoutProps>(
hourWidth,
};
if (renderTimeline) {
<TimelineWrapper {...props}>
{renderTimeline?.({ sidebarWidth, ...timeProps })}
</TimelineWrapper>;
return renderTimeline({ ...timeProps, ...props });
}
return <Timeline {...timeProps} {...props} />;
};
Expand Down Expand Up @@ -160,7 +159,7 @@ export const Layout = React.forwardRef<HTMLDivElement, LayoutProps>(
width={dayWidth}
height={contentHeight}
>
{programs.map(program =>
{programs.map((program) =>
renderPrograms(program as ProgramWithPosition)
)}
</Content>
Expand Down
2 changes: 2 additions & 0 deletions src/Epg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const {
TimelineWrapper,
TimelineBox,
TimelineTime,
TimelineDivider,
TimelineDividers,
} = TimelineStyled;

Expand All @@ -59,4 +60,5 @@ export {
TimelineBox,
TimelineTime,
TimelineDividers,
TimelineDivider,
};

0 comments on commit ebdc300

Please sign in to comment.