Skip to content

Commit fae9624

Browse files
committed
chore(explore): tweak styling for space tooltip
1 parent 811add4 commit fae9624

File tree

1 file changed

+44
-23
lines changed

1 file changed

+44
-23
lines changed

libs/explore/src/lib/explore-space-info.component.ts

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { DatePipe, UpperCasePipe } from '@angular/common';
2-
import { Component, ElementRef, inject, OnInit, signal } from '@angular/core';
2+
import {
3+
Component,
4+
computed,
5+
ElementRef,
6+
inject,
7+
OnInit,
8+
signal,
9+
} from '@angular/core';
310
import {
411
AsyncHandler,
512
CalendarEvent,
@@ -9,6 +16,7 @@ import {
916
} from '@placeos/common';
1017
import { IconComponent } from '@placeos/components';
1118
import { UserPipe } from '@placeos/users';
19+
import { isSameDay } from 'date-fns';
1220

1321
import { AuthenticatedImageDirective } from 'libs/components/src/lib/authenticated-image.directive';
1422
import { CustomTooltipComponent } from 'libs/components/src/lib/custom-tooltip.component';
@@ -38,7 +46,6 @@ export interface SpaceInfoData {
3846
[xPosition]="'center'"
3947
[yPosition]="'center'"
4048
[hover]="true"
41-
[delay]="3000"
4249
[attr.id]="space?.map_id || space?.id"
4350
(mouseenter)="updateOffset()"
4451
class="pointer-events-auto relative hidden h-full w-full cursor-pointer sm:block"
@@ -47,7 +54,7 @@ export interface SpaceInfoData {
4754
<div
4855
name="space-info"
4956
[id]="space?.id"
50-
class="pointer-events-none absolute left-0 top-0 w-64 transform overflow-hidden rounded bg-base-100 shadow"
57+
class="pointer-events-none absolute left-0 top-0 w-64 transform overflow-hidden rounded border border-base-300 bg-base-100 shadow"
5158
[class.-translate-x-full]="x_pos === 'end'"
5259
[class.-translate-y-full]="y_pos === 'bottom'"
5360
>
@@ -67,7 +74,7 @@ export interface SpaceInfoData {
6774
/>
6875
} @else {
6976
<div
70-
class="absolute inset-0 bg-neutral opacity-30"
77+
class="absolute inset-0 bg-base-200 opacity-30"
7178
></div>
7279
}
7380
</div>
@@ -96,23 +103,6 @@ export interface SpaceInfoData {
96103
<h4 class="mb-2 px-2 text-xl font-medium">
97104
{{ space.display_name || space.name }}
98105
</h4>
99-
@if (next()) {
100-
<div
101-
class="mb-1 flex items-center space-x-2 px-2 text-base"
102-
>
103-
<icon>alarm</icon>
104-
<div>
105-
Free
106-
{{ next().date > now() ? 'until' : 'at' }}
107-
{{
108-
(next().date > now()
109-
? next().date
110-
: next().date_end
111-
) | date: 'shortTime'
112-
}}
113-
</div>
114-
</div>
115-
}
116106
@if (space.capacity >= 0) {
117107
<div
118108
capacity
@@ -145,13 +135,36 @@ export interface SpaceInfoData {
145135
}
146136
@if (show_event_details() && next()) {
147137
@let host = next().host | user;
148-
<div class="rounded-xl border border-base-300 p-2">
138+
<div class="rounded px-2 pb-1 text-xs opacity-30">
139+
{{ current() ? 'Current' : 'Upcoming' }}
140+
booking
141+
</div>
142+
<div
143+
class="mb-1 flex flex-col rounded-lg border border-base-300 p-2"
144+
>
149145
<h3>{{ next().title }}</h3>
150146
<div class="text-xs opacity-50">
151147
{{ host?.name || next().host }}
152148
</div>
153149
</div>
154150
}
151+
@if (next()) {
152+
<div
153+
class="mt-1 flex items-center space-x-2 px-2 text-base"
154+
>
155+
<icon>alarm</icon>
156+
<div>
157+
Free
158+
{{ next().date > now() ? 'until' : 'at' }}
159+
{{
160+
(next().date > now()
161+
? next().date
162+
: next().date_end
163+
) | date: 'shortTime'
164+
}}
165+
</div>
166+
</div>
167+
}
155168
</div>
156169
</div>
157170
</div>
@@ -204,6 +217,12 @@ export class ExploreSpaceInfoComponent extends AsyncHandler implements OnInit {
204217
public readonly now = signal(Date.now());
205218
/** List of upcoming events for space */
206219
public readonly next = signal<CalendarEvent>(null);
220+
public readonly current = computed(() =>
221+
this.next()
222+
? this.next()?.date <= Date.now() &&
223+
this.next()?.date_end > Date.now()
224+
: false,
225+
);
207226
/** Whether the event details should be display on the tooltip */
208227
public readonly show_event_details = settingSignal(
209228
'explore.show_event_details',
@@ -221,7 +240,9 @@ export class ExploreSpaceInfoComponent extends AsyncHandler implements OnInit {
221240
this.timeout('update_offset', () => this.updateOffset(), 200);
222241
const events = this.events
223242
.sort((a, b) => a.date - b.date)
224-
.filter((i) => i.date_end > Date.now());
243+
.filter(
244+
(i) => i.date_end > Date.now() && isSameDay(i.date, Date.now()),
245+
);
225246
this.next.set(events[0]);
226247
this.interval('time', () => this.now.set(Date.now()), 5000);
227248
}

0 commit comments

Comments
 (0)