Skip to content

Commit c328cd1

Browse files
committed
chore: prepare for major release
1 parent b134a32 commit c328cd1

File tree

6 files changed

+112
-12
lines changed

6 files changed

+112
-12
lines changed

.eslintrc.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
"plugin:react-hooks/recommended",
88
"plugin:storybook/recommended",
99
],
10-
ignorePatterns: ["dist", ".eslintrc.cjs"],
10+
ignorePatterns: ["dist", ".eslintrc.cjs", "build"],
1111
parser: "@typescript-eslint/parser",
1212
plugins: ["react-refresh"],
1313
rules: {

.github/workflows/npm-publish.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: Publish package
66
on:
77
release:
88
types: [created]
9+
workflow_dispatch:
910

1011
jobs:
1112
build:

.pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ci:
22
skip:
33
- prettier
4+
- eslint
45
repos:
56
- repo: https://github.com/pre-commit/mirrors-prettier
67
rev: v3.1.0
@@ -9,3 +10,10 @@ repos:
910
additional_dependencies:
1011
- prettier@latest
1112
- prettier-plugin-organize-imports@latest
13+
- repo: local
14+
hooks:
15+
- id: eslint
16+
name: Lint with eslint
17+
pass_filenames: false
18+
language: system
19+
entry: pnpm lint

README.md

+99-8
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,109 @@
22

33
A simple but customizable resource scheduler/timeline built with mantine
44

5-
Compatibility:
6-
This library uses subgrids, which are a brand new feature in browsers (most released a supporting version in July 2024), for creating its layout.
7-
Read here about its browser compatibility: https://caniuse.com/css-subgrid
5+
## Compatibility:
86

9-
It uses the following peer dependencies:
7+
This library uses subgrids, which is a rather new browser feature.
8+
9+
## Peer dependencies
1010

1111
- `@mantine/hooks` for @mantine/core
1212
- `@mantine/core` for styling
1313
- `dayjs` for handling of dates
14-
- `@tanstack/react-virtual` for virtualization
14+
- `@tanstack/react-virtual` for virtualization of bigger timelines
15+
- `valtio` for more granular render control
16+
- `@use-gesture/react` for panning and zoom gestures when holding CTRL
17+
18+
## Minimal usage
19+
20+
```tsx
21+
import { type Dayjs } from "dayjs";
22+
import { useSchedulerController, Scheduler } from "mantine-resource-timeline";
23+
24+
interface MyDataType {
25+
id: string | number;
26+
resourceId: string | number | number[] | string[];
27+
startDate: Date;
28+
endDate: Date;
29+
}
30+
31+
interface MyResourceType {
32+
id: string | number;
33+
name: string;
34+
}
35+
36+
const data: MyDataType[] = [
37+
{
38+
id: "appointment-1",
39+
title: "Bob & Alice Meet",
40+
resourceId: [1, 2],
41+
startDate: Dayjs,
42+
endDate: Dayjs,
43+
},
44+
];
45+
46+
const resources: MyResourceType[] = [
47+
{
48+
id: 1,
49+
name: "Bob",
50+
},
51+
{
52+
id: 2,
53+
name: "Alice",
54+
},
55+
];
56+
57+
function MyTimeline() {
58+
const controller = useSchedulerController<MyDataType, MyResourceType>({});
59+
60+
return (
61+
<Scheduler
62+
controller={controller}
63+
data={data}
64+
resources={resources}
65+
width="100%"
66+
height="95vh"
67+
dataResourceIdAccessor="resourceId"
68+
endDateAccessor="endDate"
69+
startDateAccessor="startDate"
70+
dataIdAccessor="id"
71+
resourceIdAccessor="id"
72+
tz="Europe/Berlin"
73+
/>
74+
);
75+
}
76+
```
77+
78+
For how to activate other features of this library and adapting the timeline component to your needs take a look at the [Advanced Example](https://github.com/jvllmr/mantine-resource-timeline/blob/dev/stories/Advanced.stories.tsx).
79+
80+
The controller object allows us to control multiple components state, such as the time to be displayed, from the outside. It's a valtio proxy object which allows us to pass it around in our app without having to fear unnecessary re-renders. Take a look at [valtio's documentation](https://valtio.dev/docs/introduction/getting-started) to find out how a valtio proxy object is handled correctly.
81+
82+
## Future development
83+
84+
I have mostly achieved what I initially wanted to achieve with this component library. This means I most likely won't re-iterate on it because I have lost mostly lost my interest in this project.
85+
I'm still eager to answer questions via issues or review Pull Requests to this project though. Feel free to contribute anything you'd like as long as it's within the scope of this project. Especially if it includes documentation/tests.
86+
87+
## Contributing
88+
89+
To develop code for this project you need pnpm. If you don't use pnpm already, you can follow their [installation guide](https://pnpm.io/installation) to install it. I personally recommend installation via corepack.
90+
91+
After that you can install dependencies via:
92+
93+
```shell
94+
pnpm install
95+
```
96+
97+
Next you should be able to start the storybook server via:
98+
99+
```shell
100+
pnpm storybook
101+
```
102+
103+
Then you can open the storybook via http://127.0.0.1:6006.
15104

16-
Roadmap:
105+
Before committing and pushing you should format and lint the project via the following commands:
17106

18-
- More examples and minimal documentation in Storybook
19-
- Tests, tests, tests
107+
```shell
108+
pnpm format
109+
pnpm lint
110+
```

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mantine-resource-timeline",
33
"description": "A resource timeline component built with Mantine",
44
"private": false,
5-
"version": "0.2.0",
5+
"version": "7.0.0",
66
"type": "module",
77
"repository": {
88
"url": "git+https://github.com/jvllmr/mantine-resource-timeline.git",
@@ -22,7 +22,8 @@
2222
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
2323
"preview": "vite preview",
2424
"storybook": "storybook dev -p 6006",
25-
"build-storybook": "storybook build"
25+
"build-storybook": "storybook build",
26+
"format": "prettier -w ."
2627
},
2728
"files": [
2829
"build",

src/controller/controller.ts

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ function clipStartViewDate(date: Dayjs, displayUnit: SchedulerDisplayUnit) {
104104
}
105105
}
106106

107-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
108107
function calculateDisplayUnit(
109108
// eslint-disable-next-line @typescript-eslint/no-explicit-any
110109
controller: SchedulerController<any, any>,

0 commit comments

Comments
 (0)