Skip to content

Commit 26d998a

Browse files
authored
HR: update schedule layout (#2202)
1 parent 1976486 commit 26d998a

File tree

3 files changed

+80
-28
lines changed

3 files changed

+80
-28
lines changed

packages/theme/styles/components.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,13 @@
434434
&:hover { background-color: var(--highlight-select-hover); }
435435
}
436436
}
437+
}
437438

438-
.scroller-thead {
439-
position: sticky;
440-
top: 0;
441-
z-index: 2;
442-
background-color: var(--body-color);
443-
}
439+
.scroller-thead {
440+
position: sticky;
441+
top: 0;
442+
z-index: 2;
443+
background-color: var(--body-color);
444444
}
445445

446446
// THead background-color in Tooltip and Popups

plugins/hr-resources/src/components/Schedule.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,4 @@
119119
<SpaceSelector _class={hr.class.Department} label={hr.string.Department} bind:space={department} />
120120
</div>
121121

122-
<div class="mr-6 h-full">
123-
<ScheduleMonthView {department} {descendants} departmentById={departments} {currentDate} {mode} />
124-
</div>
122+
<ScheduleMonthView {department} {descendants} departmentById={departments} {currentDate} {mode} />

plugins/hr-resources/src/components/ScheduleView.svelte

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -189,47 +189,60 @@
189189
}
190190
return total
191191
}
192+
193+
let hoveredIndex: number = -1
192194
</script>
193195

194196
{#if departmentStaff.length}
195-
<Scroller>
197+
<Scroller tableFade>
196198
<table>
197199
<thead class="scroller-thead">
198200
<tr class="scroller-thead__tr">
199201
<th>
200202
<Label label={contact.string.Employee} />
201203
</th>
202-
{#each values as value}
204+
{#each values as value, i}
203205
{#if mode === CalendarMode.Year}
204206
{@const month = getMonth(currentDate, value)}
205207
<th
206208
class="fixed"
207209
class:today={month.getFullYear() === todayDate.getFullYear() &&
208210
month.getMonth() === todayDate.getMonth()}
211+
on:mousemove={() => {
212+
hoveredIndex = i
213+
}}
214+
on:mouseleave={() => {
215+
hoveredIndex = -1
216+
}}
209217
>
210-
<div class="cursor-pointer uppercase flex-col-center">
211-
<div class="flex-center">{getMonthName(month)}</div>
212-
</div>
218+
{getMonthName(month)}
213219
</th>
214220
{:else}
215221
{@const day = getDay(new Date(startDate), value)}
216-
<th class:today={areDatesEqual(todayDate, day)} class:weekend={isWeekend(day)}>
217-
<div class="cursor-pointer uppercase flex-col-center">
218-
<div class="flex-center">{getWeekDayName(day, 'short')}</div>
219-
<div class="flex-center">{day.getDate()}</div>
220-
</div>
222+
<th
223+
class:today={areDatesEqual(todayDate, day)}
224+
class:weekend={isWeekend(day)}
225+
on:mousemove={() => {
226+
hoveredIndex = i
227+
}}
228+
on:mouseleave={() => {
229+
hoveredIndex = -1
230+
}}
231+
>
232+
{getWeekDayName(day, 'short')}
233+
<span>{day.getDate()}</span>
221234
</th>
222235
{/if}
223236
{/each}
224237
</tr>
225238
</thead>
226239
<tbody>
227-
{#each departmentStaff as employee}
240+
{#each departmentStaff as employee, row}
228241
<tr>
229242
<td>
230243
<EmployeePresenter value={employee} />
231244
</td>
232-
{#each values as value}
245+
{#each values as value, i}
233246
{#if mode === CalendarMode.Year}
234247
{@const month = getMonth(currentDate, value)}
235248
{@const requests = getRequests(employee._id, month)}
@@ -256,6 +269,9 @@
256269
class:today={areDatesEqual(todayDate, date)}
257270
class:weekend={isWeekend(date)}
258271
class:cursor-pointer={editable}
272+
class:hovered={i === hoveredIndex}
273+
class:firstLine={row === 0}
274+
class:lastLine={row === departmentStaff.length - 1}
259275
use:tooltip={tooltipValue}
260276
on:click={(e) => createRequest(e, date, employee)}
261277
>
@@ -272,38 +288,52 @@
272288
</table>
273289
</Scroller>
274290
{:else}
275-
<div class="flex-center h-full flex-grow fs-title">
291+
<div class="flex-center h-full w-full flex-grow fs-title">
276292
<Label label={hr.string.NoEmployeesInDepartment} />
277293
</div>
278294
{/if}
279295

280296
<style lang="scss">
281297
table {
282-
border-collapse: collapse;
283-
table-layout: fixed;
284-
width: auto;
285298
position: relative;
299+
width: 100%;
286300
287301
td,
288302
th {
289303
width: auto;
290-
min-width: 1rem;
304+
width: 2rem;
305+
min-width: 1.5rem;
306+
border: none;
291307
&.fixed {
292308
width: 5rem;
309+
padding: 0 0.125rem;
310+
hyphens: auto;
293311
}
294312
&:first-child {
295313
width: 15rem;
296314
padding: 0.5rem;
297315
}
298316
}
299317
th {
300-
padding: 0.5rem;
318+
flex-shrink: 0;
319+
padding: 0;
301320
height: 2.5rem;
321+
min-height: 2.5rem;
322+
max-height: 2.5rem;
323+
text-transform: uppercase;
302324
font-weight: 500;
303325
font-size: 0.75rem;
326+
line-height: 105%;
304327
color: var(--dark-color);
305328
box-shadow: inset 0 -1px 0 0 var(--divider-color);
306329
user-select: none;
330+
cursor: pointer;
331+
332+
span {
333+
display: block;
334+
font-weight: 600;
335+
font-size: 1rem;
336+
}
307337
&.today {
308338
color: var(--caption-color);
309339
}
@@ -313,7 +343,7 @@
313343
}
314344
td {
315345
height: 3.5rem;
316-
border: 1px solid var(--divider-color);
346+
border: none;
317347
color: var(--caption-color);
318348
&.today {
319349
background-color: var(--theme-bg-accent-hover);
@@ -322,5 +352,29 @@
322352
background-color: var(--theme-bg-accent-color);
323353
}
324354
}
355+
td:not(:last-child) {
356+
border-right: 1px solid var(--divider-color);
357+
}
358+
tr:not(.scroller-thead__tr) {
359+
border-bottom: 1px solid var(--divider-color);
360+
}
361+
tr.scroller-thead__tr:not(:last-child) {
362+
border-right: 1px solid var(--divider-color);
363+
}
364+
365+
.hovered {
366+
position: relative;
367+
368+
&::after {
369+
position: absolute;
370+
content: '';
371+
top: 0;
372+
left: 0;
373+
width: 100%;
374+
height: 100%;
375+
background-color: var(--caption-color);
376+
opacity: 0.15;
377+
}
378+
}
325379
}
326380
</style>

0 commit comments

Comments
 (0)