Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add click event handler for title; add read full button in the footer… #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-chrono",
"name": "react-chrono-extra",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the package name is being changed

"version": "2.2.7",
"license": "MIT",
"description": "A Modern Timeline component for React",
Expand Down
6 changes: 4 additions & 2 deletions src/components/timeline-elements/memoized/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
const TitleMemo = ({
title,
url,
urlClassName,
theme,
color,
dir,
Expand All @@ -40,13 +41,14 @@ const TitleMemo = ({
$fontSize={fontSize}
data-class={classString}
$padding={padding}
onClick={typeof url === 'function' ? url : () => {}}
>
{url ? (
{typeof url === 'string' ? (
<CardTitleAnchor href={url} target="_blank" rel="noreferrer">
{title}
</CardTitleAnchor>
) : (
title
<span className={cls(url ? urlClassName : '')}>{title}</span>
)}
</CardTitle>
) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Title extends common {
padding?: boolean;
title?: string;
url?: string;
urlClassName?: string
}

export interface Content extends common {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
* @property {React.RefObject} progressRef - Ref to the progress bar.
* @property {boolean} isNested - Determines if component is nested.
* @property {boolean} isResuming - Determines if slideshow is resuming.
* @property {string | Function} url - Navigate user to URL
*
* @returns {JSX.Element} ContentFooter component.
*/
Expand All @@ -48,6 +49,7 @@ const ContentFooter: FunctionComponent<ContentFooterProps> = ({
progressRef,
isNested,
isResuming,
url
}) => {
const { mode, theme } = useContext(GlobalContext);

Expand All @@ -72,25 +74,39 @@ const ContentFooter: FunctionComponent<ContentFooterProps> = ({

return (
<>
{canShowMore ? (
<ShowMore
className="show-more"
onPointerDown={handleClick}
onKeyUp={(event) => {
if (event.key === 'Enter') {
onExpand();
}
}}
show={canShow ? 'true' : 'false'}
theme={theme}
tabIndex={0}
>
{<span>{showMore ? 'read less' : 'read more'}</span>}
<ChevronIconWrapper collapsed={showMore ? 'true' : 'false'}>
<ChevronIcon />
</ChevronIconWrapper>
</ShowMore>
) : null}
<div style={{ width: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<button
style={{ margin: '0 6px 6px 0', padding: '3px' }}
onClick={typeof url === 'function' ? url : () => {}}
>
<span
style={{ fontSize: '12px', color: 'rgb(0, 127, 255)' }}
>
read in full
</span>
</button>
{canShowMore ? (
<ShowMore
className="show-more"
onPointerDown={handleClick}
onKeyUp={(event) => {
if (event.key === 'Enter') {
onExpand();
}
}}
show={canShow ? 'true' : 'false'}
theme={theme}
tabIndex={0}
>
{<span>{showMore ? 'read less' : 'read more'}</span>}
<ChevronIconWrapper collapsed={showMore ? 'true' : 'false'}>
<ChevronIcon />
</ChevronIconWrapper>
</ShowMore>
) : null}
</div>
</div>

{showProgressBar && (
<SlideShowProgressBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { TimelineCardHeader } from './timeline-card-content.styles';
*
* @property {string} title - The title of the card.
* @property {string} url - The URL of the card.
* @property {string} urlClassName - Class applied to title, if url present
* @property {boolean} media - Indicates whether the card has media or not.
* @property {string} content - The main content of the card.
* @returns {JSX.Element} The ContentHeader component.
*/
const ContentHeader: FunctionComponent<ContentHeaderProps> = memo(
({ title, url, media, content }: ContentHeaderProps) => {
({ title, url, urlClassName, media, content }: ContentHeaderProps) => {
// Using context to get global values
const { fontSizes, classNames, theme } = useContext(GlobalContext);

Expand All @@ -29,6 +30,7 @@ const ContentHeader: FunctionComponent<ContentHeaderProps> = memo(
title={title}
theme={theme}
url={url}
urlClassName={urlClassName}
fontSize={fontSizes?.cardTitle}
classString={classNames?.cardTitle}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RefObject } from 'react';

export type ContentHeaderProps = Pick<
TimelineContentModel,
'theme' | 'url' | 'title' | 'media' | 'content'
'theme' | 'url' | 'title' | 'media' | 'content' | 'urlClassName'
>;

export type ContentFooterProps = {
Expand All @@ -22,4 +22,5 @@ export type ContentFooterProps = {
textContentIsLarge: boolean;
theme?: Theme;
triangleDir?: string;
url?: string
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const TimelineCardContent: React.FunctionComponent<TimelineContentModel> =
flip,
branchDir,
url,
urlClassName,
timelineContent,
items,
isNested,
Expand Down Expand Up @@ -375,6 +376,7 @@ const TimelineCardContent: React.FunctionComponent<TimelineContentModel> =
title={title}
theme={theme}
url={url}
urlClassName={urlClassName}
media={media}
content={content}
/>
Expand All @@ -394,6 +396,7 @@ const TimelineCardContent: React.FunctionComponent<TimelineContentModel> =
theme={theme}
title={title}
url={url}
urlClassName={urlClassName}
startWidth={startWidth}
detailsText={TextOrContent}
paused={paused}
Expand Down Expand Up @@ -444,6 +447,7 @@ const TimelineCardContent: React.FunctionComponent<TimelineContentModel> =
showMore={showMore}
isNested={isNested}
isResuming={isResuming}
url={url}
/>
)}
</TimelineItemContentWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const CardMedia: React.FunctionComponent<CardMediaModel> = ({
media,
slideshowActive,
url,
urlClassName,
detailsText,
showProgressBar,
remainInterval,
Expand Down Expand Up @@ -294,6 +295,7 @@ const CardMedia: React.FunctionComponent<CardMediaModel> = ({
theme={theme}
active={active}
url={url}
urlClassName={urlClassName}
fontSize={fontSizes?.cardTitle}
classString={classNames?.cardTitle}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/timeline-vertical/timeline-vertical-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
* @property {string} cardSubtitle - The subtitle of the card.
* @property {string} cardTitle - The title of the card.
* @property {string} url - The URL of the card.
* @property {string} urlClassName - Class applied to title, if title is url
* @property {string} className - The class name for the component.
* @property {React.ReactNode} contentDetailsChildren - The content details children nodes.
* @property {React.ReactNode} iconChild - The icon child nodes.
Expand Down Expand Up @@ -49,6 +50,7 @@ const VerticalItem: React.FunctionComponent<VerticalItemModel> = (
cardSubtitle,
cardTitle,
url,
urlClassName,
className,
contentDetailsChildren,
iconChild,
Expand Down Expand Up @@ -217,6 +219,7 @@ const VerticalItem: React.FunctionComponent<VerticalItemModel> = (
theme={theme}
title={cardTitle}
url={url}
urlClassName={urlClassName}
flip={flipLayout}
timelineContent={timelineContent}
items={items}
Expand Down
3 changes: 3 additions & 0 deletions src/models/TimelineContentModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ export type TimelineContentModel = {

// URL associated with the timeline item.
url?: string;

// Class applied to title, if title is URL
urlClassName: string
};
3 changes: 3 additions & 0 deletions src/models/TimelineMediaModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ export interface CardMediaModel {

// URL associated with the media.
url?: string;

// Class applied to title, if url is present
urlClassName?: string
}
2 changes: 1 addition & 1 deletion src/models/TimelineVerticalModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type VerticalModel = Pick<
| 'timelineContent'
| 'items'
| 'isNested'
> & { active?: boolean; className: string; id?: string };
> & { active?: boolean; className: string; id?: string, urlClassName?: string };

/**
* Represents the model for a vertical timeline point.
Expand Down