chore: build

This commit is contained in:
Safwan Samsudeen 2024-04-20 11:54:03 +05:30
parent 0e6e0154b4
commit ab9ecf753f
7 changed files with 157 additions and 112 deletions

97
dist/frappe-gantt.css vendored
View File

@ -81,9 +81,6 @@
.gantt .grid-row {
fill: #ffffff;
}
.gantt .grid-row:nth-child(even) {
fill: #f5f5f5;
}
.gantt .row-line {
stroke: #ebeff2;
}
@ -104,7 +101,7 @@
opacity: 0.5;
}
.gantt .holiday-highlight {
fill: #EEE;
fill: #f3f4f7;
opacity: 0.5;
}
.gantt .month-highlight {
@ -120,73 +117,96 @@
stroke: #666;
stroke-width: 1.4;
}
.gantt .bar {
fill: #b8c2cc;
stroke: #8d99a6;
.gantt .bar-wrapper .bar {
fill: #fff;
stroke: #fff;
stroke-width: 0;
transition: stroke-width 0.3s ease;
}
.gantt .bar-progress {
fill: #acacfa;
fill: #dedfe0;
}
.gantt .date-highlight {
fill: #e8e8e8;
display: none;
}
.gantt .bar-expected-progress {
fill: #c4c4e9;
}
.gantt .bar-invalid {
fill: transparent;
stroke: #8d99a6;
stroke: #fff;
stroke-width: 1;
stroke-dasharray: 5;
}
.gantt .bar-invalid ~ .bar-label {
fill: #555;
fill: #fff;
}
.gantt .bar-label {
fill: #fff;
fill: #333;
dominant-baseline: central;
font-size: 12px;
font-weight: 500;
font-family: Helvetica;
font-size: 14px;
font-weight: 400;
}
.gantt .bar-label.big {
fill: #555;
fill: #333;
text-anchor: start;
}
.gantt .bar-wrapper.important .bar {
fill: #94c4f4;
}
.gantt .bar-wrapper.important .bar-progress {
fill: #2c94ec;
}
.gantt .bar-wrapper.important .bar-label {
fill: #fff;
}
.gantt .bar-wrapper.important .handle {
fill: #94c4f4;
}
.gantt .handle {
fill: #ddd;
fill: #dcdce4;
cursor: ew-resize;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease;
}
.gantt .bar-wrapper {
cursor: pointer;
outline: none;
}
.gantt .bar-wrapper:hover .bar {
fill: #a9b5c1;
}
.gantt .bar-wrapper:hover .bar-progress {
fill: #9494f9;
}
.gantt .bar-wrapper:hover .handle {
.gantt:hover .handle {
visibility: visible;
opacity: 1;
}
.gantt .bar-wrapper.active .bar {
fill: #a9b5c1;
.gantt .bar-wrapper {
cursor: pointer;
}
.gantt .bar-wrapper.active .bar-progress {
fill: #9494f9;
.gantt .bar-wrapper .bar {
outline: groove 1px black;
border-radius: 3px;
}
.gantt .bar-wrapper.important .bar {
outline: none;
outline-width: 1.5px;
}
.gantt .bar-wrapper.important .bar:active {
outline: 1px dotted;
}
.gantt .bar-wrapper:hover .bar {
outline-width: 1.5px;
transition: transform 0.3s ease;
}
.gantt .bar-wrapper:hover .date-highlight {
display: block;
}
.gantt .bar-wrapper.active .bar {
outline-style: dotted;
}
.gantt .lower-text,
.gantt .upper-text {
font-size: 12px;
font-size: 14px;
text-anchor: middle;
}
.gantt .lower-text,
.gantt .upper-text {
fill: #555;
}
.gantt .lower-text {
fill: #333;
}
.gantt .hide {
@ -203,14 +223,17 @@
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
background: rgb(0, 0, 0);
padding: 0;
color: #959da5;
border-radius: 3px;
border: 1px solid rgb(0, 0, 0);
}
.gantt-container .popup-wrapper .title {
border-bottom: 3px solid #acacfa;
border-bottom: 1px solid #dedfe0;
padding: 10px;
text-align: center;
color: #fff;
}
.gantt-container .popup-wrapper .subtitle {
padding: 10px;
@ -221,5 +244,5 @@
height: 5px;
margin: 0 0 0 -5px;
border: 5px solid transparent;
border-top-color: rgba(0, 0, 0, 0.8);
border-bottom-color: rgba(0, 0, 0, 0.8);
}

98
dist/frappe-gantt.js vendored
View File

@ -9,6 +9,21 @@ var Gantt = (function () {
const SECOND = "second";
const MILLISECOND = "millisecond";
const SHORTENED = {
January: "Jan",
February: "Feb",
March: "Mar",
April: "Apr",
May: "May",
June: "Jun",
July: "Jul",
August: "Aug",
September: "Sep",
October: "Oct",
November: "Nov",
December: "Dec"
};
var date_utils = {
parse_duration(duration) {
const regex = /([0-9])+(y|m|d|h|min|s|ms)/gm;
@ -101,7 +116,7 @@ var Gantt = (function () {
SSS: values[6],
D: values[2],
MMMM: month_name_capitalized,
MMM: month_name_capitalized,
MMM: SHORTENED[month_name_capitalized],
};
let str = format_string;
@ -422,7 +437,7 @@ var Gantt = (function () {
this.duration *
(this.task.progress / 100) || 0;
this.group = createSVG("g", {
class: "bar-wrapper " + (this.task.custom_class || ""),
class: "bar-wrapper " + (this.task.custom_class || "") + (this.task.important && 'important'),
"data-id": this.task.id,
});
this.bar_group = createSVG("g", {
@ -463,11 +478,11 @@ var Gantt = (function () {
draw() {
this.draw_bar();
this.draw_progress_bar();
if (this.gantt.options.show_expected_progress) {
this.prepare_expected_progress_values();
this.draw_expected_progress_bar();
}
this.draw_progress_bar();
this.draw_label();
this.draw_resize_handles();
@ -528,12 +543,26 @@ var Gantt = (function () {
class: "bar-progress",
append_to: this.bar_group,
});
const x = (date_utils.diff(this.task._start, this.gantt.gantt_start, 'hour') /
this.gantt.options.step) *
this.gantt.options.column_width;
this.$date_highlight = createSVG("rect", {
x,
y: this.gantt.options.header_height - 17,
width: this.width,
height: this.height * 0.8,
rx: 12,
class: "date-highlight",
append_to: this.bar_group,
});
animateSVG(this.$bar_progress, "width", 0, this.progress_width);
}
draw_label() {
let x_coord = this.x + 5;
let x_coord = this.x + this.$bar.getWidth() / 2;
if (this.task.thumbnail) {
x_coord = this.x + this.image_size + 5;
@ -597,7 +626,7 @@ var Gantt = (function () {
const handle_width = 8;
createSVG("rect", {
x: bar.getX() + bar.getWidth() - 9,
x: bar.getX() + bar.getWidth() + handle_width - 4,
y: bar.getY() + 1,
width: handle_width,
height: this.height - 2,
@ -608,7 +637,7 @@ var Gantt = (function () {
});
createSVG("rect", {
x: bar.getX() + 1,
x: bar.getX() - handle_width - 4,
y: bar.getY() + 1,
width: handle_width,
height: this.height - 2,
@ -628,12 +657,12 @@ var Gantt = (function () {
get_progress_polygon_points() {
const bar_progress = this.$bar_progress;
return [
bar_progress.getEndX() - 5,
bar_progress.getY() + bar_progress.getHeight(),
bar_progress.getEndX() + 5,
bar_progress.getY() + bar_progress.getHeight(),
bar_progress.getEndX() - 6,
bar_progress.getY() + bar_progress.getHeight() + 8,
bar_progress.getEndX() + 6,
bar_progress.getY() + bar_progress.getHeight() + 8,
bar_progress.getEndX(),
bar_progress.getY() + bar_progress.getHeight() - 8.66,
bar_progress.getY() + bar_progress.getHeight() + 0.5,
];
}
@ -656,7 +685,7 @@ var Gantt = (function () {
this.gantt.hide_popup();
this.group.classList.remove("active");
} else {
this.show_popup();
this.show_popup(e.offsetX);
this.gantt.unselect_all();
this.group.classList.add("active");
}
@ -674,7 +703,7 @@ var Gantt = (function () {
});
}
show_popup() {
show_popup(x) {
if (this.gantt.bar_being_dragged) return;
const start_date = date_utils.format(
@ -690,6 +719,7 @@ var Gantt = (function () {
const subtitle = start_date + " - " + end_date;
this.gantt.show_popup({
x,
target_element: this.$bar,
title: this.task.name,
subtitle: subtitle,
@ -925,10 +955,12 @@ var Gantt = (function () {
label = this.group.querySelector(".bar-label"),
img = this.group.querySelector('.bar-img');
let padding = 5;
let x_offset_label_img = this.image_size + 10;
if (label.getBBox().width > bar.getWidth()) {
const labelWidth = label.getBBox().width;
const barWidth = bar.getWidth();
if (labelWidth > barWidth) {
label.classList.add("big");
if (img) {
img.setAttribute('x', bar.getX() + bar.getWidth() + padding);
@ -942,9 +974,9 @@ var Gantt = (function () {
if (img) {
img.setAttribute('x', bar.getX() + padding);
img_mask.setAttribute('x', bar.getX() + padding);
label.setAttribute('x', bar.getX() + x_offset_label_img);
label.setAttribute('x', bar.getX() + barWidth / 2 + x_offset_label_img);
} else {
label.setAttribute('x', bar.getX() + padding);
label.setAttribute('x', bar.getX() + barWidth / 2 - labelWidth / 2);
}
}
}
@ -954,10 +986,10 @@ var Gantt = (function () {
const bar = this.$bar;
this.handle_group
.querySelector(".handle.left")
.setAttribute("x", bar.getX() + 1);
.setAttribute("x", bar.getX() - 12);
this.handle_group
.querySelector(".handle.right")
.setAttribute("x", bar.getEndX() - 9);
.setAttribute("x", bar.getEndX() + 4);
const handle = this.group.querySelector(".handle.progress");
handle && handle.setAttribute("points", this.get_progress_polygon_points());
}
@ -996,15 +1028,15 @@ var Gantt = (function () {
this.gantt.options.header_height +
this.gantt.options.bar_height +
(this.gantt.options.padding + this.gantt.options.bar_height) *
this.from_task.task._index +
this.from_task.task._index +
this.gantt.options.padding;
const end_x = this.to_task.$bar.getX() - this.gantt.options.padding / 2;
const end_x = this.to_task.$bar.getX() - this.gantt.options.padding / 2 - 7;
const end_y =
this.gantt.options.header_height +
this.gantt.options.bar_height / 2 +
(this.gantt.options.padding + this.gantt.options.bar_height) *
this.to_task.task._index +
this.to_task.task._index +
this.gantt.options.padding;
const from_is_below_to =
@ -1088,9 +1120,6 @@ var Gantt = (function () {
if (!options.target_element) {
throw new Error("target_element is required to show popup");
}
if (!options.position) {
options.position = "left";
}
const target_element = options.target_element;
if (this.custom_html) {
@ -1113,15 +1142,11 @@ var Gantt = (function () {
position_meta = options.target_element.getBBox();
}
if (options.position === "left") {
this.parent.style.left =
position_meta.x + (position_meta.width + 10) + "px";
this.parent.style.top = position_meta.y + "px";
this.parent.style.left = options.x - this.parent.clientWidth / 2 + "px";
this.parent.style.top = position_meta.y + position_meta.height + 10 + "px";
this.pointer.style.transform = "rotateZ(90deg)";
this.pointer.style.left = "-7px";
this.pointer.style.top = "2px";
}
this.pointer.style.left = this.parent.clientWidth / 2 + "px";
this.pointer.style.top = "-15px";
// show
this.parent.style.opacity = 1;
@ -1602,13 +1627,10 @@ var Gantt = (function () {
const x = (date_utils.diff(d, this.gantt_start, 'hour') /
this.options.step) *
this.options.column_width;
const height =
(this.options.bar_height + this.options.padding) * this.tasks.length +
this.options.header_height +
this.options.padding / 2;
const height = (this.options.bar_height + this.options.padding) * this.tasks.length;
createSVG('rect', {
x,
y: 0,
y: this.options.header_height + this.options.padding / 2,
width: (this.view_is('Day') ? 1 : 2) * this.options.column_width,
height,
class: 'holiday-highlight',

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.dark>.gantt-container .gantt .grid-header{fill:#252525;stroke:#616161}.dark>.gantt-container .gantt .grid-row{fill:#252525}.dark>.gantt-container .gantt .grid-row:nth-child(even){fill:#3e3e3e}.dark>.gantt-container .gantt .row-line{stroke:#3e3e3e}.dark>.gantt-container .gantt .tick{stroke:#616161}.dark>.gantt-container .gantt .today-highlight{opacity:.2}.dark>.gantt-container .gantt .arrow{stroke:#eee}.dark>.gantt-container .gantt .bar{fill:#616161;stroke:none}.dark>.gantt-container .gantt .bar-progress{fill:#8a8aff}.dark>.gantt-container .gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#c6ccd2}.dark>.gantt-container .gantt .bar-invalid~.bar-label{fill:#ececec}.dark>.gantt-container .gantt .bar-label.big{fill:#ececec}.dark>.gantt-container .gantt .bar-wrapper:hover .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper:hover .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .bar-wrapper.active .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper.active .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .upper-text{fill:#a2a2a2}.dark>.gantt-container .gantt .lower-text{fill:#f7f7f7}.dark>.gantt-container .popup-wrapper{background-color:#333}.dark>.gantt-container .popup-wrapper .title{border-color:#a4a4ff}.dark>.gantt-container .popup-wrapper .pointer{border-top-color:#333}.gantt{user-select:none;-webkit-user-select:none}.gantt .grid-background{fill:none}.gantt .grid-header{fill:#fff;stroke:#e0e0e0;stroke-width:1.4}.gantt .grid-row{fill:#fff}.gantt .grid-row:nth-child(even){fill:#f5f5f5}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke:#000;stroke-width:.5}.gantt .today-highlight{fill:#f6e796;opacity:.5}.gantt .week-highlight{fill:#f6e796;opacity:.5}.gantt .holiday-highlight{fill:#eee;opacity:.5}.gantt .month-highlight{fill:#f6e796;opacity:.5}.gantt .year-highlight{fill:#f6e796;opacity:.5}.gantt .arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar{fill:#b8c2cc;stroke:#8d99a6;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#acacfa}.gantt .bar-expected-progress{fill:#c4c4e9}.gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#8d99a6;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#555}.gantt .bar-label{fill:#fff;dominant-baseline:central;font-size:12px;font-weight:500}.gantt .bar-label.big{fill:#555;text-anchor:start}.gantt .handle{fill:#ddd;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt .bar-wrapper{cursor:pointer;outline:none}.gantt .bar-wrapper:hover .bar{fill:#a9b5c1}.gantt .bar-wrapper:hover .bar-progress{fill:#9494f9}.gantt .bar-wrapper:hover .handle{visibility:visible;opacity:1}.gantt .bar-wrapper.active .bar{fill:#a9b5c1}.gantt .bar-wrapper.active .bar-progress{fill:#9494f9}.gantt .lower-text,.gantt .upper-text{font-size:12px;text-anchor:middle}.gantt .upper-text{fill:#555}.gantt .lower-text{fill:#333}.gantt .hide{display:none}.gantt-container{position:relative;overflow:auto;font-size:12px;height:500px}.gantt-container .popup-wrapper{position:absolute;top:0;left:0;background:rgba(0,0,0,.8);padding:0;color:#959da5;border-radius:3px}.gantt-container .popup-wrapper .title{border-bottom:3px solid #acacfa;padding:10px}.gantt-container .popup-wrapper .subtitle{padding:10px;color:#dfe2e5}.gantt-container .popup-wrapper .pointer{position:absolute;height:5px;margin:0 0 0 -5px;border:5px solid rgba(0,0,0,0);border-top-color:rgba(0,0,0,.8)}
.dark>.gantt-container .gantt .grid-header{fill:#252525;stroke:#616161}.dark>.gantt-container .gantt .grid-row{fill:#252525}.dark>.gantt-container .gantt .grid-row:nth-child(even){fill:#3e3e3e}.dark>.gantt-container .gantt .row-line{stroke:#3e3e3e}.dark>.gantt-container .gantt .tick{stroke:#616161}.dark>.gantt-container .gantt .today-highlight{opacity:.2}.dark>.gantt-container .gantt .arrow{stroke:#eee}.dark>.gantt-container .gantt .bar{fill:#616161;stroke:none}.dark>.gantt-container .gantt .bar-progress{fill:#8a8aff}.dark>.gantt-container .gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#c6ccd2}.dark>.gantt-container .gantt .bar-invalid~.bar-label{fill:#ececec}.dark>.gantt-container .gantt .bar-label.big{fill:#ececec}.dark>.gantt-container .gantt .bar-wrapper:hover .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper:hover .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .bar-wrapper.active .bar{fill:#6e6e6e}.dark>.gantt-container .gantt .bar-wrapper.active .bar-progress{fill:#a4a4ff}.dark>.gantt-container .gantt .upper-text{fill:#a2a2a2}.dark>.gantt-container .gantt .lower-text{fill:#f7f7f7}.dark>.gantt-container .popup-wrapper{background-color:#333}.dark>.gantt-container .popup-wrapper .title{border-color:#a4a4ff}.dark>.gantt-container .popup-wrapper .pointer{border-top-color:#333}.gantt{user-select:none;-webkit-user-select:none}.gantt .grid-background{fill:none}.gantt .grid-header{fill:#fff;stroke:#e0e0e0;stroke-width:1.4}.gantt .grid-row{fill:#fff}.gantt .row-line{stroke:#ebeff2}.gantt .tick{stroke:#e0e0e0;stroke-width:.2}.gantt .tick.thick{stroke:#000;stroke-width:.5}.gantt .today-highlight{fill:#f6e796;opacity:.5}.gantt .week-highlight{fill:#f6e796;opacity:.5}.gantt .holiday-highlight{fill:#f3f4f7;opacity:.5}.gantt .month-highlight{fill:#f6e796;opacity:.5}.gantt .year-highlight{fill:#f6e796;opacity:.5}.gantt .arrow{fill:none;stroke:#666;stroke-width:1.4}.gantt .bar-wrapper .bar{fill:#fff;stroke:#fff;stroke-width:0;transition:stroke-width .3s ease}.gantt .bar-progress{fill:#dedfe0}.gantt .date-highlight{fill:#e8e8e8;display:none}.gantt .bar-expected-progress{fill:#c4c4e9}.gantt .bar-invalid{fill:rgba(0,0,0,0);stroke:#fff;stroke-width:1;stroke-dasharray:5}.gantt .bar-invalid~.bar-label{fill:#fff}.gantt .bar-label{fill:#333;dominant-baseline:central;font-family:Helvetica;font-size:14px;font-weight:400}.gantt .bar-label.big{fill:#333;text-anchor:start}.gantt .bar-wrapper.important .bar{fill:#94c4f4}.gantt .bar-wrapper.important .bar-progress{fill:#2c94ec}.gantt .bar-wrapper.important .bar-label{fill:#fff}.gantt .bar-wrapper.important .handle{fill:#94c4f4}.gantt .handle{fill:#dcdce4;cursor:ew-resize;opacity:0;visibility:hidden;transition:opacity .3s ease}.gantt:hover .handle{visibility:visible;opacity:1}.gantt .bar-wrapper{cursor:pointer}.gantt .bar-wrapper .bar{outline:groove 1px #000;border-radius:3px}.gantt .bar-wrapper.important .bar{outline:none;outline-width:1.5px}.gantt .bar-wrapper.important .bar:active{outline:1px dotted}.gantt .bar-wrapper:hover .bar{outline-width:1.5px;transition:transform .3s ease}.gantt .bar-wrapper:hover .date-highlight{display:block}.gantt .bar-wrapper.active .bar{outline-style:dotted}.gantt .lower-text,.gantt .upper-text{font-size:14px;text-anchor:middle}.gantt .lower-text,.gantt .upper-text{fill:#333}.gantt .hide{display:none}.gantt-container{position:relative;overflow:auto;font-size:12px;height:500px}.gantt-container .popup-wrapper{position:absolute;top:0;left:0;background:#000;padding:0;color:#959da5;border-radius:3px;border:1px solid #000}.gantt-container .popup-wrapper .title{border-bottom:1px solid #dedfe0;padding:10px;text-align:center;color:#fff}.gantt-container .popup-wrapper .subtitle{padding:10px;color:#dfe2e5}.gantt-container .popup-wrapper .pointer{position:absolute;height:5px;margin:0 0 0 -5px;border:5px solid rgba(0,0,0,0);border-bottom-color:rgba(0,0,0,.8)}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,48 +34,48 @@
<script>
let tasks = [
{
start: '2018-10-01',
end: '2018-10-08',
start: '2024-10-01',
end: '2024-10-08',
name: 'Redesign website',
id: "Task 0",
progress: 80
progress: 30
},
{
start: '2018-09-26',
start: '2024-09-26',
// Utilizes duration
duration: '1m 4d',
duration: '6d',
name: 'Write new content',
id: "Task 1",
progress: 5,
dependencies: 'Task 0'
important: true
},
{
start: '2018-10-04',
end: '2018-10-08',
start: '2024-10-04',
end: '2024-10-08',
name: 'Apply new styles',
id: "Task 2",
progress: 100,
progress: 80,
dependencies: 'Task 1'
},
{
start: '2018-10-08',
end: '2018-10-09',
start: '2024-10-08',
end: '2024-10-09',
name: 'Review',
id: "Task 3",
progress: 5,
dependencies: 'Task 2'
},
{
start: '2018-10-08',
end: '2018-10-10',
start: '2024-10-08',
end: '2024-10-10',
name: 'Deploy',
id: "Task 4",
progress: 0,
// dependencies: 'Task 2'
},
{
start: '2018-10-11',
end: '2018-10-11',
start: '2024-10-11',
end: '2024-10-11',
name: 'Go Live!',
id: "Task 5",
progress: 0,
@ -95,24 +95,24 @@
// tasks = [...tasks, ...Array.from({length: tasks.length * 3}, (_, i) => ({...tasks[i % 3], id: i}))]
let gantt_chart = new Gantt(".gantt-target", tasks, {
on_click: (task) => {
console.log("Double Click", task);
},
on_double_click: (task) => {
console.log("Double Click", task);
},
on_date_change: (task, start, end) => {
console.log("Date change", task, start, end);
},
on_progress_change: (task, progress) => {
console.log("Progress Change", task, progress);
},
on_view_change: (mode) => {
console.log("View Change", mode);
},
on_hover: (task, x, y) => {
console.log("Hover", x, y);
},
// on_click: (task) => {
// console.log("Double Click", task);
// },
// on_double_click: (task) => {
// console.log("Double Click", task);
// },
// on_date_change: (task, start, end) => {
// console.log("Date change", task, start, end);
// },
// on_progress_change: (task, progress) => {
// console.log("Progress Change", task, progress);
// },
// on_view_change: (mode) => {
// console.log("View Change", mode);
// },
// on_hover: (task, x, y) => {
// console.log("Hover", x, y);
// },
view_mode: "Day",
view_mode_padding: { DAY: "7d" },
language: "en",