Skip to content

Commit

Permalink
New release: 4.3.0 (#62)
Browse files Browse the repository at this point in the history
* fix: when the container component has only one content component

* fix: modify unit tests

* chore: change version

* chore: some changes to PR request file

* fix: publish github action

* Create new release (#61)

* breacking change(rename): components

* chore: update tests

* change: today text to active

* add(events): optional subtitle prop

* fix(test): optional subtitle prop

* add(event): description symbol

* improve(a11y): change div and p elements to ul and li

* chore(tests): improve test and coverage

* add(events-event): allow render closed some event componentes inside events componente

* chore: order alphabetically asc all imports and attributes

* chore(package): change version

* fix(tests): improve coverage

* add(template): config template

* add(template): features requests

* add(pull-request-template): add issue section

* chore(documentation): change content

* fix(test): update snapshots

* chore(template): some changes in pull_request_template file
  • Loading branch information
Proskynete committed Dec 26, 2022
1 parent e48d0ee commit 078c033
Show file tree
Hide file tree
Showing 65 changed files with 633 additions and 474 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 0,
'no-underscore-dangle': 0,
'@typescript-eslint/naming-convention': 0,
'jest/expect-expect': 0,
},
};
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contact_links:
- name: Ask the community
url: https://github.com/Proskynete/vertical-timeline-component-react/discussions/new
about: Ask and discuss questions with other members of the community.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Feature request
description: Suggest new or updated features to include the library.
title: 'Suggest a new feature'
labels: [feature]
assignees: []
body:
- type: checkboxes
attributes:
label: Prerequisites
description: Please take a couple of minutes to help me work faster.
options:
- label: I have [searched](https://github.com/Proskynete/vertical-timeline-component-react/issues?q=is%3Aissue) for duplicate or closed feature requests
required: true
- label: I have read the [contributing guidelines](https://github.com/Proskynete/vertical-timeline-component-react/blob/master/CONTRIBUTING.md)
required: true
- type: textarea
id: proposal
attributes:
label: Proposal
description: Please provide detailed information on what we should add.
validations:
required: true
- type: textarea
id: motivation
attributes:
label: Motivation and context
description: Tell us why this change is needed or helpful, and what problems it may help solve.
validations:
required: true
7 changes: 3 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)
## 🎯 Issues

Write here the list of issues that the PR is solving

## 👾 Type of change

Expand All @@ -18,9 +20,6 @@ Please delete options that are not relevant.

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

## ✅ Checklist

- [ ] My code follows the style guidelines of this project
Expand Down
142 changes: 71 additions & 71 deletions README.md

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions lib/cjs/components/container/index.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions lib/cjs/components/content/index.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/cjs/components/error-message/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interface ErrorMessageProps {
type: 'atLeast' | 'onlySupports';
component: string;
type: 'atLeast' | 'onlySupports';
}
declare const ErrorMessage: ({ type, component }: ErrorMessageProps) => JSX.Element;
export { ErrorMessage };
3 changes: 3 additions & 0 deletions lib/cjs/components/event/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ContentProps } from '../../interfaces';
declare const Event: ({ collapse, defaultClosed, description, title }: ContentProps) => JSX.Element;
export { Event };
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Content = void 0;
exports.Event = void 0;
var react_1 = __importStar(require("react"));
var useConfig_1 = require("../../hooks/useConfig");
var main_1 = require("../../styles/main");
var Content = function (_a) {
var Event = function (_a) {
var _b;
var title = _a.title, description = _a.description, collapse = _a.collapse;
var collapse = _a.collapse, defaultClosed = _a.defaultClosed, description = _a.description, title = _a.title;
var config = (0, useConfig_1.useConfig)().config;
var _c = (0, react_1.useState)(true), show = _c[0], setShow = _c[1];
var _c = (0, react_1.useState)(!defaultClosed), show = _c[0], setShow = _c[1];
var isCollapsed = collapse || config.collapse;
var handleSetShow = function () {
setShow(!show);
Expand All @@ -45,7 +45,7 @@ var Content = function (_a) {
title),
show && (react_1.default.createElement(main_1.DescriptionWrapper, null, description.map(function (text, i) {
var _a;
return (react_1.default.createElement(main_1.Description, { key: i, style: (_a = config.customStyles) === null || _a === void 0 ? void 0 : _a.description }, text));
return (react_1.default.createElement(main_1.Description, { key: i, symbol: config.descriptionSymbol, style: (_a = config.customStyles) === null || _a === void 0 ? void 0 : _a.description }, text));
})))));
};
exports.Content = Content;
exports.Event = Event;
4 changes: 4 additions & 0 deletions lib/cjs/components/events/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PropsWithChildren } from 'react';
import { EventsProps } from '../../interfaces';
declare const Events: ({ active, children, defaultClosed, endDate, startDate, subtitle, title, withoutDay, }: PropsWithChildren<EventsProps>) => JSX.Element;
export { Events };
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
exports.Events = void 0;
var react_1 = __importDefault(require("react"));
var useConfig_1 = require("../../hooks/useConfig");
var main_1 = require("../../styles/main");
var content_1 = require("../content");
var event_1 = require("../event");
var validate_1 = require("../validate");
var year_content_1 = __importDefault(require("../year-content"));
var Container = function (_a) {
var _b;
var title = _a.title, startDate = _a.startDate, endDate = _a.endDate, today = _a.today, withoutDay = _a.withoutDay, children = _a.children;
var Events = function (_a) {
var _b, _c;
var active = _a.active, children = _a.children, _d = _a.defaultClosed, defaultClosed = _d === void 0 ? false : _d, endDate = _a.endDate, startDate = _a.startDate, subtitle = _a.subtitle, title = _a.title, withoutDay = _a.withoutDay;
var config = (0, useConfig_1.useConfig)().config;
return (react_1.default.createElement(main_1.ContainerWrapper, null,
react_1.default.createElement(year_content_1.default, { startDate: startDate, endDate: endDate, today: today, withoutDay: withoutDay }),
react_1.default.createElement(year_content_1.default, { startDate: startDate, endDate: endDate, active: active, withoutDay: withoutDay }),
react_1.default.createElement(main_1.BodyWrapper, null,
react_1.default.createElement(main_1.Title, { style: (_b = config.customStyles) === null || _b === void 0 ? void 0 : _b.title }, title),
subtitle && react_1.default.createElement(main_1.Subtitle, { style: (_c = config.customStyles) === null || _c === void 0 ? void 0 : _c.subtitle }, subtitle),
react_1.default.createElement(main_1.BodyInner, null,
react_1.default.createElement(validate_1.Validate, { componentToValidate: content_1.Content }, children)))));
react_1.default.createElement(validate_1.Validate, { componentToValidate: event_1.Event, defaultClosed: defaultClosed }, children)))));
};
exports.Container = Container;
exports.Events = Events;
2 changes: 1 addition & 1 deletion lib/cjs/components/timeline/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from 'react';
import { TimelineProps } from '../../interfaces';
declare const Timeline: ({ theme, lang, dateFormat, collapse, withoutDay, customStyles, children, }: PropsWithChildren<TimelineProps>) => JSX.Element;
declare const Timeline: ({ children, collapse, customStyles, dateFormat, descriptionSymbol, lang, theme, withoutDay, }: PropsWithChildren<TimelineProps>) => JSX.Element;
export { Timeline };
16 changes: 12 additions & 4 deletions lib/cjs/components/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ var styled_components_1 = require("styled-components");
var config_1 = require("../../config");
var config_context_1 = require("../../context/config.context");
var main_1 = require("../../styles/main");
var container_1 = require("../container");
var events_1 = require("../events");
var validate_1 = require("../validate");
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, _d = _a.dateFormat, dateFormat = _d === void 0 ? config_1.defaultValues.dateFormat : _d, _e = _a.collapse, collapse = _e === void 0 ? config_1.defaultValues.collapse : _e, _f = _a.withoutDay, withoutDay = _f === void 0 ? config_1.defaultValues.withoutDay : _f, customStyles = _a.customStyles, children = _a.children;
var children = _a.children, _b = _a.collapse, collapse = _b === void 0 ? config_1.defaultValues.collapse : _b, customStyles = _a.customStyles, _c = _a.dateFormat, dateFormat = _c === void 0 ? config_1.defaultValues.dateFormat : _c, _d = _a.descriptionSymbol, descriptionSymbol = _d === void 0 ? config_1.defaultValues.descriptionSymbol : _d, _e = _a.lang, lang = _e === void 0 ? config_1.defaultValues.lang : _e, _f = _a.theme, theme = _f === void 0 ? config_1.defaultValues.theme : _f, _g = _a.withoutDay, withoutDay = _g === void 0 ? config_1.defaultValues.withoutDay : _g;
return (react_1.default.createElement(main_1.TimelineWrapper, null,
react_1.default.createElement(main_1.TimelineWrapperInner, null,
react_1.default.createElement(config_context_1.ConfigProvider, { config: { theme: theme, lang: lang, dateFormat: dateFormat, collapse: collapse, customStyles: customStyles, withoutDay: withoutDay } },
react_1.default.createElement(config_context_1.ConfigProvider, { config: {
theme: theme,
lang: lang,
dateFormat: dateFormat,
collapse: collapse,
customStyles: customStyles,
descriptionSymbol: descriptionSymbol,
withoutDay: withoutDay,
} },
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme },
react_1.default.createElement(validate_1.Validate, { componentToValidate: container_1.Container }, children))))));
react_1.default.createElement(validate_1.Validate, { componentToValidate: events_1.Events }, children))))));
};
exports.Timeline = Timeline;
12 changes: 7 additions & 5 deletions lib/cjs/components/validate/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { JSXElementConstructor, PropsWithChildren } from 'react';
interface ValidateProps {
componentToValidate: JSXElementConstructor<any>;
}
declare const Validate: ({ children, componentToValidate }: PropsWithChildren<ValidateProps>) => JSX.Element;
import React, { PropsWithChildren } from 'react';
declare type ValidateProps = {
componentToValidate: React.JSXElementConstructor<any>;
} & {
[key: string]: any;
};
declare const Validate: ({ children, componentToValidate, ...otherProps }: PropsWithChildren<ValidateProps>) => JSX.Element;
export { Validate };
45 changes: 18 additions & 27 deletions lib/cjs/components/validate/index.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validate = void 0;
var react_1 = __importStar(require("react"));
var react_1 = __importDefault(require("react"));
var error_message_1 = require("../error-message");
var Validate = function (_a) {
var children = _a.children, componentToValidate = _a.componentToValidate;
var count = children && react_1.Children.count(children);
var children = _a.children, componentToValidate = _a.componentToValidate, otherProps = __rest(_a, ["children", "componentToValidate"]);
var count = children && react_1.default.Children.count(children);
if (count === 0 || !children)
return react_1.default.createElement(error_message_1.ErrorMessage, { type: "atLeast", component: componentToValidate.name });
var elements = react_1.Children.map(children, function (element) {
return element.type === componentToValidate ? (element) : (react_1.default.createElement(error_message_1.ErrorMessage, { type: "onlySupports", component: componentToValidate.name }));
var elements = react_1.default.Children.map(children, function (element) {
return element.type === componentToValidate ? (react_1.default.cloneElement(element, otherProps)) : (react_1.default.createElement(error_message_1.ErrorMessage, { type: "onlySupports", component: componentToValidate.name }));
});
return react_1.default.createElement(react_1.default.Fragment, null, elements);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/cjs/components/year-content/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { YearContentProps } from '../../interfaces';
declare const YearContent: ({ startDate, endDate, today, withoutDay }: YearContentProps) => JSX.Element;
declare const YearContent: ({ active, endDate, startDate, withoutDay }: YearContentProps) => JSX.Element;
export default YearContent;
7 changes: 3 additions & 4 deletions lib/cjs/components/year-content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var text_helper_1 = require("../../helpers/text.helper");
var useConfig_1 = require("../../hooks/useConfig");
var YearContent = function (_a) {
var _b;
var startDate = _a.startDate, endDate = _a.endDate, _c = _a.today, today = _c === void 0 ? false : _c, withoutDay = _a.withoutDay;
var _c = _a.active, active = _c === void 0 ? false : _c, endDate = _a.endDate, startDate = _a.startDate, withoutDay = _a.withoutDay;
var config = (0, useConfig_1.useConfig)().config;
var _today = today && (react_1.default.createElement("time", { "aria-hidden": true, dateTime: (0, transform_date_helper_1.getAccessibilityDate)({
var _active = active && (react_1.default.createElement("time", { "aria-hidden": true, dateTime: (0, transform_date_helper_1.getAccessibilityDate)({
date: new Date(),
lang: config.lang,
withoutDay: config.withoutDay || withoutDay,
Expand Down Expand Up @@ -55,10 +55,9 @@ var YearContent = function (_a) {
type: 'full',
withoutDay: config.withoutDay || withoutDay,
}),
today: today,
lang: config.lang,
}), style: (_b = config.customStyles) === null || _b === void 0 ? void 0 : _b.date },
_today,
_active,
_endDate,
_startDate));
};
Expand Down
6 changes: 3 additions & 3 deletions lib/cjs/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { DefaultTimelineProps } from '../interfaces';
export declare const defaultValues: DefaultTimelineProps;
export declare const mapText: {
en: {
de: {
from: string;
to: string;
};
es: {
en: {
from: string;
to: string;
};
de: {
es: {
from: string;
to: string;
};
Expand Down
20 changes: 11 additions & 9 deletions lib/cjs/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapText = exports.defaultValues = void 0;
exports.defaultValues = {
collapse: false,
dateFormat: 'only-number',
descriptionSymbol: '•',
lang: 'en',
theme: {
yearColor: '#888888',
lineColor: '#c5c5c5',
dotColor: '#c5c5c5',
borderDotColor: '#ffffff',
descriptionColor: '#cccccc',
dotColor: '#c5c5c5',
eventColor: '#cccccc',
lineColor: '#c5c5c5',
subtitleColor: '#c5c5c5',
titleColor: '#cccccc',
subtitleColor: '#888888',
textColor: '#cccccc',
yearColor: '#888888',
},
lang: 'en',
dateFormat: 'only-number',
collapse: false,
withoutDay: false,
};
exports.mapText = {
de: { from: 'Von', to: 'Bis' },
en: { from: 'From', to: 'To' },
es: { from: 'Desde', to: 'Hasta' },
de: { from: 'Von', to: 'Bis' },
tr: { from: 'Başlangıç', to: 'Bitiş' },
zh: { from: '从', to: '到' },
};
3 changes: 1 addition & 2 deletions lib/cjs/helpers/text.helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Languages } from '../interfaces';
export declare const clearString: (str: string) => string;
export interface GetAriaTextParams {
from: string;
to: string;
today: boolean;
lang: Languages;
to: string;
}
export declare const getAriaText: ({ from, to, lang }: GetAriaTextParams) => string;
10 changes: 5 additions & 5 deletions lib/cjs/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Event } from './components/event';
import { Events } from './components/events';
import { DateFormat, Languages, Theme, TimelineProps } from './interfaces';
import { Timeline } from './components/timeline';
import { Container } from './components/container';
import { Content } from './components/content';
import { Theme, DateFormat, Languages, TimelineProps } from './interfaces';
export { Timeline, Container, Content };
export type { Theme, DateFormat, Languages, TimelineProps };
export { Timeline, Events, Event };
export type { DateFormat, Languages, Theme, TimelineProps };
10 changes: 5 additions & 5 deletions lib/cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Content = exports.Container = exports.Timeline = void 0;
exports.Event = exports.Events = exports.Timeline = void 0;
var event_1 = require("./components/event");
Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return event_1.Event; } });
var events_1 = require("./components/events");
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return events_1.Events; } });
var timeline_1 = require("./components/timeline");
Object.defineProperty(exports, "Timeline", { enumerable: true, get: function () { return timeline_1.Timeline; } });
var container_1 = require("./components/container");
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
var content_1 = require("./components/content");
Object.defineProperty(exports, "Content", { enumerable: true, get: function () { return content_1.Content; } });
Loading

0 comments on commit 078c033

Please sign in to comment.