Skip to content

Commit c85225c

Browse files
authored
Merge pull request #941 from 4Efficiency-Services/master
2 parents f6ffe8f + d7c062b commit c85225c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1109
-236
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Huge update made by @Remco4EF and @remcoblumink
1414
* Updates dependencies to latest versions
1515
* Updates react usage to 18+
1616
* REMOVED enzyme for tests --> testing does not work atm
17-
17+
* Added option to drag from external element to the timeline
18+
* Added nextjs15 demo to test #939 and removed bundled stylesheet (added somewhere in 0.30.0 reworks...)
1819

1920
## 0.28.0
2021

demo-next/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

demo-next/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# env files (can opt-in for committing if needed)
33+
.env*
34+
35+
# vercel
36+
.vercel
37+
38+
# typescript
39+
*.tsbuildinfo
40+
next-env.d.ts

demo-next/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

demo-next/next.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { NextConfig } from "next";
2+
import path from 'node:path'
3+
import { resolve } from 'path'
4+
5+
const nextConfig: NextConfig = {
6+
/* config options here */
7+
webpack: (config, { isServer }) => {
8+
config.resolve.alias = {
9+
...config.resolve.alias,
10+
'react-calendar-timeline/dist/Timeline.scss': resolve(__dirname, '../src/lib/Timeline.scss'),
11+
'react-calendar-timeline/style.css': resolve(__dirname, '../dist/style.css'),
12+
'react-calendar-timeline': resolve(__dirname, '../src/index.ts'),
13+
}
14+
return config
15+
}
16+
}
17+
export default nextConfig;

demo-next/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "demo-next",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"next": "15.0.3",
13+
"randomcolor": "^0.6.2",
14+
"react": "19.0.0-rc-66855b96-20241106",
15+
"react-calendar-timeline": "file:../dist/",
16+
"react-dom": "19.0.0-rc-66855b96-20241106"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^20",
20+
"@types/randomcolor": "^0.5.9",
21+
"@types/react": "^18",
22+
"@types/react-dom": "^18",
23+
"eslint": "^8",
24+
"eslint-config-next": "15.0.3",
25+
"typescript": "^5"
26+
}
27+
}

demo-next/public/file.svg

Lines changed: 1 addition & 0 deletions
Loading

demo-next/public/globe.svg

Lines changed: 1 addition & 0 deletions
Loading

demo-next/public/next.svg

Lines changed: 1 addition & 0 deletions
Loading

demo-next/public/vercel.svg

Lines changed: 1 addition & 0 deletions
Loading

demo-next/public/window.svg

Lines changed: 1 addition & 0 deletions
Loading

demo-next/src/app/favicon.ico

25.3 KB
Binary file not shown.
66.3 KB
Binary file not shown.

demo-next/src/app/fonts/GeistVF.woff

64.7 KB
Binary file not shown.

demo-next/src/app/layout.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Metadata } from "next";
2+
3+
export const metadata: Metadata = {
4+
title: "React-calendar-timeline with Create Next App",
5+
description: "Generated by create next app",
6+
};
7+
8+
export default function RootLayout({
9+
children,
10+
}: Readonly<{
11+
children: React.ReactNode;
12+
}>) {
13+
return (
14+
<html lang="en">
15+
<body>
16+
{children}
17+
</body>
18+
</html>
19+
);
20+
}

