Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ContentFooter: FunctionComponent<ContentFooterProps> = ({
isNested,
isResuming,
}: ContentFooterProps) => {
const { mode, theme } = useContext(GlobalContext);
const { mode, theme, showMoreText } = useContext(GlobalContext);

const canShowTriangleIcon = useMemo(() => {
return (
Expand Down Expand Up @@ -95,7 +95,17 @@ const ContentFooter: FunctionComponent<ContentFooterProps> = ({
theme={theme}
tabIndex={0}
>
{<span>{showMore ? 'read less' : 'read more'}</span>}
{
<span>
{showMore
? showMoreText
? showMoreText.expand
: 'read less'
: showMoreText
? showMoreText.collapse
: 'read more'}
</span>
}
<ChevronIconWrapper collapsed={showMore ? 'true' : 'false'}>
<ChevronIcon />
</ChevronIconWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline-horizontal/timeline-horizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const TimelineHorizontal: React.FunctionComponent<TimelineHorizontalModel> = ({
onElapsed={onElapsed}
customContent={children ? (children as ReactNode[])[index] : null}
hasFocus={hasFocus}
iconChild={iconChildColln[index]}
iconChild={item.icon || iconChildColln[index]}
active={item.active}
cardWidth={cardWidth}
isNested={isNested}
Expand Down
12 changes: 7 additions & 5 deletions src/components/timeline-vertical/timeline-vertical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ const TimelineVertical: React.FunctionComponent<TimelineVerticalModel> = ({
(contentDetailsChildren as React.ReactNode[])[index]) ||
null;

const customIcon = Array.isArray(iconChildren)
? iconChildren[index]
: index === 0
? iconChildren
: null;
const customIcon = item.icon
? item.icon
: Array.isArray(iconChildren)
? iconChildren[index]
: index === 0
? iconChildren
: null;

return (
<TimelineVerticalItem
Expand Down
2 changes: 2 additions & 0 deletions src/demo/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const NewDemo: React.FunctionComponent = () => {
timelineContent,
date,
items,
icon,
}) => ({
title,
url,
Expand All @@ -80,6 +81,7 @@ const NewDemo: React.FunctionComponent = () => {
timelineContent,
date,
items,
icon,
}),
);
setItems(newItems);
Expand Down
6 changes: 6 additions & 0 deletions src/demo/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const items: TimelineItemModel[] = [
</ul>
`,
],
icon: (
<img
src="https://img.icons8.com/ios-filled/100/000000/twitter.png"
alt="github"
/>
),
},
{
title: '25 July 1941',
Expand Down
1 change: 1 addition & 0 deletions src/demo/vertical-samples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export const VerticalCustomContent2: FunctionComponent<{
flipLayout
timelinePointDimension={30}
items={items}
showMoreText={{ expand: 'Expand', collapse: 'Collapse' }}
>
<div>
<div style={{ width: '250px', height: '250px' }}>
Expand Down
4 changes: 4 additions & 0 deletions src/models/TimelineItemModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export interface TimelineItemModel {

// Indicates if the timeline item is visible.
visible?: boolean;

// Optional prop for timeline icon.
icon?: ReactNode;
}

/**
Expand All @@ -74,6 +77,7 @@ export type TimelineCardModel = Pick<
| 'timelineContent'
| 'isNested'
| 'items'
| 'icon'
> & {
// Function for auto-scrolling.
autoScroll?: ({
Expand Down
6 changes: 6 additions & 0 deletions src/models/TimelineModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type TimelineModel = Pick<
| 'nestedCardHeight'
| 'noUniqueId'
| 'uniqueId'
| 'showMoreText'
> & {
activeTimelineItem?: number;
contentDetailsChildren?: React.ReactNode | React.ReactNode[];
Expand Down Expand Up @@ -243,6 +244,11 @@ export type TimelineProps = {

// enables the read more button
useReadMore?: boolean;

showMoreText?: {
expand?: string;
collapse?: string;
}
};

export type SlideShowType = 'reveal' | 'slide_in' | 'slide_from_sides';
Expand Down