ywana-core8 0.0.938 → 0.0.940

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.938",
3
+ "version": "0.0.940",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -118,7 +118,7 @@ export const TextArea = (props) => {
118
118
  export const DropDown = (props) => {
119
119
 
120
120
  const site = useContext(SiteContext)
121
- const { id, options = [], value, onChange, predictive = false, readOnly = false, verbose = true, editable = false, onBlur, position="bottom"} = props
121
+ const { id, options = [], value, onChange, predictive = false, readOnly = false, verbose = true, editable = false, onBlur, position="bottom", className} = props
122
122
  const [open, setOpen] = useState(false)
123
123
  const [label, setLabel] = useState()
124
124
 
@@ -193,7 +193,7 @@ export const DropDown = (props) => {
193
193
 
194
194
  const title = editable ? <div className='row'>{props.label}<Icon className="decorator" icon="edit" size="small" /></div> : props.label
195
195
  return (
196
- <div className="dropdown">
196
+ <div className={`dropdown ${className}`}>
197
197
  <TextField {...props} label={title} onClick={onFocus} value={label} onChange={change} onBlur={blur} readOnly={!predictive && !editable} />
198
198
  {!readOnly ? <Icon icon="expand_more" clickable size="small" action={toggle} /> : null}
199
199
  {renderOptions()}
@@ -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;
@@ -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
- <div className='day-cell' style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`day_${month}-${day}`}>
68
- <div className="weekday">{weekday.substring(0, 2)}</div>
69
- <div className="daynum">{day}</div>
70
- </div>
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="content-cell" style={{ minWidth: dayWidth, maxWidth: dayWidth }} key={`content${index}_${year}-${month}-${day}`} onClick={() => selectCell({ lane:lane.id, date: dayDate })}>
91
- {dayEvents.map((event, index) => <EventRenderer key={`${event.id}-${index}`} event={event} />)}
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: "2023-01-04", color: "yellow", title: "Event One" },
133
- { id: "1", lane: "1", date: "2023-01-04", color: "yellow", title: "Event One" },
134
- { id: "1", lane: "1", date: "2023-01-05", color: "yellow", title: "Event One" },
135
- { id: "2", lane: "1", date: "2023-01-05", color: "red", title: "Event One" },
136
- { id: "3", lane: "1", date: "2023-01-05", color: "blue", title: "Event One" },
137
- { id: "4", lane: "1", date: "2023-01-05", color: "red", title: "Event One" },
138
- { id: "5", lane: "2", date: "2023-01-04", color: "yellow", title: "Event One" },
139
- { id: "6", lane: "2", date: "2023-01-05", color: "red", title: "Event One" },
140
- { id: "7", lane: "2", date: "2023-01-06", color: "blue", title: "Event One" },
141
- { id: "8", lane: "2", date: "2023-01-07", color: "red", title: "Event One" },
142
- { id: "9", lane: "3", date: "2023-01-04", color: "yellow", title: "Event One" },
143
- { id: "10", lane: "3", date: "2023-01-05", color: "red", title: "Event One" },
144
- { id: "11", lane: "3", date: "2023-01-06", color: "blue", title: "Event One" },
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="2023-01-03" to="2023-01-13" lanes={lanes} events={events} EventRenderer={EventCard} />
170
+ <Planner2 from="2024-01-01" to="2024-12-01" lanes={lanes} events={events} EventRenderer={EventCard} />
150
171
  </>
151
172
  )
152
173
  }