Skip to content

Commit

Permalink
fix: change licence document to MIT and return interfaces from main r…
Browse files Browse the repository at this point in the history
…oute
  • Loading branch information
Proskynete committed Aug 15, 2022
1 parent a2c0f1b commit a336cc4
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 741 deletions.
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions lib/cjs/components/timeline/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { PropsWithChildren } from 'react';
import { DateFormat, Theme } from '../../interfaces';
interface TimelineProps {
theme?: Theme;
lang?: string;
dateFormat?: DateFormat;
}
declare const Timeline: ({ theme, lang, children, dateFormat, }: PropsWithChildren<TimelineProps>) => JSX.Element;
import { TimelineProps } from '../../interfaces';
declare const Timeline: ({ theme, lang, dateFormat, children, }: PropsWithChildren<TimelineProps>) => JSX.Element;
export default Timeline;
2 changes: 1 addition & 1 deletion lib/cjs/components/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var config_1 = require("../../config");
var config_context_1 = require("../../context/config.context");
var main_1 = require("../../styles/main");
var Timeline = function (_a) {
var _b = _a.theme, theme = _b === void 0 ? config_1.defaultValues.theme : _b, _c = _a.lang, lang = _c === void 0 ? config_1.defaultValues.lang : _c, children = _a.children, _d = _a.dateFormat, dateFormat = _d === void 0 ? config_1.defaultValues.dateFormat : _d;
var _b = _a.theme, theme = _b === void 0 ? config_1.defaultValues.theme : _b, _c = _a.lang, lang = _c === void 0 ? config_1.defaultValues.lang : _c, _d = _a.dateFormat, dateFormat = _d === void 0 ? config_1.defaultValues.dateFormat : _d, children = _a.children;
return (react_1.default.createElement(main_1.TimelineWrapper, null,
react_1.default.createElement(main_1.TimelineWrapperInner, null,
react_1.default.createElement(config_context_1.ConfigContext.Provider, { value: { lang: lang, dateFormat: dateFormat } },
Expand Down
10 changes: 4 additions & 6 deletions lib/cjs/components/year-content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ var config_context_1 = require("../../context/config.context");
var config_1 = require("../../config");
var main_1 = require("../../styles/main");
var transform_date_helper_1 = require("../../helpers/transform-date.helper");
var text_helper_1 = require("../../helpers/text.helper");
var YearContent = function (_a) {
var startDate = _a.startDate, endDate = _a.endDate, _b = _a.currentYear, currentYear = _b === void 0 ? false : _b;
var _c = (0, react_1.useContext)(config_context_1.ConfigContext), lang = _c.lang, dateFormat = _c.dateFormat;
var _lang = (0, text_helper_1.clearString)(lang).split(' ')[0];
var d = new Date();
var _year = d.getFullYear();
var _currentYear = currentYear && (react_1.default.createElement("time", { dateTime: _year.toString() }, _year));
var _endDate = endDate && (react_1.default.createElement(react_1.default.Fragment, null,
react_1.default.createElement(main_1.YearSpan, null, config_1.mapText[_lang].to),
react_1.default.createElement("time", { dateTime: endDate }, (0, transform_date_helper_1.transformDate)({ date: endDate, lang: _lang, type: dateFormat }))));
react_1.default.createElement(main_1.YearSpan, null, config_1.mapText[lang].to),
react_1.default.createElement("time", { dateTime: endDate }, (0, transform_date_helper_1.transformDate)({ date: endDate, lang: lang, type: dateFormat }))));
var _startDate = (react_1.default.createElement(react_1.default.Fragment, null,
react_1.default.createElement(main_1.YearSpan, null, config_1.mapText[_lang].from),
react_1.default.createElement("time", { dateTime: startDate }, (0, transform_date_helper_1.transformDate)({ date: startDate, lang: _lang, type: dateFormat }))));
react_1.default.createElement(main_1.YearSpan, null, config_1.mapText[lang].from),
react_1.default.createElement("time", { dateTime: startDate }, (0, transform_date_helper_1.transformDate)({ date: startDate, lang: lang, type: dateFormat }))));
return (react_1.default.createElement(main_1.YearWrapper, { format: dateFormat, lang: lang },
_currentYear,
_endDate,
Expand Down
4 changes: 2 additions & 2 deletions lib/cjs/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultValues } from '../interfaces';
export declare const defaultValues: DefaultValues;
import { DefaultTimelineProps } from '../interfaces';
export declare const defaultValues: DefaultTimelineProps;
export declare const mapText: {
en: {
from: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/cjs/context/config.context.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { DefaultValues } from '../interfaces';
export declare const ConfigContext: import("react").Context<DefaultValues>;
import { DefaultTimelineProps } from '../interfaces';
export declare const ConfigContext: import("react").Context<DefaultTimelineProps>;
4 changes: 2 additions & 2 deletions lib/cjs/helpers/transform-date.helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DateFormat } from '../interfaces';
import { DateFormat, LangAllowed } from '../interfaces';
interface ITransformDate {
date: string;
lang: string;
lang: LangAllowed;
type: DateFormat;
}
export declare const transformDate: ({ date, lang, type }: ITransformDate) => string;
Expand Down
2 changes: 2 additions & 0 deletions lib/cjs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import YearContent from './components/year-content';
import BodyContent from './components/body-content';
import Section from './components/section';
import Description from './components/description';
import { Theme, DateFormat, LangAllowed, TimelineProps } from './interfaces';
export { Timeline, Container, YearContent, BodyContent, Section, Description };
export type { Theme, DateFormat, LangAllowed, TimelineProps };
10 changes: 8 additions & 2 deletions lib/cjs/interfaces/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ export interface Theme {
textColor: string;
}
export declare type DateFormat = 'only-number' | 'short' | 'with-weekday' | 'full';
export interface DefaultValues {
export declare type LangAllowed = 'en' | 'es' | 'de' | 'tr' | 'zh';
export interface TimelineProps {
theme?: Theme;
lang: string;
lang?: LangAllowed;
dateFormat?: DateFormat;
}
export interface DefaultTimelineProps {
theme?: Theme;
lang: LangAllowed;
dateFormat: DateFormat;
}
9 changes: 2 additions & 7 deletions lib/esm/components/timeline/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { PropsWithChildren } from 'react';
import { DateFormat, Theme } from '../../interfaces';
interface TimelineProps {
theme?: Theme;
lang?: string;
dateFormat?: DateFormat;
}
declare const Timeline: ({ theme, lang, children, dateFormat, }: PropsWithChildren<TimelineProps>) => JSX.Element;
import { TimelineProps } from '../../interfaces';
declare const Timeline: ({ theme, lang, dateFormat, children, }: PropsWithChildren<TimelineProps>) => JSX.Element;
export default Timeline;
2 changes: 1 addition & 1 deletion lib/esm/components/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defaultValues } from '../../config';
import { ConfigContext } from '../../context/config.context';
import { TimelineWrapper, TimelineWrapperInner } from '../../styles/main';
var Timeline = function (_a) {
var _b = _a.theme, theme = _b === void 0 ? defaultValues.theme : _b, _c = _a.lang, lang = _c === void 0 ? defaultValues.lang : _c, children = _a.children, _d = _a.dateFormat, dateFormat = _d === void 0 ? defaultValues.dateFormat : _d;
var _b = _a.theme, theme = _b === void 0 ? defaultValues.theme : _b, _c = _a.lang, lang = _c === void 0 ? defaultValues.lang : _c, _d = _a.dateFormat, dateFormat = _d === void 0 ? defaultValues.dateFormat : _d, children = _a.children;
return (React.createElement(TimelineWrapper, null,
React.createElement(TimelineWrapperInner, null,
React.createElement(ConfigContext.Provider, { value: { lang: lang, dateFormat: dateFormat } },
Expand Down
10 changes: 4 additions & 6 deletions lib/esm/components/year-content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import { ConfigContext } from '../../context/config.context';
import { mapText } from '../../config';
import { YearWrapper, YearSpan } from '../../styles/main';
import { transformDate } from '../../helpers/transform-date.helper';
import { clearString } from '../../helpers/text.helper';
var YearContent = function (_a) {
var startDate = _a.startDate, endDate = _a.endDate, _b = _a.currentYear, currentYear = _b === void 0 ? false : _b;
var _c = useContext(ConfigContext), lang = _c.lang, dateFormat = _c.dateFormat;
var _lang = clearString(lang).split(' ')[0];
var d = new Date();
var _year = d.getFullYear();
var _currentYear = currentYear && (React.createElement("time", { dateTime: _year.toString() }, _year));
var _endDate = endDate && (React.createElement(React.Fragment, null,
React.createElement(YearSpan, null, mapText[_lang].to),
React.createElement("time", { dateTime: endDate }, transformDate({ date: endDate, lang: _lang, type: dateFormat }))));
React.createElement(YearSpan, null, mapText[lang].to),
React.createElement("time", { dateTime: endDate }, transformDate({ date: endDate, lang: lang, type: dateFormat }))));
var _startDate = (React.createElement(React.Fragment, null,
React.createElement(YearSpan, null, mapText[_lang].from),
React.createElement("time", { dateTime: startDate }, transformDate({ date: startDate, lang: _lang, type: dateFormat }))));
React.createElement(YearSpan, null, mapText[lang].from),
React.createElement("time", { dateTime: startDate }, transformDate({ date: startDate, lang: lang, type: dateFormat }))));
return (React.createElement(YearWrapper, { format: dateFormat, lang: lang },
_currentYear,
_endDate,
Expand Down
4 changes: 2 additions & 2 deletions lib/esm/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefaultValues } from '../interfaces';
export declare const defaultValues: DefaultValues;
import { DefaultTimelineProps } from '../interfaces';
export declare const defaultValues: DefaultTimelineProps;
export declare const mapText: {
en: {
from: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/esm/context/config.context.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { DefaultValues } from '../interfaces';
export declare const ConfigContext: import("react").Context<DefaultValues>;
import { DefaultTimelineProps } from '../interfaces';
export declare const ConfigContext: import("react").Context<DefaultTimelineProps>;
4 changes: 2 additions & 2 deletions lib/esm/helpers/transform-date.helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DateFormat } from '../interfaces';
import { DateFormat, LangAllowed } from '../interfaces';
interface ITransformDate {
date: string;
lang: string;
lang: LangAllowed;
type: DateFormat;
}
export declare const transformDate: ({ date, lang, type }: ITransformDate) => string;
Expand Down
2 changes: 2 additions & 0 deletions lib/esm/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import YearContent from './components/year-content';
import BodyContent from './components/body-content';
import Section from './components/section';
import Description from './components/description';
import { Theme, DateFormat, LangAllowed, TimelineProps } from './interfaces';
export { Timeline, Container, YearContent, BodyContent, Section, Description };
export type { Theme, DateFormat, LangAllowed, TimelineProps };
10 changes: 8 additions & 2 deletions lib/esm/interfaces/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ export interface Theme {
textColor: string;
}
export declare type DateFormat = 'only-number' | 'short' | 'with-weekday' | 'full';
export interface DefaultValues {
export declare type LangAllowed = 'en' | 'es' | 'de' | 'tr' | 'zh';
export interface TimelineProps {
theme?: Theme;
lang: string;
lang?: LangAllowed;
dateFormat?: DateFormat;
}
export interface DefaultTimelineProps {
theme?: Theme;
lang: LangAllowed;
dateFormat: DateFormat;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vertical-timeline-component-react",
"version": "3.0.3",
"version": "3.0.4",
"description": "A simple component for create a vertical timeline with React",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
10 changes: 2 additions & 8 deletions src/components/timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@ import React, { PropsWithChildren } from 'react';
import { ThemeProvider } from 'styled-components';
import { defaultValues } from '../../config';
import { ConfigContext } from '../../context/config.context';
import { DateFormat, Theme } from '../../interfaces';
import { TimelineProps } from '../../interfaces';
import { TimelineWrapper, TimelineWrapperInner } from '../../styles/main';

interface TimelineProps {
theme?: Theme;
lang?: string;
dateFormat?: DateFormat;
}

const Timeline = ({
theme = defaultValues.theme,
lang = defaultValues.lang,
children,
dateFormat = defaultValues.dateFormat,
children,
}: PropsWithChildren<TimelineProps>) => {
return (
<TimelineWrapper>
Expand Down
10 changes: 4 additions & 6 deletions src/components/year-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ConfigContext } from '../../context/config.context';
import { mapText } from '../../config';
import { YearWrapper, YearSpan } from '../../styles/main';
import { transformDate } from '../../helpers/transform-date.helper';
import { clearString } from '../../helpers/text.helper';

interface YearContentProps {
startDate: string;
Expand All @@ -17,7 +16,6 @@ const YearContent = ({
currentYear = false,
}: PropsWithChildren<YearContentProps>) => {
const { lang, dateFormat } = useContext(ConfigContext);
const _lang = clearString(lang).split(' ')[0];

const d = new Date();
const _year = d.getFullYear();
Expand All @@ -28,18 +26,18 @@ const YearContent = ({

const _endDate = endDate && (
<>
<YearSpan>{mapText[_lang].to}</YearSpan>
<YearSpan>{mapText[lang].to}</YearSpan>
<time dateTime={endDate}>
{transformDate({ date: endDate, lang: _lang, type: dateFormat })}
{transformDate({ date: endDate, lang: lang, type: dateFormat })}
</time>
</>
);

const _startDate = (
<>
<YearSpan>{mapText[_lang].from}</YearSpan>
<YearSpan>{mapText[lang].from}</YearSpan>
<time dateTime={startDate}>
{transformDate({ date: startDate, lang: _lang, type: dateFormat })}
{transformDate({ date: startDate, lang: lang, type: dateFormat })}
</time>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DefaultValues } from '../interfaces';
import { DefaultTimelineProps } from '../interfaces';

export const defaultValues: DefaultValues = {
export const defaultValues: DefaultTimelineProps = {
theme: {
yearColor: '#888',
lineColor: '#c5c5c5',
Expand Down
4 changes: 2 additions & 2 deletions src/context/config.context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from 'react';
import { defaultValues } from '../config';
import { DefaultValues } from '../interfaces';
import { DefaultTimelineProps } from '../interfaces';

export const ConfigContext = createContext<DefaultValues>(defaultValues);
export const ConfigContext = createContext<DefaultTimelineProps>(defaultValues);
4 changes: 2 additions & 2 deletions src/helpers/transform-date.helper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DateFormat } from '../interfaces';
import { DateFormat, LangAllowed } from '../interfaces';

interface ITransformDate {
date: string;
lang: string;
lang: LangAllowed;
type: DateFormat;
}

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import YearContent from './components/year-content';
import BodyContent from './components/body-content';
import Section from './components/section';
import Description from './components/description';
import { Theme, DateFormat, LangAllowed, TimelineProps } from './interfaces';

export { Timeline, Container, YearContent, BodyContent, Section, Description };
export type { Theme, DateFormat, LangAllowed, TimelineProps };
12 changes: 10 additions & 2 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ export interface Theme {

export type DateFormat = 'only-number' | 'short' | 'with-weekday' | 'full';

export interface DefaultValues {
export type LangAllowed = 'en' | 'es' | 'de' | 'tr' | 'zh';

export interface TimelineProps {
theme?: Theme;
lang?: LangAllowed;
dateFormat?: DateFormat;
}

export interface DefaultTimelineProps {
theme?: Theme;
lang: string;
lang: LangAllowed;
dateFormat: DateFormat;
}

0 comments on commit a336cc4

Please sign in to comment.