2
0
mirror of https://github.com/tenrok/vue-ganttastic.git synced 2026-06-24 01:10:34 +03:00

chore: restructuring

This commit is contained in:
2021-10-19 14:39:10 +03:00
parent 992e0aa04e
commit c562d6ef7c
17 changed files with 434 additions and 433 deletions
-1
View File
@@ -1,3 +1,2 @@
src/demo
demo demo
dist dist
+7 -3
View File
@@ -1,7 +1,4 @@
.DS_Store .DS_Store
node_modules
/dist
# local env files # local env files
.env.local .env.local
@@ -21,3 +18,10 @@ pnpm-debug.log*
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
# npm
node_modules
# output directories
/demo
/dist
+2 -10
View File
@@ -1,19 +1,11 @@
module.exports = { module.exports = {
arrowParens: 'avoid', arrowParens: 'avoid',
bracketSpacing: true, bracketSpacing: true,
// embeddedLanguageFormatting: 'auto',
// htmlWhitespaceSensitivity: 'css',
// insertPragma: false,
// jsxBracketSameLine: false,
// jsxSingleQuote: false,
printWidth: 80, printWidth: 80,
// proseWrap: 'preserve',
// quoteProps: 'as-needed',
// requirePragma: false,
semi: false, semi: false,
singleQuote: true, singleQuote: true,
tabWidth: 2, tabWidth: 2,
trailingComma: 'es5', trailingComma: 'none',
useTabs: false, useTabs: false,
vueIndentScriptAndStyle: true, vueIndentScriptAndStyle: true
} }
+2 -2
View File
@@ -58,8 +58,8 @@ The following code showcases a simple usage example in a .vue SFC (Single File C
</template> </template>
<script> <script>
import { GGanttChart, GGanttRow } from '@tenrok/vue-ganttastic'
import { GGanttChart, GGanttRow } from 'vue-ganttastic' import '@tenrok/vue-ganttastic/dist/vue-ganttastic.css'
export default { export default {
@@ -32,7 +32,7 @@
class="color-indicator" class="color-indicator"
:style="{ :style="{
background: background:
this.barStyle.background || this.barStyle.backgroundColor, this.barStyle.background || this.barStyle.backgroundColor
}" }"
/> />
{{ barStartText }} - {{ barEndText }} {{ barStartText }} - {{ barEndText }}
@@ -50,7 +50,7 @@ export default {
props: { props: {
bar: { type: Object }, bar: { type: Object },
barContainer: [Object, DOMRect], barContainer: [Object, DOMRect],
allBarsInRow: { type: Array }, allBarsInRow: { type: Array }
}, },
inject: [ inject: [
@@ -63,7 +63,7 @@ export default {
'onDragendBar', 'onDragendBar',
'getMinGapBetweenBars', 'getMinGapBetweenBars',
'getTimeUnit', 'getTimeUnit',
'getTimeFormat', 'getTimeFormat'
], ],
data() { data() {
@@ -85,7 +85,7 @@ export default {
this.ganttChartProps.precision === 'month' ? 'MM-DD' : 'HH:mm', this.ganttChartProps.precision === 'month' ? 'MM-DD' : 'HH:mm',
timeFormat: this.getTimeFormat(), timeFormat: this.getTimeFormat(),
barStartKey: this.ganttChartProps.barStartKey, barStartKey: this.ganttChartProps.barStartKey,
barEndKey: this.ganttChartProps.barEndKey, barEndKey: this.ganttChartProps.barEndKey
} }
}, },
@@ -96,7 +96,7 @@ export default {
}, },
set(value) { set(value) {
this.bar[this.barStartKey] = value.format(this.timeFormat) this.bar[this.barStartKey] = value.format(this.timeFormat)
}, }
}, },
barEndMoment: { barEndMoment: {
@@ -105,20 +105,20 @@ export default {
}, },
set(value) { set(value) {
this.bar[this.barEndKey] = value.format(this.timeFormat) this.bar[this.barEndKey] = value.format(this.timeFormat)
}, }
}, },
barStartText: { barStartText: {
get() { get() {
return moment(this.barStartMoment).format(this.timeChildFormat) return moment(this.barStartMoment).format(this.timeChildFormat)
}, }
}, },
barEndText: { barEndText: {
get() { get() {
let endMoment = moment(this.barEndMoment) let endMoment = moment(this.barEndMoment)
return endMoment.format(this.timeChildFormat) return endMoment.format(this.timeChildFormat)
}, }
}, },
barConfig() { barConfig() {
@@ -131,7 +131,7 @@ export default {
this.bar.ganttBarConfig.backgroundColor, this.bar.ganttBarConfig.backgroundColor,
opacity: this.bar.ganttBarConfig.isShadow opacity: this.bar.ganttBarConfig.isShadow
? '0.3' ? '0.3'
: this.bar.ganttBarConfig.opacity, : this.bar.ganttBarConfig.opacity
} }
} }
return {} return {}
@@ -147,14 +147,14 @@ export default {
left: `${xStart}px`, left: `${xStart}px`,
width: `${xEnd - xStart}px`, width: `${xEnd - xStart}px`,
height: `${this.ganttChartProps.rowHeight - 6}px`, height: `${this.ganttChartProps.rowHeight - 6}px`,
zIndex: this.barConfig.zIndex || (this.isDragging ? 2 : 1), zIndex: this.barConfig.zIndex || (this.isDragging ? 2 : 1)
} }
}, },
tooltipStyle() { tooltipStyle() {
return { return {
left: this.barStyle.left, left: this.barStyle.left,
top: `${this.ganttChartProps.rowHeight}px`, top: `${this.ganttChartProps.rowHeight}px`
} }
}, },
@@ -164,7 +164,7 @@ export default {
chartEndMoment() { chartEndMoment() {
return moment(this.ganttChartProps.chartEnd) return moment(this.ganttChartProps.chartEnd)
}, }
}, },
methods: { methods: {
@@ -213,7 +213,7 @@ export default {
this.setDragLimitsOfGanttBar(this) this.setDragLimitsOfGanttBar(this)
// initialize the dragging on next mousemove event: // initialize the dragging on next mousemove event:
window.addEventListener('mousemove', this.onFirstMousemove, { window.addEventListener('mousemove', this.onFirstMousemove, {
once: true, once: true
}) })
// if next mousemove happens after mouse up (if user just presses mouse button down, then up, without moving): // if next mousemove happens after mouse up (if user just presses mouse button down, then up, without moving):
window.addEventListener( window.addEventListener(
@@ -569,120 +569,7 @@ export default {
timeDiffFromStart = duration.asHours() timeDiffFromStart = duration.asHours()
} }
return moment(this.chartStartMoment).add(timeDiffFromStart, 'hours') return moment(this.chartStartMoment).add(timeDiffFromStart, 'hours')
}, }
}, }
} }
</script> </script>
<style scoped>
.g-gantt-bar {
position: absolute;
top: 2px;
left: 30px;
display: flex;
justify-content: space-between;
align-items: center;
color: white;
width: 300px;
height: 34px;
border-radius: 15px;
background: #79869c;
overflow: hidden;
cursor: move;
}
.g-gantt-bar-immobile {
cursor: unset;
}
.g-gantt-bar-label {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 14px 0 14px; /* 14px is the width of the handle */
display: flex;
justify-content: center;
align-items: center;
}
.g-gantt-bar-label > * {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.g-gantt-bar > .g-gantt-bar-handle-left,
.g-gantt-bar > .g-gantt-bar-handle-right {
position: absolute;
width: 10px;
height: 100%;
background: white;
opacity: 0.7;
border-radius: 40px;
}
.g-gantt-bar-handle-left {
left: 0;
cursor: w-resize;
}
.g-gantt-bar-handle-right {
right: 0;
cursor: e-resize;
}
.g-gantt-bar-label img {
pointer-events: none;
}
.g-gantt-tooltip {
position: absolute;
background: black;
color: white;
z-index: 3;
font-size: 0.7em;
padding: 3px;
border-radius: 3px;
transition: opacity 0.2s;
display: flex;
align-items: center;
}
.g-gantt-tooltip:before {
content: '';
position: absolute;
top: 0;
left: 10%;
width: 0;
height: 0;
border: 10px solid transparent;
border-bottom-color: black;
border-top: 0;
margin-left: -5px;
margin-top: -5px;
}
.g-gantt-tooltip > .color-indicator {
width: 8px;
height: 8px;
border-radius: 100%;
margin-right: 4px;
}
.fade-enter-active {
animation: fade-in 0.3s;
}
.fade-leave-active {
animation: fade-in 0.3s reverse;
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
</style>
@@ -39,18 +39,18 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import GanttasticThemeColors from '@/assets/GanttasticThemeColors.js' import GanttasticThemeColors from './GanttasticThemeColors.js'
import GGanttTimeaxis from '@/components/GGanttTimeaxis.vue' import GGanttTimeaxis from './GGanttTimeaxis.vue'
import GGanttGrid from '@/components/GGanttGrid.vue' import GGanttGrid from './GGanttGrid.vue'
import GGanttRow from '@/components/GGanttRow.vue' import GGanttRow from './GGanttRow.vue'
import GGanttBar from '@/components/GGanttBar.vue' import GGanttBar from './GGanttBar.vue'
export default { export default {
name: 'GGanttChart', name: 'GGanttChart',
components: { components: {
GGanttTimeaxis, GGanttTimeaxis,
GGanttGrid, GGanttGrid
}, },
props: { props: {
@@ -75,13 +75,13 @@ export default {
precision: { type: String, default: 'month' }, // 'month', 'day' precision: { type: String, default: 'month' }, // 'month', 'day'
barStartKey: { type: String, default: 'start' }, // property name of the bar objects that represents the start datetime barStartKey: { type: String, default: 'start' }, // property name of the bar objects that represents the start datetime
barEndKey: { type: String, default: 'end' }, // property name of the bar objects that represents the end datetime barEndKey: { type: String, default: 'end' }, // property name of the bar objects that represents the end datetime
mayAdd: { type: Boolean, default: true }, mayAdd: { type: Boolean, default: true }
}, },
data() { data() {
return { return {
timemarkerOffset: 0, timemarkerOffset: 0,
movedBarsInDrag: new Set(), movedBarsInDrag: new Set()
} }
}, },
@@ -104,7 +104,7 @@ export default {
themeColors() { themeColors() {
return GanttasticThemeColors[this.theme] || GanttasticThemeColors.default return GanttasticThemeColors[this.theme] || GanttasticThemeColors.default
}, }
}, },
methods: { methods: {
@@ -376,7 +376,7 @@ export default {
} else if (nextBar.barConfig.bundle) { } else if (nextBar.barConfig.bundle) {
bundleBarsAndGapDist.push({ bundleBarsAndGapDist.push({
bar: nextBar, bar: nextBar,
gapDistance: gapDistanceSoFar, gapDistance: gapDistanceSoFar
}) })
} }
currentBar = nextBar currentBar = nextBar
@@ -398,7 +398,7 @@ export default {
} else if (nextBar.barConfig.bundle) { } else if (nextBar.barConfig.bundle) {
bundleBarsAndGapDist.push({ bundleBarsAndGapDist.push({
bar: nextBar, bar: nextBar,
gapDistance: gapDistanceSoFar, gapDistance: gapDistanceSoFar
}) })
} }
currentBar = nextBar currentBar = nextBar
@@ -448,7 +448,7 @@ export default {
} else { } else {
return null return null
} }
}, }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@@ -478,34 +478,8 @@ export default {
getMinGapBetweenBars: () => this.minGapBetweenBars, getMinGapBetweenBars: () => this.minGapBetweenBars,
getDefaultBarLength: () => this.defaultBarLength, getDefaultBarLength: () => this.defaultBarLength,
getTimeUnit: () => this.timeUnit, getTimeUnit: () => this.timeUnit,
getTimeFormat: () => this.timeFormat, getTimeFormat: () => this.timeFormat
} }
}, }
} }
</script> </script>
<style scoped>
.g-gantt-chart {
position: relative;
/* display: flex; */
/* flex-direction: column; */
overflow: auto;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
padding-bottom: 23px;
border: 1px solid #eaeaea;
box-sizing: border-box;
}
.g-gantt-chart >>> * {
font-family: Roboto, Verdana;
}
.g-gantt-rows-container {
position: relative;
}
</style>
@@ -13,8 +13,8 @@
{ {
'g-grid-line-highlighted': 'g-grid-line-highlighted':
(precision === 'day' && highlightedHours.includes(childPoint)) || (precision === 'day' && highlightedHours.includes(childPoint)) ||
(precision === 'month' && highlightedDays.includes(childPoint)), (precision === 'month' && highlightedDays.includes(childPoint))
}, }
]" ]"
:style="{ width: `${gridSize}px` }" :style="{ width: `${gridSize}px` }"
/> />
@@ -35,7 +35,7 @@ export default {
highlightedDays: { type: Array, default: () => [] }, highlightedDays: { type: Array, default: () => [] },
precision: { type: String }, precision: { type: String },
timeCount: { type: Number }, timeCount: { type: Number },
gridSize: { type: Number }, gridSize: { type: Number }
}, },
computed: { computed: {
@@ -56,32 +56,7 @@ export default {
} }
} }
return res return res
}, }
}, }
} }
</script> </script>
<style scoped>
.g-grid-container {
position: absolute;
top: 0;
bottom: 0;
overflow: hidden;
}
.g-grid-line {
height: 100%;
border: 1px solid transparent;
border-left: 1px solid #eaeaea;
box-sizing: border-box;
display: inline-block;
}
.g-grid-line-last {
border-right: 1px solid #eaeaea;
}
.g-grid-line-highlighted {
background: #dcefff;
}
</style>
@@ -37,20 +37,20 @@
</template> </template>
<script> <script>
import GGanttBar from '@/components/GGanttBar.vue' import GGanttBar from './GGanttBar.vue'
import moment from 'moment' import moment from 'moment'
export default { export default {
name: 'GGanttRow', name: 'GGanttRow',
components: { components: {
GGanttBar, GGanttBar
}, },
props: { props: {
label: { type: String, default: 'Row' }, label: { type: String, default: 'Row' },
bars: { type: Array, default: () => [] }, bars: { type: Array, default: () => [] },
highlightOnHover: { type: Boolean }, highlightOnHover: { type: Boolean }
}, },
inject: [ inject: [
@@ -60,14 +60,14 @@ export default {
'getChartEnd', 'getChartEnd',
'getDefaultBarLength', 'getDefaultBarLength',
'getTimeUnit', 'getTimeUnit',
'getTimeFormat', 'getTimeFormat'
], ],
data() { data() {
return { return {
barContainer: {}, barContainer: {},
timeUnit: this.getTimeUnit(), timeUnit: this.getTimeUnit(),
timeFormat: this.getTimeFormat(), timeFormat: this.getTimeFormat()
} }
}, },
@@ -77,9 +77,9 @@ export default {
width: `${this.$parent.rowLabelWidth}px`, width: `${this.$parent.rowLabelWidth}px`,
// height: `${this.$parent.rowHeight}px`, // height: `${this.$parent.rowHeight}px`,
background: this.$parent.themeColors.ternary, background: this.$parent.themeColors.ternary,
color: this.$parent.themeColors.text, color: this.$parent.themeColors.text
} }
}, }
}, },
mounted() { mounted() {
@@ -163,50 +163,13 @@ export default {
if (this.$refs.barContainer) { if (this.$refs.barContainer) {
this.barContainer = this.$refs.barContainer.getBoundingClientRect() this.barContainer = this.$refs.barContainer.getBoundingClientRect()
} }
}, }
}, },
watch: { watch: {
'$parent.rowLabelWidth': function () { '$parent.rowLabelWidth': function () {
this.barContainer = this.$refs.barContainer.getBoundingClientRect() this.barContainer = this.$refs.barContainer.getBoundingClientRect()
}, }
}, }
} }
</script> </script>
<style scoped>
.g-gantt-row {
display: flex;
width: 100%;
height: 40px;
transition: background-color 0.2s;
}
.g-gantt-row > .g-gantt-row-label {
display: flex;
/* justify-content: center; */
align-items: center;
background: #e8e8e8;
color: #424242;
font-size: 0.9em;
z-index: 3;
font-weight: bold;
left: 0;
position: sticky;
padding: 0 10px;
box-sizing: border-box;
}
.g-gantt-row > .g-gantt-row-label > * {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.g-gantt-row > .g-gantt-row-bars-container {
position: relative;
/* border-top: 1px solid #eaeaea; */
border-bottom: 1px solid #eaeaea;
flex: 1;
}
</style>
@@ -8,7 +8,7 @@
class="g-timeaxis-empty-space" class="g-timeaxis-empty-space"
:style="{ :style="{
minWidth: `${rowLabelWidth}px`, minWidth: `${rowLabelWidth}px`,
background: themeColors.secondary, background: themeColors.secondary
}" }"
/> />
<div class="g-timeaxis-days"> <div class="g-timeaxis-days">
@@ -19,7 +19,7 @@
:style="{ :style="{
background: background:
index % 2 === 0 ? themeColors.primary : themeColors.secondary, index % 2 === 0 ? themeColors.primary : themeColors.secondary,
color: themeColors.text, color: themeColors.text
}" }"
> >
<div v-html="pointFormatted(point) || '&nbsp;'"></div> <div v-html="pointFormatted(point) || '&nbsp;'"></div>
@@ -34,7 +34,7 @@
width: `${gridSize}px`, width: `${gridSize}px`,
background: background:
index % 2 === 0 ? themeColors.primary : themeColors.secondary, index % 2 === 0 ? themeColors.primary : themeColors.secondary,
color: themeColors.text, color: themeColors.text
}" }"
> >
<span :style="{ fontSize: hourFontSize }">{{ <span :style="{ fontSize: hourFontSize }">{{
@@ -68,7 +68,7 @@ export default {
precision: { type: String }, precision: { type: String },
timeFormat: { type: String }, timeFormat: { type: String },
timeCount: { type: Number }, timeCount: { type: Number },
gridSize: { type: Number }, gridSize: { type: Number }
}, },
data() { data() {
@@ -78,7 +78,7 @@ export default {
timemarker: null, timemarker: null,
hourFontSize: '11px', hourFontSize: '11px',
dayFormat: 'DD MMMM', dayFormat: 'DD MMMM',
monthFormat: 'MMMM YYYY', monthFormat: 'MMMM YYYY'
} }
}, },
@@ -88,7 +88,7 @@ export default {
}, },
chartEnd() { chartEnd() {
this.initAxis() this.initAxis()
}, }
}, },
mounted() { mounted() {
@@ -160,13 +160,13 @@ export default {
let axisMonthObject = { let axisMonthObject = {
widthPercentage: widthPercentage, widthPercentage: widthPercentage,
value: moment(datetime, 'YYYY-MM'), value: moment(datetime, 'YYYY-MM'),
childPoints: [], childPoints: []
} }
let startDay = datetimeMoment.date() let startDay = datetimeMoment.date()
for (let i = 0; i <= endDay - startDay; i++) { for (let i = 0; i <= endDay - startDay; i++) {
let day = { let day = {
text: datetimeMoment.format('D'), text: datetimeMoment.format('D'),
fullDatetime: datetimeMoment.format(this.timeFormat), fullDatetime: datetimeMoment.format(this.timeFormat)
} }
axisMonthObject.childPoints.push(day) axisMonthObject.childPoints.push(day)
datetimeMoment.add(1, 'day') datetimeMoment.add(1, 'day')
@@ -179,13 +179,13 @@ export default {
let axisDayObject = { let axisDayObject = {
widthPercentage: widthPercentage, widthPercentage: widthPercentage,
value: moment(datetime, 'YYYY-MM-DD'), // ISO 8601 value: moment(datetime, 'YYYY-MM-DD'), // ISO 8601
childPoints: [], childPoints: []
} }
let startHour = datetimeMoment.hour() let startHour = datetimeMoment.hour()
for (let i = 0; i <= endHour - startHour; i++) { for (let i = 0; i <= endHour - startHour; i++) {
let hour = { let hour = {
text: datetimeMoment.format('HH'), text: datetimeMoment.format('HH'),
fullDatetime: datetimeMoment.format(this.timeFormat), fullDatetime: datetimeMoment.format(this.timeFormat)
} }
axisDayObject.childPoints.push(hour) axisDayObject.childPoints.push(hour)
datetimeMoment.add(1, 'hour') datetimeMoment.add(1, 'hour')
@@ -239,91 +239,7 @@ export default {
// ? moment(point.value).locale(this.locale).format(this.dayFormat) // ? moment(point.value).locale(this.locale).format(this.dayFormat)
// : '' // : ''
return moment(point.value).locale(this.locale).format(this.dayFormat) return moment(point.value).locale(this.locale).format(this.dayFormat)
}, }
}, }
} }
</script> </script>
<style scoped>
.g-timeaxis,
.g-timeaxis-days,
.g-timeaxis-day,
.g-timeaxis-day > div {
display: flex;
/* overflow: hidden; */
}
.g-timeaxis {
position: sticky;
top: 0;
/* width: 100%; */
/* height: 8%; */
/* min-height: 75px; */
background: white;
z-index: 4;
box-shadow: 0px 1px 3px 2px rgba(50, 50, 50, 0.5);
}
.g-timeaxis > .g-timeaxis-empty-space {
min-height: 100%;
background: #f5f5f5;
z-index: 5;
left: 0;
position: sticky;
}
.g-timeaxis > .g-timeaxis-days {
position: relative;
height: 100%;
}
.g-timeaxis-day {
height: 100%;
flex-direction: column;
background: #e0e0e0;
}
.g-timeaxis-day:nth-child(odd) {
background: #e8e8e8;
}
.g-timeaxis-day > div:nth-child(1) {
/* day text */
height: 50%;
justify-content: space-around;
font-weight: bold;
align-items: center;
}
.g-timeaxis-day > div:nth-child(2) {
/* hours of a day */
align-items: flex-end;
height: 50%;
justify-content: space-between;
background: #f5f5f5;
padding-top: 2px;
color: #212121;
}
.g-timeaxis-hour {
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-direction: column;
opacity: 0.5;
}
.g-timeaxis-hour-pin {
width: 1px;
height: 8px;
}
.g-timeaxis-marker {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 3px;
background: black;
}
</style>
+19
View File
@@ -0,0 +1,19 @@
import GGanttChart from './components/GGanttChart.vue'
import GGanttRow from './components/GGanttRow.vue'
import './scss/vue-ganttastic.scss'
const VueGanttastic = { GGanttChart, GGanttRow }
const install = Vue => {
Object.keys(VueGanttastic).forEach(name => {
Vue.component(name, VueGanttastic[name])
})
}
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
export default VueGanttastic
export { GGanttChart, GGanttRow }
+274
View File
@@ -0,0 +1,274 @@
.g-gantt-chart {
position: relative;
/* display: flex; */
/* flex-direction: column; */
overflow: auto;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
padding-bottom: 23px;
border: 1px solid #eaeaea;
box-sizing: border-box;
}
.g-gantt-chart >>> * {
font-family: Roboto, Verdana;
}
.g-timeaxis,
.g-timeaxis-days,
.g-timeaxis-day,
.g-timeaxis-day > div {
display: flex;
/* overflow: hidden; */
}
.g-timeaxis {
position: sticky;
top: 0;
/* width: 100%; */
/* height: 8%; */
/* min-height: 75px; */
background: white;
z-index: 4;
box-shadow: 0px 1px 3px 2px rgba(50, 50, 50, 0.5);
}
.g-timeaxis > .g-timeaxis-empty-space {
min-height: 100%;
background: #f5f5f5;
z-index: 5;
left: 0;
position: sticky;
}
.g-timeaxis > .g-timeaxis-days {
position: relative;
height: 100%;
}
.g-timeaxis-day {
height: 100%;
flex-direction: column;
background: #e0e0e0;
}
.g-timeaxis-day:nth-child(odd) {
background: #e8e8e8;
}
.g-timeaxis-day > div:nth-child(1) {
/* day text */
height: 50%;
justify-content: space-around;
font-weight: bold;
align-items: center;
}
.g-timeaxis-day > div:nth-child(2) {
/* hours of a day */
align-items: flex-end;
height: 50%;
justify-content: space-between;
background: #f5f5f5;
padding-top: 2px;
color: #212121;
}
.g-timeaxis-hour {
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-direction: column;
opacity: 0.5;
}
.g-timeaxis-hour-pin {
width: 1px;
height: 8px;
}
.g-timeaxis-marker {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 3px;
background: black;
}
.g-gantt-rows-container {
position: relative;
}
.g-grid-container {
position: absolute;
top: 0;
bottom: 0;
overflow: hidden;
}
.g-grid-line {
height: 100%;
border: 1px solid transparent;
border-left: 1px solid #eaeaea;
box-sizing: border-box;
display: inline-block;
}
.g-grid-line-last {
border-right: 1px solid #eaeaea;
}
.g-grid-line-highlighted {
background: #dcefff;
}
.g-gantt-row {
display: flex;
width: 100%;
height: 40px;
transition: background-color 0.2s;
}
.g-gantt-row > .g-gantt-row-label {
display: flex;
/* justify-content: center; */
align-items: center;
background: #e8e8e8;
color: #424242;
font-size: 0.9em;
z-index: 3;
font-weight: bold;
left: 0;
position: sticky;
padding: 0 10px;
box-sizing: border-box;
}
.g-gantt-row > .g-gantt-row-label > * {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.g-gantt-row > .g-gantt-row-bars-container {
position: relative;
/* border-top: 1px solid #eaeaea; */
border-bottom: 1px solid #eaeaea;
flex: 1;
}
.g-gantt-bar {
position: absolute;
top: 2px;
left: 30px;
display: flex;
justify-content: space-between;
align-items: center;
color: white;
width: 300px;
height: 34px;
border-radius: 15px;
background: #79869c;
overflow: hidden;
cursor: move;
}
.g-gantt-bar-immobile {
cursor: unset;
}
.g-gantt-bar-label {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 14px 0 14px; /* 14px is the width of the handle */
display: flex;
justify-content: center;
align-items: center;
}
.g-gantt-bar-label > * {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.g-gantt-bar > .g-gantt-bar-handle-left,
.g-gantt-bar > .g-gantt-bar-handle-right {
position: absolute;
width: 10px;
height: 100%;
background: white;
opacity: 0.7;
border-radius: 40px;
}
.g-gantt-bar-handle-left {
left: 0;
cursor: w-resize;
}
.g-gantt-bar-handle-right {
right: 0;
cursor: e-resize;
}
.g-gantt-bar-label img {
pointer-events: none;
}
.g-gantt-tooltip {
position: absolute;
background: black;
color: white;
z-index: 3;
font-size: 0.7em;
padding: 3px;
border-radius: 3px;
transition: opacity 0.2s;
display: flex;
align-items: center;
}
.g-gantt-tooltip:before {
content: '';
position: absolute;
top: 0;
left: 10%;
width: 0;
height: 0;
border: 10px solid transparent;
border-bottom-color: black;
border-top: 0;
margin-left: -5px;
margin-top: -5px;
}
.g-gantt-tooltip > .color-indicator {
width: 8px;
height: 8px;
border-radius: 100%;
margin-right: 4px;
}
.fade-enter-active {
animation: fade-in 0.3s;
}
.fade-leave-active {
animation: fade-in 0.3s reverse;
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@tenrok/vue-ganttastic", "name": "@tenrok/vue-ganttastic",
"version": "0.10.11", "version": "0.10.12",
"description": "A simple and customizable Gantt chart component for Vue.js", "description": "A simple and customizable Gantt chart component for Vue.js",
"keywords": [ "keywords": [
"gantt", "gantt",
@@ -40,8 +40,8 @@
"url": "git+https://github.com/tenrok/vue-ganttastic.git" "url": "git+https://github.com/tenrok/vue-ganttastic.git"
}, },
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve --open",
"build": "vue-cli-service build --target lib --name vue-ganttastic src/lib.js", "build": "vue-cli-service build --target lib --name vue-ganttastic lib/index.js",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
+58 -63
View File
@@ -69,14 +69,7 @@
</template> </template>
<script> <script>
import GGanttChart from '@/components/GGanttChart.vue'
import GGanttRow from '@/components/GGanttRow.vue'
export default { export default {
components: {
GGanttChart,
GGanttRow,
},
data: () => ({ data: () => ({
chart1: { chart1: {
chartStart: '2020-03-02 00:00', chartStart: '2020-03-02 00:00',
@@ -104,8 +97,8 @@ export default {
color: 'white', color: 'white',
backgroundColor: '#404040', backgroundColor: '#404040',
opacity: 0.5, opacity: 0.5,
immobile: true, immobile: true
}, }
}, },
{ {
myStart: '2020-03-03 04:00', myStart: '2020-03-03 04:00',
@@ -114,10 +107,10 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#2e74a3', backgroundColor: '#2e74a3',
bundle: 'blueBundle', bundle: 'blueBundle'
}, }
}, }
], ]
}, },
{ {
label: 'Row #2', label: 'Row #2',
@@ -129,8 +122,8 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#de3b26', backgroundColor: '#de3b26',
bundle: 'redBundle', bundle: 'redBundle'
}, }
}, },
{ {
myStart: '2020-03-03 04:00', myStart: '2020-03-03 04:00',
@@ -139,16 +132,16 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#2e74a3', backgroundColor: '#2e74a3',
bundle: 'blueBundle', bundle: 'blueBundle'
}, }
}, },
{ {
myStart: '2020-03-03 18:00', myStart: '2020-03-03 18:00',
myEnd: '2020-03-03 22:00', myEnd: '2020-03-03 22:00',
label: 'Bar', label: 'Bar',
ganttBarConfig: { color: 'white', backgroundColor: '#aa34a3' }, ganttBarConfig: { color: 'white', backgroundColor: '#aa34a3' }
}, }
], ]
}, },
{ {
label: 'Row #3', label: 'Row #3',
@@ -160,8 +153,8 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#de3b26', backgroundColor: '#de3b26',
bundle: 'redBundle', bundle: 'redBundle'
}, }
}, },
{ {
myStart: '2020-03-02 22:30', myStart: '2020-03-02 22:30',
@@ -170,8 +163,8 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#a23def', backgroundColor: '#a23def',
handles: true, handles: true
}, }
}, },
{ {
myStart: '2020-03-02 01:00', myStart: '2020-03-02 01:00',
@@ -181,8 +174,8 @@ export default {
color: 'white', color: 'white',
backgroundColor: '#5effad', backgroundColor: '#5effad',
pushOnOverlap: false, pushOnOverlap: false,
zIndex: 2, zIndex: 2
}, }
}, },
{ {
myStart: '2020-03-03 14:00', myStart: '2020-03-03 14:00',
@@ -191,10 +184,10 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
background: background:
'repeating-linear-gradient(45deg,#de7359,#de7359 10px,#ffc803 10px,#ffc803 20px)', 'repeating-linear-gradient(45deg,#de7359,#de7359 10px,#ffc803 10px,#ffc803 20px)'
}, }
}, }
], ]
}, },
{ {
label: 'Row #4', label: 'Row #4',
@@ -206,8 +199,8 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#d18aaf', backgroundColor: '#d18aaf',
handles: true, handles: true
}, }
}, },
{ {
myStart: '2020-03-02 00:30', myStart: '2020-03-02 00:30',
@@ -216,12 +209,12 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#f2840f', backgroundColor: '#f2840f',
borderRadius: 0, borderRadius: 0
}, }
}, }
], ]
}, }
], ]
}, },
chart2: { chart2: {
chartStart: '2020-03-01 00:00', chartStart: '2020-03-01 00:00',
@@ -240,7 +233,7 @@ export default {
'2020-03-08', '2020-03-08',
'2020-03-15', '2020-03-15',
'2020-03-22', '2020-03-22',
'2020-03-29', '2020-03-29'
], ],
selectedTheme: 'vue', // 'default', 'vue', 'dark', 'material-blue', 'creamy', 'slumber', 'sky', 'crimson', 'grove', 'fuchsia', 'flare' selectedTheme: 'vue', // 'default', 'vue', 'dark', 'material-blue', 'creamy', 'slumber', 'sky', 'crimson', 'grove', 'fuchsia', 'flare'
width: '1100px', width: '1100px',
@@ -257,10 +250,10 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#2e74a3', backgroundColor: '#2e74a3',
bundle: 'blueBundle', bundle: 'blueBundle'
}, }
}, }
], ]
}, },
{ {
label: 'Row #2', label: 'Row #2',
@@ -272,8 +265,8 @@ export default {
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#2e74a3', backgroundColor: '#2e74a3',
bundle: 'blueBundle', bundle: 'blueBundle'
}, }
}, },
{ {
start: '2020-03-24 00:00', start: '2020-03-24 00:00',
@@ -281,10 +274,10 @@ export default {
label: 'Bar', label: 'Bar',
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#de3b26', backgroundColor: '#de3b26'
}, }
}, }
], ]
}, },
{ {
label: 'Row #3', label: 'Row #3',
@@ -295,41 +288,43 @@ export default {
label: 'Bar', label: 'Bar',
ganttBarConfig: { ganttBarConfig: {
color: 'white', color: 'white',
backgroundColor: '#408e2f', backgroundColor: '#408e2f'
}, }
}, }
], ]
}, },
{ {
label: label:
'Lorem ipsum dolor sit amet. Vel odit debitis qui aliquam sequi et reprehenderit Quis. Et ipsam enim aut culpa quia sed maiores veniam in consequuntur accusantium.', 'Lorem ipsum dolor sit amet. Vel odit debitis qui aliquam sequi et reprehenderit Quis. Et ipsam enim aut culpa quia sed maiores veniam in consequuntur accusantium.',
bars: [], bars: []
}, },
{ {
label: 'Row #5', label: 'Row #5',
bars: [], bars: []
}, },
{ {
label: 'Row #6', label: 'Row #6',
bars: [], bars: []
}, },
{ {
label: 'Row #7', label: 'Row #7',
bars: [], bars: []
}, },
{ {
label: 'Row #8', label: 'Row #8',
bars: [], bars: []
}, }
], ]
}, }
}), }),
methods: { methods: {
onDragend(e) { onDragend(e) {
let { event, bar } = e let { event, bar } = e
console.log('onDragend', { event: event.type, bar }) console.log('onDragend', { event: event.type, bar })
}, }
}, }
} }
</script> </script>
<style lang="scss" src="../lib/scss/vue-ganttastic.scss"></style>
-4
View File
@@ -1,4 +0,0 @@
import GGanttChart from '@/components/GGanttChart.vue'
import GGanttRow from '@/components/GGanttRow.vue'
export { GGanttChart, GGanttRow }
+6 -2
View File
@@ -1,8 +1,12 @@
import Vue from 'vue' import Vue from 'vue'
import App from './demo/App.vue' import App from './App.vue'
import { GGanttChart, GGanttRow } from '../lib'
Vue.component('GGanttChart', GGanttChart)
Vue.component('GGanttRow', GGanttRow)
Vue.config.productionTip = false Vue.config.productionTip = false
new Vue({ new Vue({
render: h => h(App), render: h => h(App)
}).$mount('#app') }).$mount('#app')
+7 -4
View File
@@ -1,14 +1,17 @@
const isBuildLib =
(process.env.npm_lifecycle_script || '').indexOf('--target lib') > 0
module.exports = { module.exports = {
publicPath: '', publicPath: '',
outputDir: process.env.NODE_ENV === 'production' ? 'dist/' : 'demo/', outputDir: isBuildLib ? 'dist' : 'demo',
css: { extract: false }, css: { extract: true },
productionSourceMap: false, productionSourceMap: false,
chainWebpack: config => { chainWebpack: config => {
if (process.env.VUE_CLI_BUILD_TARGET === 'lib') { if (process.env.VUE_CLI_BUILD_TARGET === 'lib') {
config.externals({ config.externals({
...config.get('externals'), ...config.get('externals'),
moment: 'moment', moment: 'moment'
}) })
} }
}, }
} }