table-schedule
Version:
Vanilla JS table schedule with DnD support.
209 lines (208 loc) • 4.65 kB
CSS
.table-schedule {
font-size: 12px;
min-width: 100%;
table-layout: fixed;
border-collapse: separate;
border-spacing: 0;
background-color: #fff;
}
.table-schedule * {
box-sizing: border-box;
}
.table-schedule table {
width: 100%;
border-spacing: 0;
border-collapse: collapse;
}
.table-schedule td, .table-schedule th {
padding: 0;
}
.table-schedule > thead > tr > td, .table-schedule > thead > tr > th {
text-align: center;
position: sticky;
top: 0;
background-color: #f8f8f8;
border-bottom: 1px solid #888;
border-right: 1px solid #888;
z-index: 1;
}
.table-schedule > thead > tr > td > div, .table-schedule > thead > tr > th > div {
padding: 5px;
}
.table-schedule > thead > tr > td .group-header th, .table-schedule > thead > tr > th .group-header th {
width: 80px;
border-top: 1px solid #aaa;
padding: 2px;
text-align: center;
}
.table-schedule > thead > tr > td .group-header th > div, .table-schedule > thead > tr > th .group-header th > div {
height: 20px;
overflow: hidden;
word-break: break-all;
}
.table-schedule > thead > tr > td .group-header th + th, .table-schedule > thead > tr > th .group-header th + th {
border-left: 1px solid #aaa;
}
.table-schedule > thead > tr > td:first-child, .table-schedule > thead > tr > th:first-child {
left: 0;
z-index: 2;
}
.table-schedule > tbody > tr > td, .table-schedule > tbody > tr > th {
border-bottom: 1px solid #888;
border-right: 1px solid #888;
}
.table-schedule .time-line-wrapper {
position: sticky;
left: 0;
background-color: #f8f8f8;
z-index: 1;
}
.table-schedule .time-line-wrapper .time-line th {
height: 20px;
border-bottom: 1px solid #eaeaea;
padding: 0 3px;
}
.table-schedule .time-line-wrapper .time-line tr:last-child > th {
border-bottom: none;
}
.table-schedule .time-line-wrapper .time-line th > div {
max-height: 20px;
overflow: hidden;
}
.table-schedule .day-col {
position: relative;
}
.table-schedule .day-col.drop-target:before {
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(104, 207, 255, 0.4);
}
.table-schedule .day-col .day-grid {
user-select: none;
table-layout: fixed;
}
.table-schedule .day-col .day-grid th, .table-schedule .day-col .day-grid td {
border: 1px solid #eaeaea;
}
.table-schedule .day-col .day-grid tr .grid-cell {
width: 80px;
height: 20px;
}
.table-schedule .day-col .day-grid tr > td:first-child {
border-left: none;
}
.table-schedule .day-col .day-grid tr > td:last-child {
border-right: none;
}
.table-schedule .day-col .day-grid tr:first-child > td {
border-top: none;
}
.table-schedule .day-col .day-grid tr:last-child > td {
border-bottom: none;
}
.table-schedule .day-col .events-container {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
display: flex;
}
.table-schedule .day-col .events-container .events-col {
flex: 1;
height: 100%;
position: relative;
}
.event {
position: absolute;
width: 100%;
background-color: #68cfff;
border: 1px solid #02afff;
border-radius: 3px;
touch-action: none;
}
.event.drawing {
opacity: 0.5;
}
.event .event-content-wrapper {
height: 100%;
overflow: auto;
}
.event .event-content-wrapper .event-title {
font-weight: bold;
padding: 5px 5px 0;
}
.event .event-content-wrapper .event-content {
padding: 5px;
word-break: break-word;
}
.event .event-bar-wrapper {
position: absolute;
bottom: 2px;
width: 100%;
}
.event .event-bar-wrapper .event-bar {
opacity: 0;
display: block;
margin: auto;
width: 20px;
height: 5px;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 2px;
cursor: ns-resize;
}
.event .event-bar-wrapper .event-bar:hover {
opacity: 1;
}
.event.event-red {
background-color: #f44336;
color: #fff;
border-color: #ba160a;
}
.event.event-pink {
background-color: #e91e63;
color: #fff;
border-color: #930e3b;
}
.event.event-purple {
background-color: #9c27b0;
color: #fff;
border-color: #52145d;
}
.event.event-indigo {
background-color: #3f51b5;
color: #fff;
border-color: #252f69;
}
.event.event-blue {
background-color: #2196f3;
color: #fff;
border-color: #0960a5;
}
.event.event-teal {
background-color: #009688;
color: #fff;
border-color: #00302c;
}
.event.event-green {
background-color: #4caf50;
color: #fff;
border-color: #2d682f;
}
.event.event-yellow {
background-color: #ffeb3b;
border-color: #d4be00;
}
.event.event-orange {
background-color: #ff9800;
color: #fff;
border-color: #995b00;
}
.event.event-brown {
background-color: #795548;
color: #fff;
border-color: #392822;
}