GH 3365 Add contributors page on twenty-website (#3745)

* add transition in mobile navbar

* add contributors listing page

* Add breadcrumb component

* Add profilecard component

* Make profile info dynamic

* Style activity log component

* Make title a re-usable component

* Make card container re-usable

* add rank and active days logic

* complete single contributor page

* add styles for mobile

* Add github link

* Reset header desktop

* update calendar height

* remove conditional header

* add GH PR link

* display 10 prs

* Remove employees and fix rank

* Unrelated CSS adjustment

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
Deepak Kumar
2024-02-05 18:26:12 +05:30
committed by GitHub
parent 33bb48e681
commit 8dda4b0b8f
20 changed files with 749 additions and 127 deletions

View File

@ -0,0 +1,32 @@
import { differenceInDays, formatDistance } from 'date-fns';
const formatIntoRelativeDate = (dateString: string) => {
if (!dateString) return '';
const inputDate = new Date(dateString);
const currentDate = new Date();
const daysDifference = differenceInDays(currentDate, inputDate);
let formattedDate = '';
if (daysDifference === 0) {
formattedDate = 'today';
} else if (daysDifference === 1) {
formattedDate = 'yesterday';
} else if (daysDifference < 7) {
formattedDate = formatDistance(inputDate, currentDate, { addSuffix: true });
} else if (daysDifference < 14) {
formattedDate = 'last week';
} else if (daysDifference < 30) {
formattedDate = Math.floor(daysDifference / 7) + ' weeks ago';
} else if (daysDifference < 60) {
formattedDate = 'last month';
} else if (daysDifference < 365) {
formattedDate = Math.floor(daysDifference / 30) + ' months';
} else if (daysDifference < 730) {
formattedDate = 'last year';
} else {
formattedDate = Math.floor(daysDifference / 365) + ' years ago';
}
return formattedDate;
};
export { formatIntoRelativeDate };