Skip to content

Commit

Permalink
incorporting the new toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuignoto committed Jan 31, 2024
1 parent fcf2dde commit 820b791
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 15 deletions.
16 changes: 13 additions & 3 deletions src/components/list/list.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,35 @@ export const ListStyle = styled.ul`
display: flex;
flex-direction: column;
align-items: center;
min-width: 300px;
`;

export const ListItemStyle = styled.li`
margin: 0;
padding: 1rem;
padding: 0.25rem;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 1rem;
width: 100%;
&:last-child {
margin-bottom: 0;
}
border-radius: 4px;
background: #f5f5f5;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.1);
&:hover {
cursor: pointer;
background-color: #f5f5f5;
}
`;

export const TitleStyle = styled.h1``;
export const TitleStyle = styled.h1`
margin: 0.2rem 0;
`;

export const TitleDescriptionStyle = styled.p``;
export const TitleDescriptionStyle = styled.p`
padding: 0.1rem;
margin: 0;
`;
4 changes: 2 additions & 2 deletions src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const ListItem: FunctionComponent<ListItemProps> = ({
}) => {
return (
<ListItemStyle key={id}>
<TitleStyle></TitleStyle>
<TitleDescriptionStyle></TitleDescriptionStyle>
<TitleStyle>{title}</TitleStyle>
<TitleDescriptionStyle>{description} </TitleDescriptionStyle>
</ListItemStyle>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const PopOver: FunctionComponent<PopOverModel> = ({
placeholder,
}) => {
const [open, setOpen] = useState(false);

const toggleOpen = () => setOpen(!open);

return (
Expand Down
7 changes: 7 additions & 0 deletions src/components/popover/popover.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export const PopoverWrapper = styled.div``;
export const PopoverHolder = styled.div<{ position: PopoverPosition }>`
position: absolute;
z-index: 100;
background: rgba(255, 255, 255, 1);
padding: 0.5rem;
box-shadow: 0px 5px 16px rgba(0, 0, 0, 0.2);
border-radius: 6px;
top: 3rem;
max-height: 300px;
overflow-y: auto;
`;

export const Selecter = styled.div`
Expand Down
107 changes: 107 additions & 0 deletions src/components/timeline/timeline-toolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { TimelineModel, TimelineProps } from '@models/TimelineModel';
import { FunctionComponent } from 'react';
import { List } from '../list/list';
import { PopOver } from '../popover';
import TimelineControl from '../timeline-elements/timeline-control/timeline-control';
import { Toolbar } from '../toolbar';

export type TimelineToolbarProps = Pick<
TimelineModel,
| 'activeTimelineItem'
| 'slideShowEnabled'
| 'slideShowRunning'
| 'onRestartSlideshow'
| 'onNext'
| 'onPrevious'
| 'onPaused'
| 'onFirst'
| 'onLast'
> & {
toggleDarkMode: () => void;
totalItems: number;
id: string;
} & Pick<TimelineProps, 'darkMode' | 'flipLayout'>;

const TimelineToolbar: FunctionComponent<TimelineToolbarProps> = ({
activeTimelineItem,
slideShowEnabled,
slideShowRunning,
darkMode,
flipLayout,
toggleDarkMode,
onPaused,
onFirst,
onLast,
onNext,
onPrevious,
onRestartSlideshow,
totalItems,
id,
}) => {
return (
<Toolbar
items={[
{
name: 'timeline_control',
label: 'Timeline Controls',
content: (
<TimelineControl
disableLeft={
flipLayout
? activeTimelineItem === totalItems - 1
: activeTimelineItem === 0
}
disableRight={
flipLayout
? activeTimelineItem === 0
: activeTimelineItem === totalItems - 1
}
id={id}
onFirst={onFirst}
onLast={onLast}
onNext={onNext}
onPrevious={onPrevious}
onReplay={onRestartSlideshow}
slideShowEnabled={slideShowEnabled}
slideShowRunning={slideShowRunning}
isDark={darkMode}
onToggleDarkMode={toggleDarkMode}
onPaused={onPaused}
/>
),
onSelect: () => {},
},
{
name: 'popover',
label: 'timeline_popover',
content: (
<PopOver placeholder="Select a item" position="down">
<List
items={[
{
id: '1',
title: 'test1',
description: 'test1',
},
{
id: '2',
title: 'test2',
description: 'test2',
},
{
id: '3',
title: 'test3',
description: 'test3',
},
]}
/>
</PopOver>
),
onSelect: () => {},
},
]}
/>
);
};

export { TimelineToolbar };
31 changes: 22 additions & 9 deletions src/components/timeline/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import React, {
import { GlobalContext } from '../GlobalContext';
import { useMatchMedia } from '../effects/useMatchMedia';
import useNewScrollPosition from '../effects/useNewScrollPosition';
import { List } from '../list/list';
import { PopOver } from '../popover';
import TimelineControl from '../timeline-elements/timeline-control/timeline-control';
import TimelineHorizontal from '../timeline-horizontal/timeline-horizontal';
import TimelineVertical from '../timeline-vertical/timeline-vertical';
import { Toolbar } from '../toolbar';
import { TimelineToolbar } from './timeline-toolbar';
import {
Outline,
TimelineContentRender,
Expand Down Expand Up @@ -364,11 +361,11 @@ const Timeline: React.FunctionComponent<TimelineModel> = (
}}
>
<ToolbarWrapper>
<Toolbar
{/* <Toolbar
items={[
{
name: 'test2',
label: 'test2',
name: 'timeline_control',
label: 'Timeline Controls',
content: (
<TimelineControl
disableLeft={
Expand Down Expand Up @@ -397,8 +394,8 @@ const Timeline: React.FunctionComponent<TimelineModel> = (
onSelect: () => {},
},
{
name: 'test',
label: 'test',
name: 'popover',
label: 'timeline_popover',
content: (
<PopOver placeholder="Select a item" position="down">
<List
Expand All @@ -425,6 +422,22 @@ const Timeline: React.FunctionComponent<TimelineModel> = (
onSelect: () => {},
},
]}
/> */}
<TimelineToolbar
activeTimelineItem={activeTimelineItem}
totalItems={items.length}
slideShowEnabled={slideShowEnabled}
slideShowRunning={slideShowRunning}
onFirst={handleFirst}
onLast={handleLast}
onNext={handleNext}
onPrevious={handlePrevious}
onRestartSlideshow={onRestartSlideshow}
darkMode={darkMode}
toggleDarkMode={toggleDarkMode}
onPaused={onPaused}
id={id.current}
flipLayout={flipLayout}
/>
</ToolbarWrapper>
<TimelineMainWrapper
Expand Down

0 comments on commit 820b791

Please sign in to comment.