Skip to content

Commit 65d3ebc

Browse files
committed
feat: can add CSS class to gantt bar configuration
Bumped version, updated docs and README Fixes #74
1 parent 24df6fe commit 65d3ebc

File tree

7 files changed

+80
-70
lines changed

7 files changed

+80
-70
lines changed

README.md

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
# Vue Ganttastic
2+
23
<div style="display: flex; flex-direction: column; align-items:center;">
34
<img
45
src="https://user-images.githubusercontent.com/28678851/148047714-301f07df-4101-48b8-9e47-1f272b290e80.png"
56
style="margin: 10px;" height="150"
67
alt="Vue Ganttastic logo"
7-
/>
8+
/>
89

9-
<b>Vue Ganttastic</b> is a simple, interactive and highly customizable Gantt chart component for Vue 3.
10+
<b>Vue Ganttastic</b> is a simple, interactive and highly customizable Gantt chart component for Vue 3.
1011

1112
![image](https://user-images.githubusercontent.com/28678851/148191571-76bd8d61-4583-4538-8c59-cc2915494890.png)
1213

1314
</div>
1415

15-
1616
## Features
17+
1718
- **[Vue 3](https://v3.vuejs.org/) support**
18-
- **[TypeScript](https://www.typescriptlang.org/) support** *(ships with out of the box type declarations)*
19-
- **Interactivity** *(dynamic, movable and pushable bars)*
20-
- **Reactivity / Responsiveness** (*when changes occur, bars are repositioned accordingly*)
21-
- **Customization options** (*chart/bar styling, slots, event handlers etc.*)
19+
- **[TypeScript](https://www.typescriptlang.org/) support** _(ships with out of the box type declarations)_
20+
- **Interactivity** _(dynamic, movable and pushable bars)_
21+
- **Reactivity / Responsiveness** (_when changes occur, bars are repositioned accordingly_)
22+
- **Customization options** (_chart/bar styling, slots, event handlers etc._)
2223

23-
Using Vue 2? Check out [Vue-Ganttastic v1](https://github.com/zunnzunn/vue-ganttastic/tree/vue-ganttastic-v1).
24+
Using Vue 2? Check out [Vue-Ganttastic v1](https://github.com/zunnzunn/vue-ganttastic/tree/vue-ganttastic-v1).
2425

2526
## Quickstart
27+
2628
Install using
29+
2730
```
2831
npm install @infectoone/vue-ganttastic
2932
```
33+
3034
Then, initalize the plugin in the starting point of your app (most likely src/main.js):
35+
3136
```js
3237
import { createApp } from "vue"
3338
import App from "./App.vue"
@@ -40,6 +45,7 @@ createApp(App)
4045
```
4146

4247
This will globally register the components g-gantt-chart and g-gantt-row and you will be able to use those two components right away.
48+
4349
```html
4450
<template>
4551
<g-gantt-chart
@@ -49,76 +55,80 @@ This will globally register the components g-gantt-chart and g-gantt-row and you
4955
bar-start="myBeginDate"
5056
bar-end="myEndDate"
5157
>
52-
<g-gantt-row
53-
label="My row 1"
54-
:bars="row1BarList"
55-
/>
56-
<g-gantt-row
57-
label="My row 2"
58-
:bars="row2BarList"
59-
/>
58+
<g-gantt-row label="My row 1" :bars="row1BarList" />
59+
<g-gantt-row label="My row 2" :bars="row2BarList" />
6060
</g-gantt-chart>
6161
</template>
6262

6363
<script setup>
64-
65-
import { ref } from "vue"
66-
67-
const row1BarList = ref([
68-
{
69-
myBeginDate: "2021-07-13 13:00",
70-
myEndDate: "2021-07-13 19:00",
71-
ganttBarConfig: { // each bar must have a nested ganttBarConfig object ...
72-
id: "unique-id-1", // ... and a unique "id" property
73-
label: "Lorem ipsum dolor"
64+
import { ref } from "vue"
65+
66+
const row1BarList = ref([
67+
{
68+
myBeginDate: "2021-07-13 13:00",
69+
myEndDate: "2021-07-13 19:00",
70+
ganttBarConfig: {
71+
// each bar must have a nested ganttBarConfig object ...
72+
id: "unique-id-1", // ... and a unique "id" property
73+
label: "Lorem ipsum dolor"
74+
}
7475
}
75-
}
76-
])
77-
const row2BarList = ref([
78-
{
79-
myBeginDate: "2021-07-13 00:00",
80-
myEndDate: "2021-07-14 02:00",
81-
ganttBarConfig: {
82-
id: "another-unique-id-2",
83-
hasHandles: true,
84-
label: "Hey, look at me",
85-
style: { // arbitrary CSS styling for your bar
86-
background: "#e09b69",
87-
borderRadius: "20px",
88-
color: "black"
76+
])
77+
const row2BarList = ref([
78+
{
79+
myBeginDate: "2021-07-13 00:00",
80+
myEndDate: "2021-07-14 02:00",
81+
ganttBarConfig: {
82+
id: "another-unique-id-2",
83+
hasHandles: true,
84+
label: "Hey, look at me",
85+
style: {
86+
// arbitrary CSS styling for your bar
87+
background: "#e09b69",
88+
borderRadius: "20px",
89+
color: "black"
90+
},
91+
class: "foo" // you can also add CSS classes to your bars!
8992
}
9093
}
91-
}
92-
])
94+
])
9395
</script>
94-
9596
```
9697

9798
## Contributing
99+
98100
Clone the project, make some changes, test your changes out, create a pull request with a short summary of what changes you made. Contributing is warmly welcomed!
99101

100102
To test your changes out before creating a pull request, create a build:
103+
101104
```
102105
npm run build
103106
```
107+
104108
To test out the build, you should create a tarball using:
109+
105110
```
106111
npm pack
107112
```
113+
108114
Then, place the tarball in some other test project and install the package from the tarball by using:
115+
109116
```
110117
npm install <name_of_the_package>.tgz
111118
```
112119

113120
## Guide and Docs
114-
For further guides and references, check out the [official docs](https://zunnzunn.github.io/vue-ganttastic/getting-started.html).
121+
122+
For further guides and references, check out the [official docs](https://zunnzunn.github.io/vue-ganttastic/getting-started.html).
115123

116124
## About
125+
117126
**License** [MIT](https://choosealicense.com/licenses/mit/)
118127
**Author**: Marko Žunić, BSc
119-
[GitHub Repository](https://github.com/zunnzunn/vue-ganttastic)
128+
[GitHub Repository](https://github.com/zunnzunn/vue-ganttastic)
120129

121130
## Support the project!
131+
122132
In case you found the library useful, a little tip would be much appreciated!
123133

124134
<form action="https://www.paypal.com/donate" method="post" target="_top">
@@ -128,12 +138,12 @@ In case you found the library useful, a little tip would be much appreciated!
128138
</form>
129139

130140
BTC address:
131-
![image](https://user-images.githubusercontent.com/28678851/233090745-a0a6d8a4-6df6-4b82-ac0c-90e69551786e.png)
132-
141+
![image](https://user-images.githubusercontent.com/28678851/233090745-a0a6d8a4-6df6-4b82-ac0c-90e69551786e.png)
133142

134143
## Screenshots
144+
135145
![image](https://user-images.githubusercontent.com/28678851/148191571-76bd8d61-4583-4538-8c59-cc2915494890.png)
136146

137-
![image](https://user-images.githubusercontent.com/28678851/148191529-b50c0d17-bcc1-4a78-9d2c-ff2a36b03f52.png)
147+
![image](https://user-images.githubusercontent.com/28678851/148191529-b50c0d17-bcc1-4a78-9d2c-ff2a36b03f52.png)
138148

139149
![image](https://user-images.githubusercontent.com/28678851/148191757-a2520dce-aeed-43df-87b2-3a64e225f9e7.png)

docs/getting-started.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ You can add Vue Ganttastic to your project using <kbd>npm</kbd>:
66

77
```
88
npm install @infectoone/vue-ganttastic
9-
```
9+
```
10+
1011
Then, initalize the plugin in the starting point of your app (most likely `src/main.js`):
1112

1213
```javascript
@@ -24,7 +25,6 @@ This will globally register the components `g-gantt-chart` and `g-gantt-row` and
2425

2526
## Basic usage
2627

27-
2828
```vue
2929
<template>
3030
<g-gantt-chart
@@ -34,26 +34,20 @@ This will globally register the components `g-gantt-chart` and `g-gantt-row` and
3434
bar-start="myBeginDate"
3535
bar-end="myEndDate"
3636
>
37-
<g-gantt-row
38-
label="My row 1"
39-
:bars="row1BarList"
40-
/>
41-
<g-gantt-row
42-
label="My row 2"
43-
:bars="row2BarList"
44-
/>
37+
<g-gantt-row label="My row 1" :bars="row1BarList" />
38+
<g-gantt-row label="My row 2" :bars="row2BarList" />
4539
</g-gantt-chart>
4640
</template>
4741
4842
<script setup>
49-
5043
import { ref } from "vue"
5144
5245
const row1BarList = ref([
5346
{
5447
myBeginDate: "2021-07-13 13:00",
5548
myEndDate: "2021-07-13 19:00",
56-
ganttBarConfig: { // each bar must have a nested ganttBarConfig object ...
49+
ganttBarConfig: {
50+
// each bar must have a nested ganttBarConfig object ...
5751
id: "unique-id-1", // ... and a unique "id" property
5852
label: "Lorem ipsum dolor"
5953
}
@@ -67,7 +61,8 @@ const row2BarList = ref([
6761
id: "another-unique-id-2",
6862
hasHandles: true,
6963
label: "Hey, look at me",
70-
style: { // arbitrary CSS styling for your bar
64+
style: {
65+
// arbitrary CSS styling for your bar
7166
background: "#e09b69",
7267
borderRadius: "20px",
7368
color: "black"
@@ -77,6 +72,7 @@ const row2BarList = ref([
7772
])
7873
</script>
7974
```
75+
8076
The result shoud look like this:
8177
<g-gantt-chart chart-start="2021-07-12 12:00" chart-end="2021-07-14 12:00" precision="hour" width="100%" bar-start="myBeginDate" bar-end="myEndDate"> <g-gantt-row label="My row 1" :bars="row1BarList"/>
8278
<g-gantt-row label="My row 2" :bars="row2BarList"/>
@@ -104,12 +100,14 @@ const row2BarList = ref([
104100
id: "another-unique-id-2",
105101
hasHandles: true,
106102
label: "Hey, look at me",
107-
style: { // arbitrary CSS styling for your bar
103+
style: {
104+
// arbitrary CSS styling for your bar
108105
background: "#e09b69",
109106
borderRadius: "20px",
110107
color: "#000000"
111-
}
108+
},
109+
class: "foo" // you can also add CSS classes to your bars!
112110
}
113111
}
114112
])
115-
</script>
113+
</script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@infectoone/vue-ganttastic",
3-
"version": "2.1.4",
3+
"version": "2.2.0",
44
"description": "A simple and customizable Gantt chart component for Vue.js",
55
"author": "Marko Zunic (@infectoone)",
66
"scripts": {

src/color-schemes.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import type { Color } from "csstype"
1+
import type * as CSS from "csstype"
2+
3+
type Color = CSS.DataType.Color
24

35
export type ColorScheme = {
46
primary: Color
@@ -11,7 +13,7 @@ export type ColorScheme = {
1113
toast?: Color
1214
}
1315

14-
export const colorSchemes = {
16+
export const colorSchemes: Record<string, ColorScheme> = {
1517
default: {
1618
primary: "#eeeeee",
1719
secondary: "#E0E0E0",
@@ -123,7 +125,7 @@ export const colorSchemes = {
123125
text: "white",
124126
background: "white"
125127
}
126-
} as Record<string, ColorScheme>
128+
}
127129

128130
export type ColorSchemeKey = keyof typeof colorSchemes
129131

src/components/GGanttBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
:id="barConfig.id"
4-
class="g-gantt-bar"
4+
:class="['g-gantt-bar', barConfig.class || '']"
55
:style="{
66
...barConfig.style,
77
position: 'absolute',

src/composables/useBarDragManagement.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { GanttBarObject } from "../types"
22

3-
import { ref } from "vue"
43
import createBarDrag from "./createBarDrag.js"
54
import useDayjsHelper from "./useDayjsHelper.js"
65
import provideConfig from "../provider/provideConfig.js"

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export type GanttBarObject = {
1313
dragLimitLeft?: number
1414
dragLimitRight?: number
1515
style?: CSSProperties
16+
class?: string
1617
}
1718
}

0 commit comments

Comments
 (0)