demo-next/src/app/page.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
import dynamic from 'next/dynamic'
4+
//Either use default stylesheet
5+
import "react-calendar-timeline/style.css"
6+
//Or create your own...
7+
//import '@/components/Timeline.scss'
8+
const MyTimeline = dynamic(()=>import ('@/components/My-Timeline'),{loading:()=><p>asdsda</p>})
9+
export default function Home() {
10+
return (
11+
<div >
12+
<main >
13+
<MyTimeline/>
14+
</main>
15+
16+
</div>
17+
);
18+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use client'
2+
3+
import { CursorMarker, Timeline, TimelineMarkers, TodayMarker } from 'react-calendar-timeline'
4+
import dayjs from 'dayjs'
5+
import generateFakeData, { FakeDataItem, FakeGroup } from '@/components/generate-fake-data'
6+
import { useEffect, useState } from 'react'
7+
8+
9+
const MyTimeline = () => {
10+
var minTime = dayjs().add(-6, 'months').hour(0).minute(0).second(0).millisecond(0).valueOf()
11+
var maxTime = dayjs().add(6, 'months').hour(0).minute(0).second(0).millisecond(0).valueOf()
12+
const [init, setInit] = useState<boolean>(false)
13+
const [groups, setGroups] = useState<FakeGroup[]>([])
14+
const [items, setItems] = useState<FakeDataItem[]>([])
15+
useEffect(() => {
16+
const { groups: gr, items: fakeItems } = generateFakeData(15, 100)
17+
setItems(fakeItems.splice(0, Math.floor(fakeItems.length / 2)))
18+
19+
setGroups(gr)
20+
setInit(true)
21+
}, [])
22+
23+
return (init ?
24+
<>
25+
<Timeline groups={groups} items={items} visibleTimeStart={minTime} visibleTimeEnd={maxTime}>
26+
<TimelineMarkers>
27+
<TodayMarker />
28+
<CursorMarker/>
29+
</TimelineMarkers>
30+
</Timeline>
31+
</> : 'please wait...'
32+
)
33+
}
34+
35+
36+
export default MyTimeline
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@use 'react-calendar-timeline/dist/Timeline.scss' as * with (
2+
$sidebar-background-color: #2196f3,
3+
//$weekend:#29b31a
4+
) ;
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import {faker} from '@faker-js/faker'
2+
import randomColor from 'randomcolor'
3+
import dayjs from 'dayjs'
4+
import {HTMLProps} from "react";
5+
import {TimelineGroupBase, TimelineItemBase} from "react-calendar-timeline";
6+
7+
export type FakeGroup = TimelineGroupBase & {
8+
id:string;
9+
label: string
10+
bgColor: string
11+
}
12+
export type FakeDataItem = TimelineItemBase<number> & {
13+
id: number
14+
group: string
15+
title: string
16+
start_time: number
17+
end_time: number
18+
canMove?: boolean
19+
canResize?: false | 'left' | 'right' | 'both'
20+
className?: string
21+
bgColor?:string,
22+
selectedBgColor?:string
23+
color?:string
24+
itemProps?: HTMLProps<HTMLDivElement>
25+
}
26+
export default function (groupCount = 30, itemCount = 1000, daysInPast = 30) {
27+
let randomSeed = Math.floor(Math.random() * 1000)
28+
let groups :FakeGroup[]= []
29+
for (let i = 0; i < groupCount; i++) {
30+
groups.push({
31+
id:`${i + 1}`,
32+
title: faker.person.firstName(),
33+
rightTitle: faker.person.lastName(),
34+
label: `Label ${faker.person.firstName()}`,
35+
bgColor: randomColor({luminosity: 'light', seed: randomSeed + i}),
36+
})
37+
}
38+
39+
let items:FakeDataItem[] = []
40+
for (let i = 0; i < itemCount; i++) {
41+
const startDate =
42+
faker.date.recent({days: daysInPast}).valueOf() +
43+
daysInPast * 0.3 * 86400 * 1000
44+
const startValue =
45+
Math.floor(dayjs(startDate).valueOf() / 10000000) * 10000000
46+
const endValue = dayjs(
47+
startDate + faker.number.int({min: 2, max: 20}) * 15 * 60 * 1000,
48+
).valueOf()
49+
50+
const itemProps: HTMLProps<HTMLDivElement> = { style: {} }
51+
// @ts-ignore
52+
itemProps['data-tip']= faker.hacker.phrase();
53+
items.push({
54+
id: i,
55+
group: faker.number.int({min: 1, max: groups.length}) + '',
56+
title: faker.hacker.phrase(),
57+
start_time: startValue,
58+
end_time: endValue,
59+
canMove: startValue > new Date().getTime(),
60+
canResize:
61+
startValue > new Date().getTime()
62+
? endValue > new Date().getTime()
63+
? 'both'
64+
: 'left'
65+
: endValue > new Date().getTime()
66+
? 'right'
67+
: false,
68+
className:
69+
dayjs(startDate).day() === 6 || dayjs(startDate).day() === 0
70+
? 'item-weekend'
71+
: '',
72+
bgColor: randomColor({
73+
luminosity: 'light',
74+
seed: randomSeed + i,
75+
format: 'rgba',
76+
alpha: 0.6,
77+
}),
78+
selectedBgColor: randomColor({
79+
luminosity: 'light',
80+
seed: randomSeed + i,
81+
format: 'rgba',
82+
alpha: 1,
83+
}),
84+
color: randomColor({luminosity: 'dark', seed: randomSeed + i}),
85+
// itemProps:itemProps
86+
87+
})
88+
}
89+
90+
items = items.sort((a, b) => b.start_time - a.start_time)
91+
92+
return {groups, items}
93+
}

demo-next/tsconfig.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2017",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"noEmit": true,
9+
"esModuleInterop": true,
10+
"module": "esnext",
11+
"moduleResolution": "bundler",
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"jsx": "preserve",
15+
"incremental": true,
16+
"plugins": [
17+
{
18+
"name": "next"
19+
}
20+
],
21+
"paths": {
22+
"@/*": ["./src/*"]
23+
}
24+
},
25+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26+
"exclude": ["node_modules"]
27+
}

demo/README.md

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
# React + TypeScript + Vite
1+
# React-Calendar-timeline Vite
22

3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4-
5-
Currently, two official plugins are available:
6-
7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9-
10-
## Expanding the ESLint configuration
11-
12-
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13-
14-
- Configure the top-level `parserOptions` property like this:
15-
16-
```js
17-
export default {
18-
// other rules...
19-
parserOptions: {
20-
ecmaVersion: 'latest',
21-
sourceType: 'module',
22-
project: ['./tsconfig.json', './tsconfig.node.json'],
23-
tsconfigRootDir: __dirname,
24-
},
25-
}
26-
```
27-
28-
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29-
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30-
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
3+
These demos give some examples of how to use the library with Vite.

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
88

9-
<title>Vite + React + TS</title>
9+
<title>React-Calendar-Timeline Demo's</title>
1010
</head>
1111
<body>
1212
<div id="root"></div>

0 commit comments

Comments
 (0)