ywana-core8 0.0.938 → 0.0.939
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +19 -0
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +29 -5
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +29 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/incubator/planner.css +19 -0
- package/src/incubator/planner.js +45 -24
package/package.json
CHANGED
@@ -39,6 +39,21 @@
|
|
39
39
|
justify-content: center;
|
40
40
|
}
|
41
41
|
|
42
|
+
.day-cell.current-week {
|
43
|
+
border-bottom: solid 2px var(--accent-color);
|
44
|
+
}
|
45
|
+
|
46
|
+
.day-cell.today .daynum {
|
47
|
+
background-color: var(--accent-color);
|
48
|
+
color: var(--accent-color-text);
|
49
|
+
border-radius: 3px;
|
50
|
+
padding: .2rem;
|
51
|
+
}
|
52
|
+
|
53
|
+
.day-cell.weekend {
|
54
|
+
background-color: var(--secondary-color-lighter);
|
55
|
+
}
|
56
|
+
|
42
57
|
.weekday {
|
43
58
|
font-size: .6rem;
|
44
59
|
font-weight: 400;
|
@@ -73,6 +88,10 @@
|
|
73
88
|
background-color: var(--hover-color);
|
74
89
|
}
|
75
90
|
|
91
|
+
.content-cell.weekend {
|
92
|
+
background-color: var(--secondary-color-lighter);
|
93
|
+
}
|
94
|
+
|
76
95
|
.row-header {
|
77
96
|
position: sticky;
|
78
97
|
left: 0px;
|
package/src/incubator/planner.js
CHANGED
@@ -5,26 +5,41 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
5
5
|
|
6
6
|
const [days, setDays] = useState([]);
|
7
7
|
const lastDay = new Date(to);
|
8
|
+
const today = new Date();
|
8
9
|
|
9
10
|
useEffect(() => {
|
10
11
|
const day = new Date(from);
|
11
12
|
const nextDays = [];
|
12
13
|
while (day <= lastDay) {
|
14
|
+
const isToday = day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear();
|
15
|
+
const isWeekend = day.getDay() === 0 || day.getDay() === 6;
|
13
16
|
nextDays.push({
|
14
17
|
day: day.getDate(),
|
15
18
|
weekday: day.toLocaleString('en-US', { weekday: 'short' }),
|
16
19
|
month: day.toLocaleString('en-US', { month: 'short' }),
|
17
20
|
monthNum: day.getMonth() + 1,
|
18
21
|
year: day.getFullYear(),
|
22
|
+
isToday,
|
23
|
+
isWeekend,
|
24
|
+
isInCurrentWeek: isInCurrentWeek(day)
|
19
25
|
});
|
20
26
|
day.setDate(day.getDate() + 1);
|
21
27
|
}
|
22
28
|
setDays(nextDays);
|
23
29
|
}, [from, to])
|
24
30
|
|
31
|
+
function isInCurrentWeek(date) {
|
32
|
+
const today = new Date();
|
33
|
+
const first = today.getDate() - today.getDay();
|
34
|
+
const last = first + 5;
|
35
|
+
const firstDay = new Date(today.setDate(first));
|
36
|
+
const lastDay = new Date(today.setDate(last));
|
37
|
+
return date >= firstDay && date <= lastDay;
|
38
|
+
}
|
39
|
+
|
25
40
|
function selectCell(cell) {
|
26
41
|
if (onSelectCell) onSelectCell(cell)
|
27
|
-
}
|
42
|
+
}
|
28
43
|
|
29
44
|
const uniqueMonths = Array.from(
|
30
45
|
new Set(days.map(({ month }) => month))
|
@@ -63,12 +78,17 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
63
78
|
<div className="days-row" style={{ display: 'flex', width: `${totalDaysWidth}rem` }}>
|
64
79
|
<div className="row-header" style={{ minWidth: `${rowHeaderWidth}rem`, maxWidth: `${rowHeaderWidth}rem` }}>
|
65
80
|
</div>
|
66
|
-
{days.map(({ day, weekday, month }) =>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
81
|
+
{days.map(({ day, weekday, month, isToday = false, isWeekend = false, isInCurrentWeek }) => {
|
82
|
+
const todayClass = isToday ? 'today' : '';
|
83
|
+
const weekendClass = isWeekend ? 'weekend' : '';
|
84
|
+
const currentWeekClass = isInCurrentWeek ? 'current-week' : '';
|
85
|
+
return (
|
86
|
+
<div className={`day-cell ${todayClass} ${weekendClass} ${currentWeekClass}`} style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`day_${month}-${day}`}>
|
87
|
+
<div className="weekday">{weekday.substring(0, 2)}</div>
|
88
|
+
<div className="daynum">{day}</div>
|
89
|
+
</div>
|
90
|
+
)
|
91
|
+
})}
|
72
92
|
</div>
|
73
93
|
|
74
94
|
{lanes.map((lane, index) => {
|
@@ -78,7 +98,7 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
78
98
|
<div className="row-header" style={{ minWidth: `${rowHeaderWidth}rem`, maxWidth: `${rowHeaderWidth}rem` }} >
|
79
99
|
{lane.title}
|
80
100
|
</div>
|
81
|
-
{days.map(({ day, weekday, month, monthNum, year }) => {
|
101
|
+
{days.map(({ day, weekday, month, monthNum, year, isWeekend }) => {
|
82
102
|
const dayDate = new Date(year, monthNum - 1, day);
|
83
103
|
const dayEvents = laneEvents.filter((event) => {
|
84
104
|
const eventDate = new Date(event.date);
|
@@ -86,9 +106,10 @@ export const Planner2 = ({ from, to, lanes = [], events = [], cellWidth = 10, ro
|
|
86
106
|
eventDate.getMonth() === dayDate.getMonth() &&
|
87
107
|
eventDate.getFullYear() === dayDate.getFullYear();
|
88
108
|
});
|
109
|
+
const weekendClass = isWeekend ? 'weekend' : '';
|
89
110
|
return (
|
90
|
-
<div className=
|
91
|
-
|
111
|
+
<div className={`content-cell ${weekendClass}`} style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`content${index}_${year}-${month}-${day}`} onClick={() => selectCell({ lane: lane.id, date: dayDate })}>
|
112
|
+
{dayEvents.map((event, index) => <EventRenderer key={`${event.id}-${index}`} event={event} />)}
|
92
113
|
</div>
|
93
114
|
)
|
94
115
|
})}
|
@@ -129,24 +150,24 @@ const CalendarTest = (props) => {
|
|
129
150
|
]
|
130
151
|
|
131
152
|
const events = [
|
132
|
-
{ id: "1", lane: "1", date: "
|
133
|
-
{ id: "1", lane: "1", date: "
|
134
|
-
{ id: "1", lane: "1", date: "
|
135
|
-
{ id: "2", lane: "1", date: "
|
136
|
-
{ id: "3", lane: "1", date: "
|
137
|
-
{ id: "4", lane: "1", date: "
|
138
|
-
{ id: "5", lane: "2", date: "
|
139
|
-
{ id: "6", lane: "2", date: "
|
140
|
-
{ id: "7", lane: "2", date: "
|
141
|
-
{ id: "8", lane: "2", date: "
|
142
|
-
{ id: "9", lane: "3", date: "
|
143
|
-
{ id: "10", lane: "3", date: "
|
144
|
-
{ id: "11", lane: "3", date: "
|
153
|
+
{ id: "1", lane: "1", date: "2024-01-04", color: "yellow", title: "Event One" },
|
154
|
+
{ id: "1", lane: "1", date: "2024-01-04", color: "yellow", title: "Event One" },
|
155
|
+
{ id: "1", lane: "1", date: "2024-01-05", color: "yellow", title: "Event One" },
|
156
|
+
{ id: "2", lane: "1", date: "2024-01-05", color: "red", title: "Event One" },
|
157
|
+
{ id: "3", lane: "1", date: "2024-01-05", color: "blue", title: "Event One" },
|
158
|
+
{ id: "4", lane: "1", date: "2024-01-05", color: "red", title: "Event One" },
|
159
|
+
{ id: "5", lane: "2", date: "2024-01-04", color: "yellow", title: "Event One" },
|
160
|
+
{ id: "6", lane: "2", date: "2024-01-05", color: "red", title: "Event One" },
|
161
|
+
{ id: "7", lane: "2", date: "2024-01-06", color: "blue", title: "Event One" },
|
162
|
+
{ id: "8", lane: "2", date: "2024-01-07", color: "red", title: "Event One" },
|
163
|
+
{ id: "9", lane: "3", date: "2024-01-04", color: "yellow", title: "Event One" },
|
164
|
+
{ id: "10", lane: "3", date: "2024-01-05", color: "red", title: "Event One" },
|
165
|
+
{ id: "11", lane: "3", date: "2024-01-06", color: "blue", title: "Event One" },
|
145
166
|
]
|
146
167
|
|
147
168
|
return (
|
148
169
|
<>
|
149
|
-
<Planner2 from="
|
170
|
+
<Planner2 from="2024-01-01" to="2024-12-01" lanes={lanes} events={events} EventRenderer={EventCard} />
|
150
171
|
</>
|
151
172
|
)
|
152
173
|
}
|