20 changed files with 2002 additions and 197 deletions
@ -0,0 +1,75 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { createNgModule, inject, Injectable, Injector, signal, untracked } from '@angular/core'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { MatDialog } from '@angular/material/dialog'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { getCurrentAuthState, getCurrentUserSettings } from '@core/auth/auth.selectors'; |
|||
import { Authority } from '@shared/models/authority.enum'; |
|||
import { UserPermissionsService } from '@core/http/user-permissions.service'; |
|||
import { Operation, Resource } from '@shared/models/security.models'; |
|||
import { AiTourStep } from '@shared/models/user-settings.models'; |
|||
import { AiChatsService } from '@core/services/ai-chats.service'; |
|||
|
|||
export interface TourLauncherApi { |
|||
welcome(): void; |
|||
assistantTour(): Promise<void>; |
|||
} |
|||
|
|||
const OFFER_DELAY_MS = 1200; |
|||
|
|||
@Injectable({providedIn: 'root'}) |
|||
export class TourService { |
|||
|
|||
readonly active = signal(false); |
|||
|
|||
private store = inject(Store<AppState>); |
|||
private injector = inject(Injector); |
|||
private userPermissions = inject(UserPermissionsService); |
|||
private chats = inject(AiChatsService); |
|||
private dialog = inject(MatDialog); |
|||
|
|||
private launcher: Promise<TourLauncherApi> | null = null; |
|||
|
|||
private offered = false; |
|||
|
|||
aiAvailable(): boolean { |
|||
const authState = getCurrentAuthState(this.store); |
|||
return !!authState?.aiEnabled && authState.authUser?.authority === Authority.TENANT_ADMIN |
|||
&& this.userPermissions.hasGenericPermission(Resource.AI, Operation.ALL); |
|||
} |
|||
|
|||
offerWelcome(): void { |
|||
if (this.offered || !this.aiAvailable() || this.seen(AiTourStep.WELCOME)) { |
|||
return; |
|||
} |
|||
this.offered = true; |
|||
this.chats.watchStatus(); |
|||
setTimeout(() => { |
|||
if (this.active() || this.seen(AiTourStep.WELCOME) || this.dialog.openDialogs.length |
|||
|| untracked(this.chats.statusChats).some(chat => this.chats.levelOf(chat) === 'running')) { |
|||
this.offered = false; |
|||
return; |
|||
} |
|||
this.load().then(launcher => launcher.welcome()); |
|||
}, OFFER_DELAY_MS); |
|||
} |
|||
|
|||
playAssistantTour(): void { |
|||
if (this.aiAvailable() && !this.active()) { |
|||
this.load().then(launcher => launcher.assistantTour()); |
|||
} |
|||
} |
|||
|
|||
private seen(step: AiTourStep): boolean { |
|||
return !!getCurrentUserSettings(this.store)?.aiTour?.[step]; |
|||
} |
|||
|
|||
private load(): Promise<TourLauncherApi> { |
|||
if (!this.launcher) { |
|||
this.launcher = import('@modules/tour/tour.module').then(m => createNgModule(m.TourModule, this.injector).injector.get(m.TourLauncher)); |
|||
this.launcher.catch(() => this.launcher = null); |
|||
} |
|||
return this.launcher; |
|||
} |
|||
} |
|||
@ -1,39 +0,0 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-ai-button-intro', |
|||
template: ` |
|||
<div class="tb-ai-intro" data-ai role="status" aria-labelledby="tb-ai-intro-title"> |
|||
<h3 class="tb-ai-intro-title" id="tb-ai-intro-title">{{ title }}</h3> |
|||
<button mat-icon-button type="button" class="tb-ai-intro-x" [attr.aria-label]="'action.close' | translate" (click)="dismiss.emit()"> |
|||
<mat-icon fontSet="material-icons-round">close</mat-icon> |
|||
</button> |
|||
<p class="tb-ai-intro-body"> |
|||
{{ lead }} |
|||
@if (keyboard) { |
|||
{{ 'ai-assistant.intro.press' | translate }} <kbd>/</kbd> {{ 'ai-assistant.intro.on-any-page' | translate }} |
|||
} |
|||
</p> |
|||
<div class="tb-ai-intro-actions"> |
|||
<button mat-button type="button" class="tb-ai-intro-skip" (click)="dismiss.emit()">{{ 'ai-assistant.intro.got-it' | translate }}</button> |
|||
<button mat-flat-button type="button" class="tb-ai-intro-go" (click)="openChat.emit()">{{ 'ai-assistant.intro.open-chat' | translate }}</button> |
|||
</div> |
|||
</div> |
|||
`,
|
|||
standalone: false, |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class AiButtonIntroComponent { |
|||
|
|||
@Input() title: string; |
|||
|
|||
@Input() lead: string; |
|||
|
|||
@Input() keyboard = false; |
|||
|
|||
@Output() dismiss = new EventEmitter<void>(); |
|||
|
|||
@Output() openChat = new EventEmitter<void>(); |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. |
|||
// SPDX-License-Identifier: BUSL-1.1 |
|||
@property --tb-spot-a { |
|||
syntax: '<angle>'; |
|||
inherits: false; |
|||
initial-value: 0deg; |
|||
} |
|||
|
|||
.tb-tour-layer { |
|||
position: fixed; |
|||
inset: 0; |
|||
z-index: 999; |
|||
pointer-events: auto; |
|||
|
|||
&.through { |
|||
pointer-events: none; |
|||
} |
|||
} |
|||
|
|||
.tb-tour-spot { |
|||
position: fixed; |
|||
border-radius: var(--tb-spot-r, 12px); |
|||
pointer-events: none; |
|||
box-shadow: 0 0 22px 4px color-mix(in oklab, var(--ai-light-aqua) 60%, transparent), 0 0 0 9999px rgba(16, 24, 40, 0.32); |
|||
transition: left .22s cubic-bezier(.2, .7, .3, 1), top .22s cubic-bezier(.2, .7, .3, 1), width .22s cubic-bezier(.2, .7, .3, 1), |
|||
height .22s cubic-bezier(.2, .7, .3, 1), border-radius .22s ease; |
|||
|
|||
&::before { |
|||
content: ''; |
|||
position: absolute; |
|||
inset: -3px; |
|||
padding: 3px; |
|||
border-radius: calc(var(--tb-spot-r, 12px) + 3px); |
|||
background: conic-gradient(from var(--tb-spot-a) in oklab, var(--ai-light-anchor), var(--ai-light-aqua), var(--ai-light-lilac), |
|||
var(--ai-light-peach), var(--ai-light-amber), var(--ai-light-mint), var(--ai-light-anchor)); |
|||
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); |
|||
-webkit-mask-composite: xor; |
|||
mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); |
|||
animation: tb-tour-spot-turn 8s linear infinite; |
|||
} |
|||
|
|||
@media (prefers-reduced-motion: reduce) { |
|||
transition: none; |
|||
|
|||
&::before { |
|||
animation: none; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@keyframes tb-tour-spot-turn { |
|||
to { --tb-spot-a: 360deg; } |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { ChangeDetectionStrategy, Component, inject, Renderer2, signal, ViewContainerRef, ViewEncapsulation } from '@angular/core'; |
|||
|
|||
export interface TourSpot { |
|||
left: number; |
|||
top: number; |
|||
width: number; |
|||
height: number; |
|||
radius: number; |
|||
through: boolean; |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'tb-tour-host', |
|||
template: ` |
|||
@if (spot(); as s) { |
|||
<div class="tb-tour-layer" [class.through]="s.through"> |
|||
<div class="tb-tour-spot" [style.left.px]="s.left" [style.top.px]="s.top" [style.width.px]="s.width" [style.height.px]="s.height" |
|||
[style.--tb-spot-r.px]="s.radius"></div> |
|||
</div> |
|||
} |
|||
`,
|
|||
styleUrls: ['./tour-host.component.scss'], |
|||
encapsulation: ViewEncapsulation.None, |
|||
standalone: false, |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class TourHostComponent { |
|||
|
|||
readonly viewContainerRef = inject(ViewContainerRef); |
|||
|
|||
readonly renderer = inject(Renderer2); |
|||
|
|||
readonly spot = signal<TourSpot | null>(null); |
|||
} |
|||
@ -0,0 +1,309 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { ApplicationRef, ComponentRef, createComponent, EnvironmentInjector, inject, Injectable } from '@angular/core'; |
|||
import { Router } from '@angular/router'; |
|||
import { MatDialog } from '@angular/material/dialog'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { firstValueFrom } from 'rxjs'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { getCurrentAuthState } from '@core/auth/auth.selectors'; |
|||
import { ActionPreferencesUpdateAiTour } from '@core/auth/auth.actions'; |
|||
import { AiTourStep } from '@shared/models/user-settings.models'; |
|||
import { TourLauncherApi, TourService } from '@core/services/tour.service'; |
|||
import { DeviceService } from '@core/http/device.service'; |
|||
import { PageLink } from '@shared/models/page/page-link'; |
|||
import { PopoverPreferredPlacement } from '@shared/components/popover.models'; |
|||
import { escapeTourText, TourPopupRef, TourPopupService } from '@shared/components/tour/tour-popup.service'; |
|||
import { TourHostComponent } from '@modules/tour/tour-host.component'; |
|||
import { |
|||
TourPerson, |
|||
WelcomeInvitationComponent, |
|||
WelcomeInvitationData, |
|||
WelcomeInvitationResult |
|||
} from '@modules/tour/welcome-invitation.component'; |
|||
|
|||
type TourSide = 'right' | 'above'; |
|||
|
|||
interface TourStop { |
|||
target: () => HTMLElement | null; |
|||
side: TourSide; |
|||
title: string; |
|||
text: () => string; |
|||
pad?: number; |
|||
radius?: number; |
|||
interactive?: boolean; |
|||
enter?: () => Promise<void>; |
|||
} |
|||
|
|||
const AI_PAGE = '/ai-assistant'; |
|||
const NEW_USER_MS = 24 * 60 * 60 * 1000; |
|||
const PLACEMENTS: Record<TourSide, PopoverPreferredPlacement> = { |
|||
right: ['right', 'rightTop', 'rightBottom', 'bottom'], |
|||
above: ['top', 'topLeft', 'topRight'] |
|||
}; |
|||
|
|||
const delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms)); |
|||
|
|||
const visible = (el: HTMLElement | null, minWidth = 1): HTMLElement | null => { |
|||
const rect = el?.getBoundingClientRect(); |
|||
return rect && rect.width >= minWidth && rect.height > 0 && rect.right > 0 ? el : null; |
|||
}; |
|||
|
|||
@Injectable() |
|||
export class TourLauncher implements TourLauncherApi { |
|||
|
|||
private dialog = inject(MatDialog); |
|||
private store = inject(Store<AppState>); |
|||
private router = inject(Router); |
|||
private translate = inject(TranslateService); |
|||
private tourService = inject(TourService); |
|||
private tourPopup = inject(TourPopupService); |
|||
private deviceService = inject(DeviceService); |
|||
private appRef = inject(ApplicationRef); |
|||
private environmentInjector = inject(EnvironmentInjector); |
|||
|
|||
welcome(): void { |
|||
if (this.tourService.active()) { |
|||
return; |
|||
} |
|||
this.tourService.active.set(true); |
|||
this.dialog.open<WelcomeInvitationComponent, WelcomeInvitationData, WelcomeInvitationResult>(WelcomeInvitationComponent, { |
|||
panelClass: 'tb-invite-panel', |
|||
backdropClass: 'tb-invite-backdrop', |
|||
autoFocus: false, |
|||
restoreFocus: false, |
|||
maxWidth: '100vw', |
|||
data: {person: this.person()} |
|||
}).afterClosed().subscribe(result => { |
|||
this.markSeen(AiTourStep.WELCOME); |
|||
this.tourService.active.set(false); |
|||
if (result === 'tour') { |
|||
this.assistantTour(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
async assistantTour(): Promise<void> { |
|||
if (this.tourService.active()) { |
|||
return; |
|||
} |
|||
this.tourService.active.set(true); |
|||
this.markSeen(AiTourStep.ASSISTANT_TOUR); |
|||
if (this.router.url.split(/[?#]/)[0] !== AI_PAGE || this.router.url.includes('?')) { |
|||
await this.router.navigateByUrl(AI_PAGE); |
|||
} |
|||
await this.until(() => this.composer(), 6000); |
|||
const fresh = await this.noDevices(); |
|||
const before = this.person() === 'before'; |
|||
const t = (key: string) => this.translate.instant('tour.assistant.' + key); |
|||
this.play([ |
|||
{ |
|||
target: () => visible(document.querySelector<HTMLElement>(`tb-side-menu a[href="${AI_PAGE}"]`)), |
|||
side: 'right', pad: 2, radius: 8, |
|||
title: t('menu-title'), |
|||
text: () => t('menu-text') |
|||
}, |
|||
{ |
|||
target: () => this.chatsList() ?? this.chatsButton(), |
|||
side: 'right', radius: 10, |
|||
title: t('chats-title'), |
|||
text: () => t(this.chatsList() ? 'chats-text' : 'chats-folded-text') |
|||
}, |
|||
{ |
|||
target: () => this.newSolution(), |
|||
side: 'right', pad: 2, radius: 8, |
|||
title: t(before ? 'solutions-title-before' : 'solutions-title-new'), |
|||
text: () => t(before ? 'solutions-text-before' : 'solutions-text-new') |
|||
}, |
|||
{ |
|||
target: () => this.composer(), |
|||
side: 'above', radius: 20, interactive: true, |
|||
title: t('try-title'), |
|||
text: () => t(fresh ? 'try-text-fresh' : 'try-text'), |
|||
enter: async () => this.fill(t(fresh ? 'try-ask-fresh' : 'try-ask')) |
|||
} |
|||
]); |
|||
} |
|||
|
|||
private play(stops: TourStop[]): void { |
|||
const host = createComponent(TourHostComponent, {environmentInjector: this.environmentInjector}); |
|||
this.appRef.attachView(host.hostView); |
|||
document.body.append(host.location.nativeElement); |
|||
let index = -1; |
|||
let over = false; |
|||
let popup: TourPopupRef | null = null; |
|||
let cleanup: (() => void) | null = null; |
|||
const clear = () => { |
|||
cleanup?.(); |
|||
cleanup = null; |
|||
popup?.close(); |
|||
popup = null; |
|||
host.instance.spot.set(null); |
|||
}; |
|||
const end = (done: boolean) => { |
|||
if (over) { |
|||
return; |
|||
} |
|||
over = true; |
|||
clear(); |
|||
document.removeEventListener('keydown', onKey, true); |
|||
this.destroy(host); |
|||
this.tourService.active.set(false); |
|||
if (done) { |
|||
this.composer()?.querySelector('textarea')?.focus(); |
|||
} |
|||
}; |
|||
const onKey = (event: KeyboardEvent) => { |
|||
if (event.key === 'Escape') { |
|||
event.preventDefault(); |
|||
event.stopPropagation(); |
|||
end(false); |
|||
} |
|||
}; |
|||
document.addEventListener('keydown', onKey, true); |
|||
const go = async (to: number) => { |
|||
clear(); |
|||
let n = to; |
|||
while (n < stops.length && !stops[n].target()) { |
|||
n++; |
|||
} |
|||
if (n >= stops.length) { |
|||
end(true); |
|||
return; |
|||
} |
|||
index = n; |
|||
const stop = stops[index]; |
|||
await stop.enter?.(); |
|||
const target = stop.target(); |
|||
if (over || !target) { |
|||
return; |
|||
} |
|||
const live = stops.filter(s => !!s.target()); |
|||
const at = Math.max(0, live.indexOf(stop)); |
|||
const last = at === live.length - 1; |
|||
cleanup = this.spotlight(host, target, stop, () => end(true)); |
|||
popup = this.tourPopup.show({ |
|||
target, |
|||
hostView: host.instance.viewContainerRef, |
|||
renderer: host.instance.renderer, |
|||
placement: PLACEMENTS[stop.side], |
|||
title: stop.title, |
|||
text: escapeTourText(stop.text()), |
|||
count: live.length > 1 ? this.translate.instant('tour.assistant.count', {step: at + 1, count: live.length}) : null, |
|||
skipLabel: last ? null : this.translate.instant('tour.assistant.skip'), |
|||
nextLabel: this.translate.instant(last ? 'tour.assistant.done' : 'tour.assistant.next'), |
|||
onNext: () => go(index + 1), |
|||
onSkip: () => end(false), |
|||
onClose: () => end(false) |
|||
}); |
|||
setTimeout(() => document.querySelector<HTMLElement>('.tb-tour-popover .tb-tour-popup-go')?.focus({preventScroll: true}), 60); |
|||
}; |
|||
go(0); |
|||
} |
|||
|
|||
private spotlight(host: ComponentRef<TourHostComponent>, target: HTMLElement, stop: TourStop, onUse: () => void): () => void { |
|||
const pad = stop.pad ?? 6; |
|||
let frame = 0; |
|||
const place = () => { |
|||
if (!target.isConnected) { |
|||
return; |
|||
} |
|||
const rect = target.getBoundingClientRect(); |
|||
const own = parseFloat(getComputedStyle(target).borderTopLeftRadius) || 0; |
|||
host.instance.spot.set({ |
|||
left: rect.left - pad, |
|||
top: rect.top - pad, |
|||
width: rect.width + pad * 2, |
|||
height: rect.height + pad * 2, |
|||
radius: own ? own + pad : stop.radius ?? 12, |
|||
through: !!stop.interactive |
|||
}); |
|||
this.appRef.tick(); |
|||
}; |
|||
const again = () => { |
|||
cancelAnimationFrame(frame); |
|||
frame = requestAnimationFrame(place); |
|||
}; |
|||
place(); |
|||
window.addEventListener('resize', again); |
|||
window.addEventListener('scroll', again, true); |
|||
const observer = new ResizeObserver(again); |
|||
observer.observe(target); |
|||
const field = stop.interactive ? target.querySelector('textarea') : null; |
|||
const onClick = () => onUse(); |
|||
const onSend = (event: KeyboardEvent) => { |
|||
if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { |
|||
setTimeout(onUse, 0); |
|||
} |
|||
}; |
|||
if (stop.interactive) { |
|||
target.addEventListener('click', onClick, true); |
|||
field?.addEventListener('keydown', onSend); |
|||
} |
|||
return () => { |
|||
cancelAnimationFrame(frame); |
|||
window.removeEventListener('resize', again); |
|||
window.removeEventListener('scroll', again, true); |
|||
observer.disconnect(); |
|||
target.removeEventListener('click', onClick, true); |
|||
field?.removeEventListener('keydown', onSend); |
|||
}; |
|||
} |
|||
|
|||
private destroy(host: ComponentRef<TourHostComponent>): void { |
|||
this.appRef.detachView(host.hostView); |
|||
host.destroy(); |
|||
} |
|||
|
|||
private chatsList(): HTMLElement | null { |
|||
return visible(document.querySelector<HTMLElement>('.ai-rail .ai-list'), 120); |
|||
} |
|||
|
|||
private chatsButton(): HTMLElement | null { |
|||
return Array.from(document.querySelectorAll<HTMLElement>('.ai-bar-chats, .ai-strip .ai-ib')).map(el => visible(el)).find(el => !!el) ?? null; |
|||
} |
|||
|
|||
private newSolution(): HTMLElement | null { |
|||
const label = this.translate.instant('ai-assistant.new-solution'); |
|||
const nav = Array.from(document.querySelectorAll<HTMLElement>('.ai-rail .ai-nav')).find(el => el.textContent.includes(label)); |
|||
return visible(nav ?? null, 40) |
|||
?? visible(document.querySelector<HTMLElement>(`.ai-strip .ai-ib[aria-label="${label}"]`)); |
|||
} |
|||
|
|||
private composer(): HTMLElement | null { |
|||
return visible(document.querySelector<HTMLElement>('tb-ai-chat.ai-canvas .tb-ai-composer')); |
|||
} |
|||
|
|||
private fill(text: string): void { |
|||
const field = this.composer()?.querySelector('textarea'); |
|||
if (field) { |
|||
field.value = text; |
|||
field.dispatchEvent(new Event('input', {bubbles: true})); |
|||
} |
|||
} |
|||
|
|||
private async noDevices(): Promise<boolean> { |
|||
try { |
|||
const page = await firstValueFrom(this.deviceService.getTenantDevices(new PageLink(1), '', {ignoreLoading: true, ignoreErrors: true})); |
|||
return !page.totalElements; |
|||
} catch { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
private async until(found: () => unknown, timeoutMs: number): Promise<void> { |
|||
for (let waited = 0; !found() && waited < timeoutMs; waited += 100) { |
|||
await delay(100); |
|||
} |
|||
} |
|||
|
|||
private person(): TourPerson { |
|||
const created = getCurrentAuthState(this.store)?.userDetails?.createdTime; |
|||
return created && Date.now() - created < NEW_USER_MS ? 'new' : 'before'; |
|||
} |
|||
|
|||
private markSeen(step: AiTourStep): void { |
|||
this.store.dispatch(new ActionPreferencesUpdateAiTour({step, seen: true})); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { NgModule } from '@angular/core'; |
|||
import { CommonModule } from '@angular/common'; |
|||
import { SharedModule } from '@shared/shared.module'; |
|||
import { WelcomeInvitationComponent } from '@modules/tour/welcome-invitation.component'; |
|||
import { TourHostComponent } from '@modules/tour/tour-host.component'; |
|||
import { TourLauncher } from '@modules/tour/tour-launcher.service'; |
|||
|
|||
export { TourLauncher } from '@modules/tour/tour-launcher.service'; |
|||
|
|||
@NgModule({ |
|||
declarations: [ |
|||
WelcomeInvitationComponent, |
|||
TourHostComponent |
|||
], |
|||
imports: [ |
|||
CommonModule, |
|||
SharedModule |
|||
], |
|||
providers: [ |
|||
TourLauncher |
|||
] |
|||
}) |
|||
export class TourModule { } |
|||
@ -0,0 +1,47 @@ |
|||
<!-- |
|||
|
|||
SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. |
|||
SPDX-License-Identifier: BUSL-1.1 |
|||
|
|||
--> |
|||
<div class="tb-invite" data-ai [attr.data-step]="step()" role="dialog" aria-modal="true" aria-labelledby="tb-invite-title"> |
|||
<div class="iv-top"> |
|||
<div #scenes class="iv-scenes"></div> |
|||
<button mat-icon-button type="button" class="iv-x" [attr.aria-label]="'action.close' | translate" (click)="later()"> |
|||
<mat-icon fontSet="material-icons-round">close</mat-icon> |
|||
</button> |
|||
</div> |
|||
<div class="iv-body" aria-live="polite"> |
|||
@for (k of steps(); track k) { |
|||
@if (k) { |
|||
<div class="iv-kicker">{{ 'tour.invite.kicker' | translate: {kicker: ('tour.invite.kicker-' + person | translate), step: k, count: cards} }}</div> |
|||
<h2 class="iv-title" id="tb-invite-title">{{ 'tour.invite.card-' + k + '.title' | translate }}</h2> |
|||
<p class="iv-lead">{{ 'tour.invite.card-' + k + '.lead' | translate }}</p> |
|||
} @else { |
|||
<h2 class="iv-title tb-sr-only" id="tb-invite-title">{{ ('tour.invite.pill-' + person | translate) + ': ' + ('tour.invite.news' | translate) + ' ' + ('tour.invite.cover-title' | translate) }}</h2> |
|||
<p class="iv-lead">{{ 'tour.invite.cover-lead' | translate }}</p> |
|||
} |
|||
<div class="iv-foot"> |
|||
@if (k) { |
|||
<span class="iv-dotsnav" [attr.aria-label]="'tour.invite.step' | translate: {step: k, count: cards}"> |
|||
@for (n of cardNumbers; track n) { |
|||
<i [class.on]="n === k"></i> |
|||
} |
|||
</span> |
|||
} @else if (person === 'before') { |
|||
<p class="iv-note">{{ 'tour.invite.note' | translate }}</p> |
|||
} |
|||
<div class="iv-actions"> |
|||
@if (k) { |
|||
<button mat-button type="button" (click)="back()">{{ 'tour.invite.back' | translate }}</button> |
|||
} @else { |
|||
<button mat-button type="button" (click)="later()">{{ 'tour.invite.later' | translate }}</button> |
|||
} |
|||
<button #go mat-flat-button type="button" class="iv-go" (click)="next()"> |
|||
{{ (k === 0 ? 'tour.invite.go-' + person : k === cards ? 'tour.invite.show-around' : 'tour.invite.next') | translate }} |
|||
</button> |
|||
</div> |
|||
</div> |
|||
} |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,404 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. |
|||
// SPDX-License-Identifier: BUSL-1.1 |
|||
.tb-invite-backdrop { |
|||
background: rgba(16, 24, 40, 0.28); |
|||
-webkit-backdrop-filter: blur(6px) saturate(1.1); |
|||
backdrop-filter: blur(6px) saturate(1.1); |
|||
} |
|||
|
|||
.tb-invite-panel { |
|||
width: 720px; |
|||
max-width: calc(100vw - 32px) !important; |
|||
|
|||
.mat-mdc-dialog-container { |
|||
padding: 0; |
|||
} |
|||
|
|||
.mat-mdc-dialog-surface { |
|||
overflow: visible; |
|||
border-radius: 24px; |
|||
background: transparent; |
|||
box-shadow: none; |
|||
} |
|||
} |
|||
|
|||
@media (max-width: 640px) { |
|||
.tb-invite-panel { |
|||
width: 100vw; |
|||
max-width: 100vw !important; |
|||
height: 100dvh; |
|||
max-height: 100dvh !important; |
|||
|
|||
.mat-mdc-dialog-surface { |
|||
overflow: auto; |
|||
border-radius: 0; |
|||
} |
|||
} |
|||
} |
|||
|
|||
.tb-invite { |
|||
--tb-widget-shadow: 0 1px 1px rgba(20, 52, 58, 0.06), 0 2px 6px -1px rgba(20, 52, 58, 0.08); |
|||
--tb-widget-radius: 12px; |
|||
|
|||
.tb-sr-only { |
|||
position: absolute; |
|||
width: 1px; |
|||
height: 1px; |
|||
overflow: hidden; |
|||
clip: rect(0 0 0 0); |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.iv-x.mat-mdc-icon-button.mat-mdc-button-base { |
|||
--mdc-icon-button-state-layer-size: 36px; |
|||
--mat-icon-button-state-layer-size: 36px; |
|||
display: inline-flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
padding: 6px; |
|||
} |
|||
|
|||
.iv-go { |
|||
--mat-button-filled-container-color: var(--ai-action); |
|||
--mdc-filled-button-container-color: var(--ai-action); |
|||
--mat-button-filled-label-text-color: var(--ai-on-action); |
|||
--mdc-filled-button-label-text-color: var(--ai-on-action); |
|||
} |
|||
|
|||
.ai-field { |
|||
position: relative; |
|||
overflow: hidden; |
|||
isolation: isolate; |
|||
background: var(--ai-field-wash); |
|||
} |
|||
|
|||
.ai-field[data-level="tile"] { |
|||
background: var(--ai-field-tile); |
|||
} |
|||
|
|||
.ai-field[data-motion="live"]::after { |
|||
content: ''; |
|||
position: absolute; |
|||
inset: -30%; |
|||
z-index: -1; |
|||
pointer-events: none; |
|||
background: var(--ai-field-wash); |
|||
opacity: 0.6; |
|||
filter: blur(24px); |
|||
will-change: transform; |
|||
animation: iv-drift 28s ease-in-out infinite alternate; |
|||
} |
|||
} |
|||
|
|||
@keyframes iv-drift { |
|||
0% { transform: translate(-3%, -2%); } |
|||
50% { transform: translate(3%, 2%); } |
|||
100% { transform: translate(-1%, 3%); } |
|||
} |
|||
|
|||
.tb-invite { position: relative; width: 100%; overflow: hidden; border-radius: 24px; background: var(--tb-surface); color: var(--tb-ink); |
|||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 24px 48px -12px rgba(16, 24, 40, 0.22), 0 48px 96px -24px rgba(16, 24, 40, 0.24); |
|||
} |
|||
.tb-invite .iv-top { position: relative; } |
|||
.tb-invite .iv-version { display: inline-flex; align-items: center; gap: 6px; font: 500 15px/20px var(--tb-font); letter-spacing: 0; color: var(--tb-ink-76); } |
|||
.tb-invite .iv-version .mat-icon { font-size: 16px; width: 16px; height: 16px; color: var(--ai-action); } |
|||
.tb-invite .iv-x { position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; background: rgb(255 255 255 / 0.72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--tb-ink-76); } |
|||
.iv-canvas { height: 340px; -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent); mask-image: linear-gradient(to bottom, #000 82%, transparent); } |
|||
.iv-window { position: absolute; z-index: 1; left: 12%; right: 12%; top: 120px; height: 300px; display: grid; grid-template-columns: 31% 1fr; overflow: hidden; border-radius: 14px; background: var(--tb-surface); |
|||
box-shadow: 0 0 0 1px rgb(16 24 40 / 0.06), 0 24px 48px -20px rgb(16 24 40 / 0.3), 0 8px 16px -8px rgb(16 24 40 / 0.12); font-family: var(--tb-font); |
|||
transition: translate .5s cubic-bezier(.16, 1, .3, 1); animation: iv-rise .6s cubic-bezier(.16, 1, .3, 1) .08s both; } |
|||
@keyframes iv-rise { from { opacity: 0; transform: translateY(28px); } } |
|||
@keyframes iv-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } } |
|||
.tb-invite .iv-body { padding: 28px 32px 24px; } |
|||
.tb-invite .iv-title { margin: 0; font: 500 var(--chat-title)/var(--chat-title-lh) var(--tb-font); letter-spacing: 0; color: var(--tb-ink); text-wrap: balance; } |
|||
.tb-invite .iv-grad { background: linear-gradient(90deg in oklab, var(--ai-action), var(--ai-teal-600)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; } |
|||
.tb-invite .iv-lead { margin: 6px 0 0; max-width: 560px; font: 400 15px/22px var(--tb-font); color: var(--tb-ink-76); text-wrap: pretty; } |
|||
.tb-invite .iv-foot { display: flex; align-items: center; gap: 16px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--tb-line-soft); } |
|||
.tb-invite .iv-note { flex: 1; margin: 0; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.tb-invite .iv-actions { display: flex; gap: 8px; flex: none; margin-left: auto; } |
|||
.tb-invite .iv-actions .mdc-button { height: 36px; padding: 0 16px; border-radius: 8px; } |
|||
@media (max-width: 640px) { |
|||
.tb-invite:not(.iv-static) { display: flex; flex-direction: column; width: 100%; min-height: 100dvh; overflow: visible; border-radius: 0; box-shadow: none; animation-name: iv-up; } |
|||
.tb-invite:not(.iv-static) .iv-top { flex: none; } |
|||
@keyframes iv-up { from { opacity: 0; transform: translateY(32px); } } |
|||
.tb-invite:not(.iv-static) .iv-top { height: clamp(300px, 50dvh, 440px); } |
|||
.tb-invite:not(.iv-static) .iv-window { left: 6%; right: 6%; top: calc(150px + env(safe-area-inset-top)); } |
|||
.tb-invite:not(.iv-static) .iv-window.rq-files-w { left: 5%; right: 5%; top: calc(60px + env(safe-area-inset-top)); height: min(332px, calc(100% - 72px)); } |
|||
.tb-invite:not(.iv-static) .rq-files-w .rq-fgroup.in, .tb-invite:not(.iv-static) .rq-files-w .rq-fgroup small { display: none; } |
|||
.tb-invite:not(.iv-static) .rq-files-w .rq-fgrid { height: auto; padding: 12px; } |
|||
.tb-invite:not(.iv-static) .rq-files-w .rq-ftiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } |
|||
.tb-invite:not(.iv-static) .rq-files-w .rq-ft:nth-child(n+4) { display: none; } |
|||
.tb-invite:not(.iv-static) .rq-files-w .rq-code { top: 102px; left: 0; width: auto; box-shadow: none; translate: 0 102%; } |
|||
.tb-invite:not(.iv-static) .rq-files-w.open .rq-code { translate: 0 0; } |
|||
.tb-invite:not(.iv-static) .iv-window.rq-dock { left: 5%; right: 5%; top: calc(60px + env(safe-area-inset-top)); grid-template-columns: 1fr; } |
|||
.tb-invite:not(.iv-static) .rq-dock .iv-sk-page { display: none; } |
|||
.tb-invite:not(.iv-static) .iv-window.rq-col { left: 5%; right: 5%; top: calc(60px + env(safe-area-inset-top)); padding: 16px; } |
|||
.tb-invite:not(.iv-static) .rq-review { width: 320px; margin-left: -160px; } |
|||
.tb-invite:not(.iv-static) .rq-ask { top: calc(64px + env(safe-area-inset-top)); width: 328px; margin-left: -164px; } |
|||
.tb-invite:not(.iv-static) .rq-hero { padding: calc(40px + env(safe-area-inset-top)) 20px 0; } |
|||
.tb-invite:not(.iv-static) .iv-x { top: calc(10px + env(safe-area-inset-top)); right: 10px; } |
|||
.tb-invite:not(.iv-static) .iv-body { flex: 1 0 auto; display: flex; flex-direction: column; padding: 20px 20px 0; } |
|||
.tb-invite:not(.iv-static) .iv-foot { position: sticky; bottom: 0; margin-top: auto; flex-direction: column; align-items: stretch; gap: 12px; padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); background: var(--tb-surface); } |
|||
.tb-invite:not(.iv-static) .iv-actions { flex-direction: column-reverse; gap: 4px; margin-left: 0; } |
|||
.tb-invite:not(.iv-static) .iv-dotsnav { flex: none; justify-content: center; padding: 2px 0 4px; } |
|||
.tb-invite:not(.iv-static) .iv-actions .mdc-button { width: 100%; height: 44px; justify-content: center; } |
|||
.tb-invite:not(.iv-static) .iv-note { order: -1; } |
|||
} |
|||
@media (prefers-reduced-motion: reduce) { |
|||
.tb-invite, .tb-invite * { animation: none !important; } |
|||
.iv-window { transition: none; } |
|||
} |
|||
.tb-invite .iv-top { position: relative; height: 340px; } |
|||
.tb-invite .iv-scene { position: absolute; inset: 0; height: auto; opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility 0s linear .3s; } |
|||
.tb-invite .iv-scene.on { opacity: 1; visibility: visible; transition: none; animation: iv-scene-in .4s ease both; } |
|||
@keyframes iv-scene-in { from { opacity: 0; } } |
|||
.tb-invite .iv-body { min-height: 196px; display: flex; flex-direction: column; } |
|||
.tb-invite .iv-body > * { animation: iv-fade .3s ease both; } |
|||
@keyframes iv-fade { from { opacity: 0; transform: translateY(4px); } } |
|||
.tb-invite .iv-kicker { margin-bottom: 6px; font: 500 12px/16px var(--tb-font); letter-spacing: .4px; text-transform: uppercase; color: var(--tb-text-secondary); } |
|||
.tb-invite .iv-foot { margin-top: auto; } |
|||
.tb-invite .iv-lead { margin-bottom: 24px; } |
|||
.tb-invite .iv-kicker ~ .iv-lead { min-height: 3lh; } |
|||
.iv-dotsnav { flex: 1; display: inline-flex; align-items: center; gap: 6px; } |
|||
.iv-dotsnav i { width: 6px; height: 6px; border-radius: 3px; background: var(--tb-line); transition: width .25s cubic-bezier(.16, 1, .3, 1), background-color .25s ease; } |
|||
.iv-dotsnav i.on { width: 18px; background: var(--ai-action); } |
|||
@media (prefers-reduced-motion: reduce) { .tb-invite .iv-scene, .tb-invite .iv-scene.on, .iv-dotsnav i { transition: none; } } |
|||
.iv-tone { overflow: hidden; background: var(--ai-light-paper); } |
|||
.iv-tone[data-tone="aqua"] { background: radial-gradient(90% 120% at 0% 0%, var(--ai-light-aqua), transparent 70%), radial-gradient(80% 110% at 100% 100%, color-mix(in oklab, var(--ai-light-teal) 75%, transparent), transparent 70%), var(--ai-light-paper); } |
|||
.iv-tone[data-tone="amber"] { background: radial-gradient(90% 120% at 0% 0%, var(--ai-light-amber), transparent 70%), radial-gradient(80% 110% at 100% 100%, color-mix(in oklab, var(--ai-light-peach) 80%, transparent), transparent 70%), var(--ai-light-paper); } |
|||
.iv-tone[data-tone="lilac"] { background: radial-gradient(100% 130% at 0% 0%, var(--ai-light-lilac), transparent 72%), radial-gradient(70% 100% at 100% 100%, color-mix(in oklab, var(--ai-light-lilac) 55%, transparent), transparent 70%), var(--ai-light-paper); } |
|||
.iv-tone[data-tone="teal"] { background: radial-gradient(90% 120% at 0% 0%, var(--ai-light-teal), transparent 70%), radial-gradient(80% 110% at 100% 100%, color-mix(in oklab, var(--ai-light-mint) 80%, transparent), transparent 70%), var(--ai-light-paper); } |
|||
.iv-sk-page { display: flex; flex-direction: column; min-width: 0; } |
|||
.iv-sk-row { display: flex; gap: 8px; } |
|||
.rq-sp { flex: 1; } |
|||
.rq-typing { display: block; min-height: 24px; } |
|||
.rq-typing.sent { animation: rq-sent .2s cubic-bezier(.3, 0, .8, .15) both; } |
|||
@keyframes rq-sent { to { opacity: 0; transform: translateY(-12px); } } |
|||
.rq-caret { display: inline-block; width: 2px; height: 20px; margin-left: 1px; border-radius: 1px; background: var(--ai-action); vertical-align: -4px; animation: rq-blink 1.06s step-end infinite; } |
|||
@keyframes rq-blink { 50% { opacity: 0; } } |
|||
.iv-canvas.iv-tone { -webkit-mask-image: linear-gradient(to bottom, #000 90%, transparent); mask-image: linear-gradient(to bottom, #000 90%, transparent); } |
|||
.rq-hero { position: absolute; inset: 0 0 4px; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 0 72px; font-family: var(--tb-font); |
|||
animation: iv-rise .6s cubic-bezier(.16, 1, .3, 1) .05s both; } |
|||
.rq-hero-t { display: flex; flex-direction: column; align-items: center; margin: 8px 0 14px; font: 500 30px/38px var(--tb-font); letter-spacing: -0.4px; color: var(--tb-ink); text-align: center; text-wrap: balance; } |
|||
.rq-hero .rq-term { align-self: stretch; } |
|||
.rq-term { border-radius: 14px; background: var(--tb-surface); box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.04), 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.08); font-family: var(--tb-font); } |
|||
.rq-term.focus { box-shadow: 0 0 0 2px var(--ai-focus), 0 8px 24px var(--ai-focus-shadow); } |
|||
.rq-term.focus .rq-pre { color: var(--ai-focus); } |
|||
.rq-term-in { display: flex; align-items: flex-start; gap: 10px; min-height: 48px; padding: 12px 10px 10px 16px; } |
|||
.rq-term-in .rq-pre { flex: none; width: 18px; height: 24px; font-size: 20px; line-height: 24px; color: var(--ai-action); } |
|||
.rq-term-words { position: relative; flex: 1; min-width: 0; min-height: 24px; font: 400 16px/24px var(--tb-font); color: var(--tb-ink); text-align: left; } |
|||
.rq-ph { color: var(--tb-text-muted); } |
|||
.rq-send { flex: none; align-self: flex-end; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ai-action); color: var(--ai-on-action, #fff); transition: background-color .2s ease, color .2s ease, transform .14s ease; } |
|||
.rq-send.off { background: color-mix(in oklab, var(--tb-ink) 6%, var(--tb-surface)); color: var(--tb-ink-38); } |
|||
.rq-send.press { transform: scale(.86); } |
|||
.rq-send .mat-icon { font-size: 18px; width: 18px; height: 18px; } |
|||
.rq-term-foot { display: flex; align-items: center; gap: 2px; padding: 2px 8px 6px; border-top: 1px solid var(--tb-line-soft); font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-tool { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; } |
|||
.rq-tool .mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--tb-ink-54); } |
|||
.rq-cring svg { display: block; width: 20px; height: 20px; } |
|||
.rq-cring circle { fill: none; stroke-width: 2.5; } |
|||
.rq-cring .track { stroke: rgba(0, 0, 0, 0.1); } |
|||
.rq-cring .arc { stroke: var(--ai-teal-500); stroke-linecap: round; } |
|||
.rq-term.compact .rq-term-in { min-height: 0; padding: 10px 8px 10px 12px; } |
|||
.rq-term.compact .rq-send { align-self: center; width: 32px; height: 32px; } |
|||
.rq-term.compact .rq-pre { height: 22px; line-height: 22px; } |
|||
.rq-term.compact .rq-term-words { font-size: 14px; line-height: 22px; } |
|||
.iv-window.rq-dock { top: 20px; left: 6%; right: 6%; height: 284px; grid-template-columns: 1fr 56%; } |
|||
.rq-dash { display: flex; flex-direction: column; gap: 12px; padding: 16px; } |
|||
.rq-companion { display: flex; flex-direction: column; border-left: 1px solid var(--tb-line); background: var(--tb-surface); font-family: var(--tb-font); } |
|||
.rq-chead { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--tb-line-soft); } |
|||
.rq-chead b { font: 500 14px/20px var(--tb-font); } |
|||
.rq-chead > .mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--tb-ink-54); } |
|||
.rq-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 14px 0; text-align: center; } |
|||
.rq-empty > b { font: 500 15px/22px var(--tb-font); } |
|||
.rq-empty > .tb-ai-mark { margin-bottom: 6px; } |
|||
.rq-empty > span { font: 400 12.5px/18px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-prompts { align-self: stretch; display: flex; flex-direction: column; margin-top: 10px; border-top: 1px solid var(--tb-line); text-align: left; } |
|||
.rq-prompt { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 10px; min-height: 40px; padding: 0 6px; border-bottom: 1px solid var(--tb-line); font: 400 13.5px/20px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-prompt .mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--tb-ink-54); } |
|||
.rq-companion .rq-term { margin: 10px 12px 12px; } |
|||
.rq-dock .rq-chead { min-height: 44px; } |
|||
.rq-dock .rq-empty { gap: 2px; padding-top: 10px; } |
|||
.rq-dock .rq-empty > .tb-ai-mark { --m: 28px; margin-bottom: 4px; } |
|||
.rq-dock .rq-prompts { margin-top: 8px; } |
|||
.rq-dock .rq-prompt { min-height: 36px; } |
|||
.rq-dock .rq-term.compact .rq-term-in { padding: 8px 8px 8px 12px; } |
|||
.rq-companion .rq-term.docked { margin: 0; border-top: 1px solid var(--tb-line); border-radius: 0; box-shadow: none; } |
|||
.rq-dock .rq-term.docked .rq-term-in { padding: 10px 10px 2px 14px; } |
|||
.rq-term.docked .rq-term-foot { padding: 0 6px 4px; border-top: 0; } |
|||
.rq-term.docked .rq-tool { width: 30px; height: 30px; } |
|||
.iv-canvas.iv-sky { -webkit-mask-image: linear-gradient(to bottom, #000 84%, transparent); mask-image: linear-gradient(to bottom, #000 84%, transparent); } |
|||
.rq-home { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; padding: 26px 56px 0; font-family: var(--tb-font); |
|||
animation: iv-rise .6s cubic-bezier(.16, 1, .3, 1) .05s both; } |
|||
.rq-hdate { font: 500 12px/16px var(--tb-font); letter-spacing: .5px; text-transform: uppercase; color: var(--tb-ink-54); } |
|||
.rq-hgreet { display: flex; align-items: center; gap: 8px; margin-top: 2px; font: 600 24px/32px var(--tb-font); letter-spacing: -0.2px; color: var(--tb-ink); } |
|||
.rq-hgreet .tb-ai-mark { --m: 34px; width: calc(var(--m) * var(--ai-spark)); height: calc(var(--m) * var(--ai-spark)); border-radius: 0; background: none; box-shadow: none; animation: none; } |
|||
.rq-hpills { display: flex; gap: 8px; margin-top: 10px; } |
|||
.rq-hpill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 14px; border-radius: 15px; background: var(--tb-surface); box-shadow: var(--tb-widget-shadow); font: 400 14px/20px var(--tb-font); color: var(--tb-ink); white-space: nowrap; } |
|||
.rq-hpill .mat-icon { margin-left: -3px; font-size: 16px; width: 16px; height: 16px; color: var(--tb-crit); } |
|||
.rq-hrow { align-self: stretch; display: flex; gap: 8px; max-width: 520px; margin-top: 12px; } |
|||
.rq-hfield { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 8px 0 16px; border-radius: var(--tb-widget-radius); background: var(--tb-surface); box-shadow: var(--tb-widget-shadow); transition: box-shadow .2s ease; } |
|||
.rq-hfield .rq-pre { flex: none; width: 18px; font-size: 20px; line-height: 24px; color: var(--ai-action); } |
|||
.rq-hfield .rq-typing { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; font: 400 16px/24px var(--tb-font); color: var(--tb-ink); text-align: left; } |
|||
.rq-hkey { flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 22px; height: 22px; margin-right: 8px; padding: 0 6px; border: 1px solid var(--tb-line); border-radius: 6px; font: 500 12px/1 var(--tb-font); color: var(--tb-ink-54); } |
|||
.rq-hfield .rq-send { display: none; align-self: center; width: 32px; height: 32px; } |
|||
.rq-hrow.typing .rq-hfield { box-shadow: 0 0 0 2px var(--ai-focus), 0 8px 24px var(--ai-focus-shadow); } |
|||
.rq-hrow.typing .rq-hfield .rq-pre { color: var(--ai-focus); } |
|||
.rq-hrow.typing .rq-hkey { display: none; } |
|||
.rq-hrow.typing .rq-send { display: inline-flex; } |
|||
.rq-hchats { flex: none; display: inline-flex; align-items: center; gap: 8px; box-sizing: border-box; height: 46px; max-width: 160px; padding: 0 12px 0 16px; overflow: hidden; white-space: nowrap; border-radius: var(--tb-widget-radius); box-shadow: inset 0 0 0 1px var(--tb-line); font: 500 14px/20px var(--tb-font); color: var(--tb-ink-76); |
|||
transition: max-width .25s ease, padding .25s ease, margin .25s ease, opacity .15s ease; } |
|||
.rq-hchats .mat-icon { flex: none; font-size: 20px; width: 20px; height: 20px; color: var(--tb-ink-76); } |
|||
.rq-hchats .mat-icon:last-child { margin-left: -4px; font-size: 16px; width: 16px; height: 16px; color: var(--tb-ink-54); } |
|||
.rq-hrow.typing .rq-hchats { max-width: 0; margin-left: -8px; padding: 0; opacity: 0; } |
|||
.rq-hwait { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 12px; } |
|||
.rq-hwait > small { font: 500 13px/18px var(--tb-font); letter-spacing: .1px; color: var(--tb-ink-76); } |
|||
.rq-hchatrow { display: flex; gap: 8px; } |
|||
.rq-hchat { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border-radius: var(--tb-widget-radius); background: var(--tb-surface); box-shadow: var(--tb-widget-shadow); white-space: nowrap; } |
|||
.rq-hchat i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tb-caution); } |
|||
.rq-hchat b { font: 500 14px/20px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-hchat small { font: 400 13px/18px var(--tb-font); color: var(--tb-ink-54); } |
|||
.rq-hcards { align-self: stretch; display: grid; grid-template-columns: minmax(0, 1fr) 216px; gap: 12px; margin-top: 16px; } |
|||
.rq-hcard { display: flex; flex-direction: column; gap: 10px; height: 120px; padding: 12px 16px; border-radius: var(--tb-widget-radius) var(--tb-widget-radius) 0 0; background: var(--tb-surface); box-shadow: var(--tb-widget-shadow); } |
|||
.rq-hcard b { display: flex; align-items: center; gap: 8px; font: 500 15px/22px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-hcard b .mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--tb-ink-76); } |
|||
.rq-hcard b small { font: 400 13px/18px var(--tb-font); color: var(--tb-ink-54); } |
|||
.rq-hcard i { display: block; height: 8px; border-radius: 4px; background: var(--tb-line); } |
|||
@media (max-width: 640px) { |
|||
.tb-invite:not(.iv-static) .rq-home { padding: calc(24px + env(safe-area-inset-top)) 20px 0; } |
|||
.tb-invite:not(.iv-static) .rq-hpills { flex-wrap: wrap; } |
|||
.tb-invite:not(.iv-static) .rq-hchats > span:not(.mat-icon) { display: none; } |
|||
.tb-invite:not(.iv-static) .rq-hchat:nth-child(n+2), .tb-invite:not(.iv-static) .rq-hcard:nth-child(n+2) { display: none; } |
|||
.tb-invite:not(.iv-static) .rq-hcards { grid-template-columns: 1fr; } |
|||
} |
|||
@media (prefers-reduced-motion: reduce) { .rq-hfield, .rq-hchats { transition: none; } } |
|||
.iv-window.rq-col { display: flex; flex-direction: column; top: 22px; left: 19%; right: 19%; height: 276px; gap: 12px; padding: 18px 22px; font-family: var(--tb-font); } |
|||
.rq-user { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; } |
|||
.rq-bubble { padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--ai-person); font: 400 14px/20px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-hero .rq-bubble { background: var(--tb-surface); } |
|||
.rq-hero :is(.rq-rec, .rq-file) { border-color: transparent; } |
|||
.rq-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; } |
|||
.rq-agent { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; } |
|||
.rq-agent p { margin: 0; font: 400 14px/21px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-rec { display: grid; grid-template-columns: 24px auto 1fr auto; align-items: center; column-gap: 8px; min-height: 34px; padding: 4px 10px 4px 5px; border: 1px solid var(--tb-line); border-radius: 8px; background: var(--tb-surface); max-width: 100%; } |
|||
.rq-rec b { font: 500 13.5px/20px var(--tb-font); white-space: nowrap; } |
|||
.rq-rec small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-rec-tile { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; } |
|||
.rq-rec-tile .mat-icon { font-size: 16px; width: 16px; height: 16px; } |
|||
.rq-rec.planned .rq-rec-tile { background: none !important; box-shadow: inset 0 0 0 1.5px currentColor; outline: 0; border: 1.5px dashed currentColor; box-shadow: none; } |
|||
.rq-rec-ok { font-size: 16px !important; width: 16px; height: 16px; color: var(--ai-teal-600); } |
|||
.rq-rec-tile { transition: background-color .25s ease; } |
|||
.rq-file { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border: 1px solid var(--tb-line); border-radius: 8px; background: var(--tb-surface); } |
|||
.rq-file b { display: block; font: 500 13px/18px var(--tb-font); white-space: nowrap; } |
|||
.rq-file small { display: block; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); white-space: nowrap; } |
|||
.rq-file-ic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; } |
|||
.rq-file-ic .mat-icon { font-size: 17px; width: 17px; height: 17px; } |
|||
.rq-file-ic[data-tone="rule"] { background: var(--entity-rule-bg); color: var(--entity-rule-fg); } |
|||
.rq-review { position: absolute; z-index: 2; left: 50%; top: 84px; width: 380px; margin-left: -190px; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--tb-line); border-radius: 12px; background: var(--tb-surface); |
|||
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 18px 40px -16px rgba(16, 24, 40, 0.28); font-family: var(--tb-font); animation: iv-rise .6s cubic-bezier(.16, 1, .3, 1) .08s both; } |
|||
.rq-rev-head { display: flex; align-items: center; gap: 6px; font: 500 14px/20px var(--tb-font); color: var(--ai-teal-500); } |
|||
.rq-rev-head .mat-icon { font-size: 18px; width: 18px; height: 18px; } |
|||
.rq-ask { top: 34px; width: 420px; margin-left: -210px; gap: 12px; } |
|||
.rq-ask .rq-rev-head { color: var(--tb-ink); } |
|||
.rq-ask .rq-rev-head .mat-icon { color: var(--tb-ink-54); } |
|||
.rq-ask .rq-rev-head small { margin-left: 4px; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-ask-q b { display: block; font: 500 14px/20px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-ask-q span { display: block; font: 400 14px/20px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-chips { display: flex; flex-wrap: wrap; gap: 6px; } |
|||
.rq-chip { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--tb-line); font: 400 14px/20px var(--tb-font); color: var(--tb-ink-76); white-space: nowrap; } |
|||
.rq-chip.on { box-shadow: inset 0 0 0 2px var(--ai-focus); font-weight: 500; color: var(--tb-ink); } |
|||
.rq-ask-hint { margin: -2px 0 0; font: 400 13px/18px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-ask .rq-actions { margin-top: 2px; } |
|||
.rq-ask .rq-actions .rq-sp { flex: 1; } |
|||
.rq-actions { display: flex; gap: 8px; margin-top: 2px; } |
|||
.rq-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 12px; border-radius: 8px; font: 500 14px/1 var(--tb-font); letter-spacing: .1px; } |
|||
.rq-btn .mat-icon { font-size: 18px; width: 18px; height: 18px; } |
|||
.rq-btn.fill { background: var(--ai-action); color: var(--ai-on-action, #fff); } |
|||
.rq-btn.text { color: var(--ai-action); } |
|||
.rq-chip { transition: box-shadow .16s ease, color .16s ease; } |
|||
.iv-window.rq-files-w { display: block; top: 22px; left: 7%; right: 7%; height: 276px; } |
|||
.rq-code { position: absolute; top: 0; right: 0; bottom: 0; width: 60%; display: flex; flex-direction: column; min-width: 0; background: var(--tb-code-bg); color: var(--tb-code-fg); |
|||
box-shadow: -16px 0 32px -16px rgb(16 24 40 / 0.45); translate: 102% 0; transition: translate .45s cubic-bezier(.16, 1, .3, 1); } |
|||
.rq-files-w.open .rq-code { translate: 0 0; } |
|||
.rq-code-head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--tb-code-line); font-family: var(--tb-font); } |
|||
.rq-code-head > .mat-icon { font-size: 18px; width: 18px; height: 18px; color: var(--tb-code-head-fg); } |
|||
.rq-code-head b { font: 500 13.5px/20px var(--tb-font); color: var(--tb-code-fg); } |
|||
.rq-code-edit { padding: 3px 10px; border-radius: 6px; font: 500 12.5px/18px var(--tb-font); color: rgba(255, 255, 255, 0.72); box-shadow: inset 0 0 0 1px var(--tb-code-line); } |
|||
.rq-code-body { padding: 12px 0; font: 400 12.5px/21px var(--tb-mono); } |
|||
.rq-ln { display: grid; grid-template-columns: 34px 1fr; white-space: pre; } |
|||
.rq-ln i { padding-right: 12px; text-align: right; font-style: normal; color: rgba(255, 255, 255, 0.32); } |
|||
.rq-ln > span { overflow: hidden; text-overflow: ellipsis; } |
|||
.rq-ln:not(.w) { visibility: hidden; } |
|||
.rq-ln.w > span { animation: iv-fade .25s ease both; } |
|||
.rq-code .hl-key { color: var(--hl-key); } .rq-code .hl-cmd { color: var(--hl-cmd); } .rq-code .hl-str { color: var(--hl-str); } .rq-code .hl-num { color: var(--hl-num); } .rq-code .hl-flag { color: var(--hl-flag); } |
|||
.rq-wait { visibility: hidden; } |
|||
.rq-in { animation: iv-pop .35s cubic-bezier(.16, 1, .3, 1) both; } |
|||
.rq-pressed { scale: .97; } |
|||
.rq-cursor { position: absolute; left: 0; top: 0; z-index: 6; width: 22px; height: 22px; margin: -2px 0 0 -5px; opacity: 0; pointer-events: none; transform: translate(560px, 320px); |
|||
transition: transform .52s cubic-bezier(.3, .1, .2, 1), opacity .2s ease; filter: drop-shadow(0 1px 2px rgb(16 24 40 / 0.4)); } |
|||
.rq-cursor svg { display: block; width: 100%; height: 100%; fill: var(--tb-ink); stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; transition: scale .12s ease; transform-origin: 20% 12%; } |
|||
.rq-cursor.on { opacity: 1; } |
|||
.rq-cursor.press svg { scale: .84; } |
|||
.tb-invite[data-step="0"] .iv-top { height: 432px; } |
|||
.tb-invite[data-step="0"] .iv-body { min-height: 163px; padding-top: 20px; } |
|||
.tb-invite[data-step="0"] .iv-lead { margin-bottom: 16px; } |
|||
.iv-canvas[data-scene="0"] { height: 432px; -webkit-mask-image: linear-gradient(to bottom, #000 92%, transparent); mask-image: linear-gradient(to bottom, #000 92%, transparent); } |
|||
.rq-log { align-self: stretch; height: 0; margin-top: -12px; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; transition: height .5s cubic-bezier(.16, 1, .3, 1), margin-top .5s cubic-bezier(.16, 1, .3, 1), opacity .2s ease; } |
|||
.rq-log.open { height: 124px; margin-top: 0; } |
|||
.rq-log.out { opacity: 0; } |
|||
.rq-log > *, .rq-log .rq-agent > * { animation: iv-pop .35s cubic-bezier(.16, 1, .3, 1) both; } |
|||
.rq-log .rq-agent .rq-rec { animation-delay: 0s; } |
|||
.rq-log .rq-agent p { text-align: left; } |
|||
.rq-ptop { display: flex; align-items: baseline; gap: 8px; height: 44px; padding: 0 14px; border-bottom: 1px solid var(--tb-line-soft); white-space: nowrap; } |
|||
.rq-ptop b { font: 500 14px/44px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-ptop small { font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-dock .rq-dash { gap: 10px; padding: 12px 14px; } |
|||
.rq-tile { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; background: var(--tb-surface); box-shadow: inset 0 0 0 1px var(--tb-line-soft); } |
|||
.rq-tile small { display: block; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-tile b { display: block; font: 500 18px/24px var(--tb-font); color: var(--tb-ink); transition: color .3s ease; } |
|||
.rq-tile b .u { margin-left: 3px; font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-tile.hot b { color: var(--tb-caution); } |
|||
.rq-chart { height: 86px; padding: 8px 10px; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--tb-line-soft); } |
|||
.rq-chart svg { display: block; width: 100%; height: 100%; overflow: visible; } |
|||
.rq-chart .lim { stroke: var(--tb-caution); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; opacity: .75; } |
|||
.rq-chart .ln { fill: none; stroke: var(--ai-teal-600); stroke-width: 2; vector-effect: non-scaling-stroke; } |
|||
.rq-chart .plot { clip-path: inset(-20% 100% -20% 0); transition: clip-path 1s cubic-bezier(.4, 0, .2, 1); } |
|||
.rq-chart.drawn .plot { clip-path: inset(-20% 0 -20% 0); } |
|||
.rq-alarm { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: 13px; background: color-mix(in oklab, var(--tb-caution) 12%, var(--tb-surface)); color: var(--tb-caution); font: 500 12px/16px var(--tb-font); white-space: nowrap; |
|||
opacity: 0; transform: translateY(4px); transition: opacity .25s ease, transform .25s ease; } |
|||
.rq-alarm.on { opacity: 1; transform: none; } |
|||
.rq-alarm .mat-icon { font-size: 15px; width: 15px; height: 15px; } |
|||
.rq-cbody { flex: 1; min-height: 0; display: flex; flex-direction: column; } |
|||
.rq-cbody.said { gap: 10px; padding: 14px 14px 0; } |
|||
.rq-cbody.said .rq-bubble { padding: 8px 12px; } |
|||
.rq-prompt { transition: background-color .15s ease; } |
|||
.rq-prompt.picked { background: color-mix(in oklab, var(--ai-light-teal) 30%, transparent); } |
|||
.rq-agent.rq-plan { align-self: stretch; } |
|||
.rq-plan .rq-rec { align-self: stretch; } |
|||
.rq-plan-h { align-self: stretch; display: flex; align-items: center; gap: 8px; min-height: 30px; } |
|||
.rq-plan-h b { font: 500 14px/20px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-plan-h small { font: 400 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-btn.sm { height: 28px; padding: 0 12px 0 8px; font-size: 13px; transition: background-color .2s ease, color .2s ease, opacity .2s ease; } |
|||
.rq-btn.sm.busy { padding: 0 12px; opacity: .72; } |
|||
.rq-btn.sm.done { background: none; color: var(--ai-teal-600); } |
|||
.rq-rec.made .rq-rec-ok { animation: iv-pop .3s cubic-bezier(.16, 1, .3, 1) both; } |
|||
.rq-said { display: none; align-items: center; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--tb-line-soft); font: 400 13px/18px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-said.on { display: flex; animation: iv-pop .3s cubic-bezier(.16, 1, .3, 1) both; } |
|||
.rq-said b { font-weight: 500; color: var(--tb-ink); } |
|||
.rq-said .mat-icon { font-size: 16px; width: 16px; height: 16px; color: var(--ai-teal-600); } |
|||
.rq-fgrid { box-sizing: border-box; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 16px; min-width: 0; padding: 0 16px; font-family: var(--tb-font); } |
|||
.rq-fgroup > small { display: block; margin-bottom: 6px; font: 500 12px/16px var(--tb-font); color: var(--tb-text-secondary); } |
|||
.rq-ftiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; } |
|||
.rq-ft { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 8px 2px 6px; border-radius: 10px; transition: background-color .16s ease, box-shadow .16s ease, scale .1s ease; } |
|||
.rq-ft .rq-file-ic { width: 40px; height: 40px; border-radius: 10px; } |
|||
.rq-ft .rq-file-ic .mat-icon { font-size: 22px; width: 22px; height: 22px; } |
|||
.rq-ft b { max-width: 100%; overflow-wrap: anywhere; text-align: center; font: 500 12.5px/18px var(--tb-font); color: var(--tb-ink); } |
|||
.rq-ft.on { background: var(--ai-selected-wash); box-shadow: inset 0 0 0 2px var(--ai-selected); } |
|||
.rq-ft.on b { color: var(--ai-selected-text); } |
|||
@media (max-width: 640px) { |
|||
.tb-invite:not(.iv-static) .rq-hero-t { margin: 2px 0 6px; font-size: 26px; line-height: 32px; } |
|||
.tb-invite:not(.iv-static)[data-step="0"] .iv-top, .tb-invite:not(.iv-static) .iv-canvas[data-scene="0"] { height: 436px; } |
|||
.tb-invite:not(.iv-static) .rq-log.open { height: 112px; } |
|||
.tb-invite:not(.iv-static) .rq-hero { padding-top: calc(12px + env(safe-area-inset-top)); gap: 10px; } |
|||
} |
|||
@media (prefers-reduced-motion: reduce) { .rq-cursor { display: none; } .rq-chart .plot, .rq-alarm, .rq-log, .rq-tile b, .rq-ft, .rq-code { transition: none; } } |
|||
@ -0,0 +1,125 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { |
|||
AfterViewInit, |
|||
ChangeDetectionStrategy, |
|||
Component, |
|||
computed, |
|||
ElementRef, |
|||
HostListener, |
|||
inject, |
|||
signal, |
|||
ViewChild, |
|||
ViewEncapsulation |
|||
} from '@angular/core'; |
|||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { buildScene, CoverWords, SceneContext, WELCOME_CARDS } from '@modules/tour/welcome-scenes'; |
|||
|
|||
export type TourPerson = 'before' | 'new'; |
|||
|
|||
export interface WelcomeInvitationData { |
|||
person: TourPerson; |
|||
} |
|||
|
|||
export type WelcomeInvitationResult = 'tour' | 'later'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-welcome-invitation', |
|||
templateUrl: './welcome-invitation.component.html', |
|||
styleUrls: ['./welcome-invitation.component.scss'], |
|||
encapsulation: ViewEncapsulation.None, |
|||
standalone: false, |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class WelcomeInvitationComponent implements AfterViewInit { |
|||
|
|||
@ViewChild('scenes', {static: true}) scenesRef: ElementRef<HTMLElement>; |
|||
|
|||
@ViewChild('go', {read: ElementRef}) goRef: ElementRef<HTMLElement>; |
|||
|
|||
private data = inject<WelcomeInvitationData>(MAT_DIALOG_DATA); |
|||
|
|||
private dialogRef = inject<MatDialogRef<WelcomeInvitationComponent, WelcomeInvitationResult>>(MatDialogRef); |
|||
|
|||
private translate = inject(TranslateService); |
|||
|
|||
readonly cards = WELCOME_CARDS; |
|||
|
|||
readonly cardNumbers = Array.from({length: WELCOME_CARDS}, (_, i) => i + 1); |
|||
|
|||
readonly person = this.data.person; |
|||
|
|||
readonly step = signal(0); |
|||
|
|||
readonly steps = computed(() => [this.step()]); |
|||
|
|||
private frames: HTMLElement[] = []; |
|||
|
|||
private readonly context: SceneContext = { |
|||
t: (key, params) => this.translate.instant(key, params), |
|||
locale: (this.translate.currentLang || 'en-US').replace('_', '-'), |
|||
still: typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches |
|||
}; |
|||
|
|||
private readonly coverWords: CoverWords = { |
|||
pill: this.translate.instant(`tour.invite.pill-${this.person}`), |
|||
news: this.translate.instant('tour.invite.news'), |
|||
title: this.translate.instant('tour.invite.cover-title') |
|||
}; |
|||
|
|||
ngAfterViewInit(): void { |
|||
const host = this.scenesRef.nativeElement; |
|||
for (let n = 0; n <= WELCOME_CARDS; n++) { |
|||
const frame = document.createElement('div'); |
|||
frame.className = 'iv-canvas iv-scene'; |
|||
frame.setAttribute('aria-hidden', 'true'); |
|||
host.append(frame); |
|||
this.frames.push(frame); |
|||
} |
|||
this.show(0); |
|||
} |
|||
|
|||
show(k: number): void { |
|||
if (k < 0 || k > WELCOME_CARDS) { |
|||
return; |
|||
} |
|||
this.step.set(k); |
|||
this.frames.forEach((frame, n) => { |
|||
if (n === k && !frame.classList.contains('on')) { |
|||
const fresh = buildScene(n, this.context, this.coverWords); |
|||
frame.replaceWith(fresh); |
|||
this.frames[n] = fresh; |
|||
fresh.classList.add('on'); |
|||
} else if (n !== k) { |
|||
frame.classList.remove('on'); |
|||
} |
|||
}); |
|||
setTimeout(() => this.goRef?.nativeElement.focus({preventScroll: true}), 30); |
|||
} |
|||
|
|||
next(): void { |
|||
if (this.step() === WELCOME_CARDS) { |
|||
this.dialogRef.close('tour'); |
|||
} else { |
|||
this.show(this.step() + 1); |
|||
} |
|||
} |
|||
|
|||
back(): void { |
|||
this.show(this.step() - 1); |
|||
} |
|||
|
|||
later(): void { |
|||
this.dialogRef.close('later'); |
|||
} |
|||
|
|||
@HostListener('document:keydown', ['$event']) |
|||
onKey(event: KeyboardEvent): void { |
|||
if (event.key === 'ArrowRight') { |
|||
this.show(this.step() + 1); |
|||
} else if (event.key === 'ArrowLeft') { |
|||
this.show(this.step() - 1); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,466 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
|
|||
export interface SceneContext { |
|||
t: (key: string, params?: Record<string, unknown>) => string; |
|||
locale: string; |
|||
still: boolean; |
|||
} |
|||
|
|||
type Child = Node | string | null | undefined | false | Child[]; |
|||
|
|||
type Attrs = Record<string, string | null | undefined> & { style?: string }; |
|||
|
|||
const ENTITY: Record<string, [string, string]> = { |
|||
device: ['memory', 'device'], |
|||
dashboard: ['dashboard', 'view'], |
|||
rule: ['rule', 'rule'], |
|||
notification: ['notifications', 'people'] |
|||
}; |
|||
|
|||
const TONES = [null, 'sky', 'aqua', 'teal', 'amber', 'lilac']; |
|||
|
|||
const POINTER = '<svg viewBox="0 0 24 24"><path d="M5 3l14 8-6.2 1.6L16 19l-2.6 1.2-3.1-6.3L5 18z"/></svg>'; |
|||
|
|||
const CHART = '<svg viewBox="0 0 240 80" preserveAspectRatio="none"><line class="lim" x1="0" y1="30" x2="240" y2="30"/>' |
|||
+ '<g class="plot"><path class="ln" d="M0 60 C 20 58, 30 62, 50 59 S 80 56, 100 60 S 130 62, 150 58 S 172 60, 184 52 S 198 14, 210 12 ' |
|||
+ 'S 228 17, 240 14"/></g></svg>'; |
|||
|
|||
function append(el: HTMLElement, kids: Child[]): void { |
|||
for (const kid of kids) { |
|||
if (kid == null || kid === false) { |
|||
continue; |
|||
} |
|||
if (Array.isArray(kid)) { |
|||
append(el, kid); |
|||
} else { |
|||
el.append(kid); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function h(tag: string, attrs: Attrs | null, ...kids: Child[]): HTMLElement { |
|||
const el = document.createElement(tag); |
|||
for (const [key, value] of Object.entries(attrs ?? {})) { |
|||
if (value != null) { |
|||
el.setAttribute(key, value); |
|||
} |
|||
} |
|||
append(el, kids); |
|||
return el; |
|||
} |
|||
|
|||
const q = (cls: string, ...kids: Child[]) => h('div', {class: cls}, ...kids); |
|||
|
|||
const icon = (name: string, cls?: string) => h('span', {class: 'mat-icon material-icons-round' + (cls ? ' ' + cls : ''), 'aria-hidden': 'true'}, name); |
|||
|
|||
const svg = (cls: string, markup: string) => { |
|||
const el = h('span', {class: cls}); |
|||
el.innerHTML = markup; |
|||
return el; |
|||
}; |
|||
|
|||
const aiMark = () => h('span', {class: 'tb-ai-mark'}, icon('auto_awesome')); |
|||
|
|||
const delay = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms)); |
|||
|
|||
const wait = <T extends HTMLElement>(el: T): T => { |
|||
el.classList.add('rq-wait'); |
|||
return el; |
|||
}; |
|||
|
|||
const come = (...els: HTMLElement[]) => els.forEach(el => { |
|||
el.classList.remove('rq-wait'); |
|||
el.classList.add('rq-in'); |
|||
}); |
|||
|
|||
type Step = [number, (still: boolean) => void | Promise<void>]; |
|||
|
|||
function story(root: HTMLElement, ctx: SceneContext, steps: Step[]): void { |
|||
(async () => { |
|||
for (let n = 0; n < 40 && !root.isConnected; n++) { |
|||
await delay(50); |
|||
} |
|||
if (!root.isConnected) { |
|||
return; |
|||
} |
|||
for (const [ms, step] of steps) { |
|||
if (!ctx.still) { |
|||
await delay(ms); |
|||
} |
|||
if (!root.isConnected) { |
|||
return; |
|||
} |
|||
await step(ctx.still); |
|||
} |
|||
})(); |
|||
} |
|||
|
|||
async function typeText(el: HTMLElement, text: string, still: boolean): Promise<void> { |
|||
if (still) { |
|||
el.textContent = text; |
|||
return; |
|||
} |
|||
for (let i = 1; i <= text.length && el.isConnected; i++) { |
|||
el.textContent = text.slice(0, i); |
|||
await delay(/[\s,.?]/.test(text[i - 1]) ? 70 + Math.random() * 70 : 24 + Math.random() * 40); |
|||
} |
|||
} |
|||
|
|||
const pointer = () => svg('rq-cursor', POINTER); |
|||
|
|||
async function pointAt(cursor: HTMLElement, el: HTMLElement, still: boolean): Promise<void> { |
|||
if (still || !cursor.isConnected || !cursor.offsetParent || !el) { |
|||
return; |
|||
} |
|||
const host = cursor.offsetParent.getBoundingClientRect(); |
|||
const rect = el.getBoundingClientRect(); |
|||
cursor.classList.add('on'); |
|||
cursor.style.transform = `translate(${Math.round(rect.left - host.left + rect.width / 2)}px, ${Math.round(rect.top - host.top + rect.height / 2)}px)`; |
|||
await delay(560); |
|||
cursor.classList.add('press'); |
|||
el.classList.add('rq-pressed'); |
|||
await delay(170); |
|||
cursor.classList.remove('press'); |
|||
el.classList.remove('rq-pressed'); |
|||
} |
|||
|
|||
function composer(words: HTMLElement, o: { focus?: boolean; compact?: boolean; docked?: boolean; empty?: boolean } = {}): HTMLElement { |
|||
return q('rq-term' + (o.focus ? ' focus' : '') + (o.compact ? ' compact' : '') + (o.docked ? ' docked' : ''), |
|||
q('rq-term-in', icon('chevron_right', 'rq-pre'), h('span', {class: 'rq-term-words'}, words), |
|||
h('span', {class: 'rq-send' + (o.empty ? ' off' : '')}, icon('keyboard_return'))), |
|||
q('rq-term-foot', h('span', {class: 'rq-tool'}, icon('attach_file')), h('span', {class: 'rq-sp'}), |
|||
h('span', {class: 'rq-tool'}, icon('keyboard')))); |
|||
} |
|||
|
|||
const userMsg = (text: string | null, files?: HTMLElement[]) => |
|||
q('rq-user', files ? q('rq-files', files) : null, text ? q('rq-bubble', text) : null); |
|||
|
|||
const fileChip = (ic: string, name: string, meta: string) => |
|||
q('rq-file', h('span', {class: 'rq-file-ic', 'data-tone': 'rule'}, icon(ic)), h('span', null, h('b', null, name), h('small', null, meta))); |
|||
|
|||
function rec(kind: string, name: string, meta: string, o: { planned?: boolean; done?: boolean } = {}): HTMLElement { |
|||
const [ic, palette] = ENTITY[kind] ?? ENTITY.device; |
|||
return q('rq-rec' + (o.planned ? ' planned' : ''), |
|||
h('span', {class: 'rq-rec-tile', style: `background: var(--entity-${palette}-bg); color: var(--entity-${palette}-fg)`}, icon(ic)), |
|||
h('b', null, name), h('small', null, meta), o.done ? icon('check_circle', 'rq-rec-ok') : null); |
|||
} |
|||
|
|||
interface Ask { |
|||
text: string; |
|||
files?: () => HTMLElement[]; |
|||
reply: () => HTMLElement[]; |
|||
} |
|||
|
|||
function heroChat(ctx: SceneContext, asks: Ask[]): { words: HTMLElement; log: HTMLElement } { |
|||
const text = h('span', {class: 'rq-typed'}); |
|||
const caret = h('i', {class: 'rq-caret', 'aria-hidden': 'true'}); |
|||
const box = h('span', {class: 'rq-typing'}, text, caret); |
|||
const log = q('rq-log'); |
|||
const mine = (ask: Ask) => userMsg(ask.text, ask.files ? ask.files() : undefined); |
|||
(async () => { |
|||
for (let n = 0; n < 40 && !box.isConnected; n++) { |
|||
await delay(50); |
|||
} |
|||
if (!box.isConnected) { |
|||
return; |
|||
} |
|||
const send = box.closest('.rq-term')?.querySelector('.rq-send'); |
|||
if (ctx.still) { |
|||
caret.remove(); |
|||
text.className = 'rq-ph'; |
|||
text.textContent = ctx.t('tour.scene.cover.placeholder'); |
|||
send?.classList.add('off'); |
|||
log.classList.add('open'); |
|||
log.replaceChildren(mine(asks[1]), q('rq-agent', asks[1].reply())); |
|||
return; |
|||
} |
|||
const live = () => box.isConnected && !!box.closest('.iv-scene.on'); |
|||
for (let k = 0; live(); k = (k + 1) % asks.length) { |
|||
const ask = asks[k]; |
|||
text.textContent = ''; |
|||
box.classList.remove('sent'); |
|||
send?.classList.add('off'); |
|||
await delay(k ? 500 : 900); |
|||
send?.classList.remove('off'); |
|||
await typeText(text, ask.text, false); |
|||
await delay(550); |
|||
if (!live()) { |
|||
return; |
|||
} |
|||
send?.classList.add('press'); |
|||
await delay(140); |
|||
box.classList.add('sent'); |
|||
log.classList.add('out'); |
|||
await delay(210); |
|||
send?.classList.remove('press'); |
|||
send?.classList.add('off'); |
|||
text.textContent = ''; |
|||
box.classList.remove('sent'); |
|||
log.classList.add('open'); |
|||
log.replaceChildren(mine(ask)); |
|||
log.classList.remove('out'); |
|||
await delay(910); |
|||
if (!live()) { |
|||
return; |
|||
} |
|||
const agent = q('rq-agent'); |
|||
log.append(agent); |
|||
for (const node of ask.reply()) { |
|||
if (!live()) { |
|||
return; |
|||
} |
|||
agent.append(node); |
|||
await delay(550); |
|||
} |
|||
await delay(1500); |
|||
} |
|||
})(); |
|||
return {words: box, log}; |
|||
} |
|||
|
|||
function sceneCover(ctx: SceneContext, words: CoverWords): HTMLElement[] { |
|||
const t = (key: string) => ctx.t('tour.scene.cover.' + key); |
|||
const chat = heroChat(ctx, [ |
|||
{text: t('ask-1'), reply: () => [h('p', null, t('reply-1')), rec('device', t('record-1-name'), t('record-1-meta'))]}, |
|||
{text: t('ask-2'), reply: () => [h('p', null, t('reply-2')), rec('dashboard', t('record-2-name'), t('record-2-meta'), {done: true})]}, |
|||
{text: t('ask-3'), files: () => [fileChip('picture_as_pdf', t('file-3-name'), t('file-3-meta'))], reply: () => [h('p', null, t('reply-3'))]} |
|||
]); |
|||
return [q('rq-hero', |
|||
h('span', {class: 'iv-version'}, icon('auto_awesome'), words.pill), |
|||
h('b', {class: 'rq-hero-t'}, h('span', null, words.news), h('span', {class: 'iv-grad'}, words.title)), |
|||
chat.log, composer(chat.words, {focus: true}))]; |
|||
} |
|||
|
|||
function sceneHome(ctx: SceneContext): HTMLElement[] { |
|||
const t = (key: string) => ctx.t('tour.scene.home.' + key); |
|||
const hour = new Date().getHours(); |
|||
const day = new Date().toLocaleDateString(ctx.locale, {weekday: 'long', day: 'numeric', month: 'long'}); |
|||
const pill = (...kids: Child[]) => wait(h('span', {class: 'rq-hpill'}, ...kids)); |
|||
const critical = pill(icon('warning'), t('critical')); |
|||
const quiet = pill(t('inactive')); |
|||
const placeholder = h('span', {class: 'rq-ph'}, t('placeholder')); |
|||
const text = h('span', {class: 'rq-typed'}); |
|||
const caret = h('i', {class: 'rq-caret', 'aria-hidden': 'true'}); |
|||
const box = h('span', {class: 'rq-typing'}, placeholder); |
|||
const row = q('rq-hrow', |
|||
q('rq-hfield', icon('chevron_right', 'rq-pre'), box, h('kbd', {class: 'rq-hkey'}, '/'), h('span', {class: 'rq-send'}, icon('keyboard_return'))), |
|||
h('span', {class: 'rq-hchats'}, icon('forum'), h('span', null, t('chats')), icon('chevron_right'))); |
|||
const chat = (title: string, meta: string) => h('span', {class: 'rq-hchat'}, h('i', null), h('b', null, title), h('small', null, meta)); |
|||
const waits = wait(q('rq-hwait', h('small', null, t('waiting')), q('rq-hchatrow', chat(t('chat-1'), '12m'), chat(t('chat-2'), '2h')))); |
|||
const card = (ic: string, name: string, count: string, widths: number[]) => q('rq-hcard', h('b', null, icon(ic), name, h('small', null, count)), |
|||
widths.map(width => h('i', {style: `width: ${width}%`}))); |
|||
const cards = wait(q('rq-hcards', card('warning', t('alarms'), '26', [92, 70, 84]), card('notifications', t('notifications'), '7', [88, 62, 80]))); |
|||
const page = q('rq-home', q('rq-hdate', day), |
|||
q('rq-hgreet', aiMark(), t(hour < 12 ? 'morning' : hour < 18 ? 'afternoon' : 'evening')), |
|||
q('rq-hpills', critical, quiet), row, waits, cards); |
|||
story(page, ctx, [ |
|||
[600, () => come(critical)], |
|||
[160, () => come(quiet)], |
|||
[450, () => come(waits)], |
|||
[300, () => come(cards)], |
|||
[900, async still => { |
|||
if (still) { |
|||
return; |
|||
} |
|||
row.classList.add('typing'); |
|||
box.replaceChildren(text, caret); |
|||
await typeText(text, t('ask'), false); |
|||
}] |
|||
]); |
|||
return [page]; |
|||
} |
|||
|
|||
function sceneAnyPage(ctx: SceneContext): HTMLElement[] { |
|||
const t = (key: string) => ctx.t('tour.scene.page.' + key); |
|||
const tile = (key: string, value: string, unit: string) => q('rq-tile', h('small', null, key), |
|||
h('b', null, h('span', {class: 'v'}, value), h('span', {class: 'u'}, unit))); |
|||
const prompt = (ic: string, text: string) => q('rq-prompt', icon(ic), h('span', null, text)); |
|||
const load = tile(t('load'), '4.1', 'kW'); |
|||
const alarm = q('rq-alarm', icon('warning'), t('alarm')); |
|||
const chart = svg('rq-chart', CHART); |
|||
const ask = prompt('help_outline', t('ask')); |
|||
const body = q('rq-cbody', q('rq-empty', aiMark(), h('b', null, t('title')), q('rq-prompts', ask, prompt('add_chart', t('prompt-2'))))); |
|||
const said = wait(h('p', null, t('answer'))); |
|||
const about = wait(rec('device', t('record-name'), t('record-meta'))); |
|||
const cursor = pointer(); |
|||
const win = q('iv-window rq-dock', |
|||
q('iv-sk-page', q('rq-ptop', h('b', null, t('page')), h('small', null, t('range'))), |
|||
q('rq-dash', q('iv-sk-row', load, tile(t('today'), '96', 'kWh')), chart, alarm)), |
|||
q('rq-companion', q('rq-chead', h('b', null, t('new-chat')), h('span', {class: 'rq-sp'}), icon('close')), body, |
|||
composer(h('span', {class: 'rq-ph'}, t('title')), {compact: true, empty: true, docked: true}))); |
|||
story(win, ctx, [ |
|||
[800, () => chart.classList.add('drawn')], |
|||
[640, () => { |
|||
load.classList.add('hot'); |
|||
load.querySelector('.v').textContent = '14.2'; |
|||
}], |
|||
[380, () => alarm.classList.add('on')], |
|||
[900, still => pointAt(cursor, ask, still)], |
|||
[0, () => ask.classList.add('picked')], |
|||
[260, () => { |
|||
cursor.classList.remove('on'); |
|||
body.classList.add('said'); |
|||
const mine = userMsg(t('ask')); |
|||
body.replaceChildren(mine, q('rq-agent', said, about)); |
|||
come(mine); |
|||
}], |
|||
[650, () => come(said)], |
|||
[550, () => come(about)] |
|||
]); |
|||
return [win, cursor]; |
|||
} |
|||
|
|||
function scenePlan(ctx: SceneContext): HTMLElement[] { |
|||
const t = (key: string, params?: Record<string, unknown>) => ctx.t('tour.scene.plan.' + key, params); |
|||
const rows = ([['dashboard', 'row-1', 'dashboard'], ['rule', 'row-2', 'alarm-rule'], ['notification', 'row-3', 'notification-rule']] as const) |
|||
.map(([kind, name, type]) => { |
|||
const el = wait(rec(kind, t(name), t('planned', {type: t(type)}), {planned: true})); |
|||
const made = () => { |
|||
el.classList.remove('planned'); |
|||
el.classList.add('made'); |
|||
el.querySelector('small').textContent = t('created', {type: t(type)}); |
|||
el.append(icon('check_circle', 'rq-rec-ok')); |
|||
}; |
|||
return {el, made}; |
|||
}); |
|||
const run = h('span', {class: 'rq-btn fill sm'}, icon('play_arrow'), t('run')); |
|||
const cursor = pointer(); |
|||
const mine = userMsg(t('request')); |
|||
const head = wait(q('rq-plan-h', h('b', null, t('plan')), h('small', null, t('steps')), h('span', {class: 'rq-sp'}), run)); |
|||
const win = q('iv-window rq-col', mine, q('rq-agent rq-plan', head, rows.map(row => row.el))); |
|||
story(win, ctx, [ |
|||
[1200, () => come(head)], |
|||
[180, () => come(rows[0].el)], |
|||
[180, () => come(rows[1].el)], |
|||
[180, () => come(rows[2].el)], |
|||
[900, still => pointAt(cursor, run, still)], |
|||
[0, () => { |
|||
run.classList.add('busy'); |
|||
run.replaceChildren(t('running')); |
|||
}], |
|||
[260, () => cursor.classList.remove('on')], |
|||
[420, () => rows[0].made()], |
|||
[520, () => rows[1].made()], |
|||
[520, () => { |
|||
rows[2].made(); |
|||
run.classList.remove('busy'); |
|||
run.classList.add('done'); |
|||
run.replaceChildren(icon('check'), t('done')); |
|||
}] |
|||
]); |
|||
return [win, cursor]; |
|||
} |
|||
|
|||
function sceneAsk(ctx: SceneContext): HTMLElement[] { |
|||
const t = (key: string) => ctx.t('tour.scene.ask.' + key); |
|||
const chip = (text: string, on?: boolean) => h('span', {class: 'rq-chip' + (on ? ' on' : '')}, text); |
|||
const count = h('small', null, t('count-1')); |
|||
const next = h('span', {class: 'rq-btn fill'}, icon('arrow_forward'), t('next')); |
|||
const first = [chip(t('option-1-1')), chip(t('option-1-2')), chip(t('option-1-3')), chip(t('other'))]; |
|||
const said = q('rq-said'); |
|||
const ask = q('rq-ask-q', h('b', null, t('question-1')), h('span', null, t('why-1'))); |
|||
const chips = q('rq-chips', first); |
|||
const hint = h('p', {class: 'rq-ask-hint'}, t('hint-1')); |
|||
const cursor = pointer(); |
|||
const card = q('rq-review rq-ask', q('rq-rev-head', icon('help_outline'), t('needs-answer'), count), said, ask, chips, hint, |
|||
q('rq-actions', next, h('span', {class: 'rq-sp'}), h('span', {class: 'rq-btn text'}, t('skip')))); |
|||
story(card, ctx, [ |
|||
[1300, still => pointAt(cursor, first[1], still)], |
|||
[0, () => first[1].classList.add('on')], |
|||
[550, still => pointAt(cursor, next, still)], |
|||
[0, () => { |
|||
cursor.classList.remove('on'); |
|||
count.textContent = t('count-2'); |
|||
said.replaceChildren(icon('check'), h('span', null, t('said')), h('b', null, t('option-1-2'))); |
|||
said.classList.add('on'); |
|||
ask.replaceChildren(h('b', null, t('question-2')), h('span', null, t('why-2'))); |
|||
chips.replaceChildren(chip(t('option-2-1')), chip(t('option-2-2'), true), chip(t('option-2-3')), chip(t('other'))); |
|||
hint.textContent = t('hint-2'); |
|||
next.replaceChildren(icon('check'), t('done')); |
|||
come(ask, chips, hint); |
|||
}] |
|||
]); |
|||
return [card, cursor]; |
|||
} |
|||
|
|||
function sceneFiles(ctx: SceneContext): HTMLElement[] { |
|||
const t = (key: string) => ctx.t('tour.scene.files.' + key); |
|||
const span = (cls: string, text: string) => h('span', {class: 'hl-' + cls}, text); |
|||
const code: Child[][] = [ |
|||
[span('flag', '#include'), ' ', span('str', '"SHT31.h"')], |
|||
[span('key', 'SHT31'), ' sensor;'], |
|||
[''], |
|||
[span('key', 'void'), ' ', span('cmd', 'loop'), '() {'], |
|||
[' ', span('key', 'float'), ' t = sensor.', span('cmd', 'getTemperature'), '();'], |
|||
[' ', span('cmd', 'publish'), '(', span('str', '"temperature"'), ', t);'], |
|||
[' ', span('cmd', 'delay'), '(', span('num', '30000'), ');'], |
|||
['}'] |
|||
]; |
|||
const lines = code.map((parts, k) => h('div', {class: 'rq-ln'}, h('i', null, String(k + 1)), h('span', null, ...parts))); |
|||
const tile = ([name, ic, palette]: string[]) => wait(q('rq-ft', |
|||
h('span', {class: 'rq-file-ic', style: `background: var(--entity-${palette}-bg); color: var(--entity-${palette}-fg)`}, icon(ic)), h('b', null, name))); |
|||
const ins = [['SHT31.pdf', 'picture_as_pdf', 'rule'], ['wiring.jpg', 'image', 'path'], ['stores.xlsx', 'table_chart', 'view'], |
|||
['registers.csv', 'grid_on', 'view'], ['serial.log', 'subject', 'people']].map(tile); |
|||
const outs = [['sht31.ino', 'code', 'chain'], ['decoder.js', 'integration_instructions', 'chain'], ['config.json', 'data_object', 'device'], |
|||
['compose.yml', 'tune', 'device'], ['setup.md', 'description', 'people']].map(tile); |
|||
const group = (label: string, tiles: HTMLElement[], cls: string) => q('rq-fgroup ' + cls, h('small', null, label), q('rq-ftiles', tiles)); |
|||
const cursor = pointer(); |
|||
const win = q('iv-window rq-files-w', |
|||
q('rq-fgrid', group(t('in'), ins, 'in'), group(t('out'), outs, 'out')), |
|||
q('rq-code', q('rq-code-head', icon('code'), h('b', null, 'sht31.ino'), h('span', {class: 'rq-sp'}), icon('search'), |
|||
h('span', {class: 'rq-code-edit'}, t('edit'))), q('rq-code-body', lines))); |
|||
story(win, ctx, [ |
|||
[450, async still => { |
|||
for (const el of [...ins, ...outs]) { |
|||
if (!el.isConnected) { |
|||
return; |
|||
} |
|||
come(el); |
|||
if (!still) { |
|||
await delay(55); |
|||
} |
|||
} |
|||
}], |
|||
[650, still => pointAt(cursor, outs[0], still)], |
|||
[0, () => outs[0].classList.add('on')], |
|||
[220, () => win.classList.add('open')], |
|||
[380, async still => { |
|||
cursor.classList.remove('on'); |
|||
for (const line of lines) { |
|||
if (!line.isConnected) { |
|||
return; |
|||
} |
|||
line.classList.add('w'); |
|||
if (!still) { |
|||
await delay(70); |
|||
} |
|||
} |
|||
}] |
|||
]); |
|||
return [win, cursor]; |
|||
} |
|||
|
|||
export interface CoverWords { |
|||
pill: string; |
|||
news: string; |
|||
title: string; |
|||
} |
|||
|
|||
export const WELCOME_CARDS = 5; |
|||
|
|||
export function buildScene(n: number, ctx: SceneContext, words: CoverWords): HTMLElement { |
|||
const tone = TONES[n]; |
|||
const frame = h('div', { |
|||
class: 'iv-canvas iv-scene ' + (!n ? 'ai-field' : tone === 'sky' ? 'ai-field iv-sky' : 'iv-tone'), |
|||
'data-level': n ? null : 'tile', |
|||
'data-motion': n ? null : 'live', |
|||
'data-tone': n && tone !== 'sky' ? tone : null, |
|||
'data-scene': String(n), |
|||
'aria-hidden': 'true' |
|||
}); |
|||
const parts = [() => sceneCover(ctx, words), () => sceneHome(ctx), () => sceneAnyPage(ctx), () => scenePlan(ctx), |
|||
() => sceneAsk(ctx), () => sceneFiles(ctx)][n](); |
|||
append(frame, parts); |
|||
return frame; |
|||
} |
|||
@ -0,0 +1,139 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc. |
|||
// SPDX-License-Identifier: BUSL-1.1 |
|||
.tb-popover.tb-tour-popover { |
|||
> .tb-popover-content > .tb-popover-arrow { |
|||
width: 12px; |
|||
height: 12px; |
|||
border: 0; |
|||
background: var(--tb-surface, #fff); |
|||
box-shadow: -1px -1px 0 rgba(0, 0, 0, 0.04); |
|||
} |
|||
|
|||
&.tb-popover-placement-bottom, &.tb-popover-placement-bottomLeft, &.tb-popover-placement-bottomRight { |
|||
> .tb-popover-content > .tb-popover-arrow { |
|||
top: 4px; |
|||
} |
|||
} |
|||
|
|||
&.tb-popover-placement-top, &.tb-popover-placement-topLeft, &.tb-popover-placement-topRight { |
|||
> .tb-popover-content > .tb-popover-arrow { |
|||
bottom: 4px; |
|||
box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.04); |
|||
} |
|||
} |
|||
|
|||
&.tb-popover-placement-right, &.tb-popover-placement-rightTop, &.tb-popover-placement-rightBottom { |
|||
> .tb-popover-content > .tb-popover-arrow { |
|||
left: 4px; |
|||
box-shadow: -1px 1px 0 rgba(0, 0, 0, 0.04); |
|||
} |
|||
} |
|||
|
|||
&.tb-popover-placement-left, &.tb-popover-placement-leftTop, &.tb-popover-placement-leftBottom { |
|||
> .tb-popover-content > .tb-popover-arrow { |
|||
right: 4px; |
|||
box-shadow: 1px -1px 0 rgba(0, 0, 0, 0.04); |
|||
} |
|||
} |
|||
|
|||
.tb-popover-inner { |
|||
border-radius: 14px; |
|||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(16, 24, 40, 0.14), 0 24px 56px rgba(16, 24, 40, 0.16); |
|||
} |
|||
|
|||
.tb-popover-inner-content { |
|||
padding: 20px 48px 16px 24px; |
|||
} |
|||
} |
|||
|
|||
.tb-tour-popup { |
|||
display: flex; |
|||
flex-direction: column; |
|||
gap: 8px; |
|||
width: min(288px, calc(100vw - 88px)); |
|||
|
|||
.tb-tour-popup-title { |
|||
margin: 0; |
|||
font: 500 17px/24px var(--tb-font, Roboto, sans-serif); |
|||
letter-spacing: 0; |
|||
color: var(--tb-ink, rgba(0, 0, 0, 0.87)); |
|||
} |
|||
|
|||
.tb-tour-popup-x.mat-mdc-icon-button.mat-mdc-button-base { |
|||
--mdc-icon-button-state-layer-size: 32px; |
|||
--mat-icon-button-state-layer-size: 32px; |
|||
position: absolute; |
|||
top: 12px; |
|||
right: 12px; |
|||
display: inline-flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
width: 32px; |
|||
height: 32px; |
|||
padding: 4px; |
|||
border-radius: 50%; |
|||
color: var(--tb-ink-54, rgba(0, 0, 0, 0.54)); |
|||
|
|||
.mat-icon { |
|||
font-size: 24px; |
|||
width: 24px; |
|||
height: 24px; |
|||
} |
|||
|
|||
.mat-mdc-button-touch-target { |
|||
width: 32px; |
|||
height: 32px; |
|||
} |
|||
} |
|||
|
|||
.tb-tour-popup-text { |
|||
margin: 0; |
|||
font: 400 14px/20px var(--tb-font, Roboto, sans-serif); |
|||
letter-spacing: 0; |
|||
color: var(--tb-ink-76, rgba(0, 0, 0, 0.76)); |
|||
|
|||
kbd { |
|||
display: inline-block; |
|||
min-width: 18px; |
|||
padding: 0 5px; |
|||
border-radius: 4px; |
|||
background: var(--chat-key, #f6f8f8); |
|||
box-shadow: inset 0 -1px 0 var(--tb-line, rgba(0, 0, 0, 0.12)); |
|||
font: 500 12px/18px var(--tb-font, Roboto, sans-serif); |
|||
text-align: center; |
|||
color: var(--tb-ink, rgba(0, 0, 0, 0.87)); |
|||
} |
|||
} |
|||
|
|||
.tb-tour-popup-actions { |
|||
display: flex; |
|||
justify-content: flex-end; |
|||
align-items: center; |
|||
gap: 8px; |
|||
margin: 4px -28px 0 0; |
|||
|
|||
.mdc-button { |
|||
height: 36px; |
|||
padding: 0 14px; |
|||
border-radius: 8px; |
|||
} |
|||
} |
|||
|
|||
.tb-tour-popup-count { |
|||
margin-right: auto; |
|||
font: 400 14px/20px var(--tb-font, Roboto, sans-serif); |
|||
color: var(--tb-text-secondary, rgba(0, 0, 0, 0.6)); |
|||
} |
|||
|
|||
.tb-tour-popup-go { |
|||
--mat-button-filled-container-color: var(--ai-action); |
|||
--mdc-filled-button-container-color: var(--ai-action); |
|||
--mat-button-filled-label-text-color: var(--ai-on-action); |
|||
--mdc-filled-button-label-text-color: var(--ai-on-action); |
|||
} |
|||
|
|||
.tb-tour-popup-skip { |
|||
--mat-button-text-label-text-color: var(--tb-ink); |
|||
--mdc-text-button-label-text-color: var(--tb-ink); |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-tour-popup', |
|||
template: ` |
|||
<div class="tb-tour-popup" data-ai role="dialog" [attr.aria-labelledby]="titleId"> |
|||
<h2 class="tb-tour-popup-title" [id]="titleId">{{ title }}</h2> |
|||
@if (closable) { |
|||
<button mat-icon-button type="button" class="tb-tour-popup-x" [attr.aria-label]="'action.close' | translate" (click)="closed.emit()"> |
|||
<mat-icon fontSet="material-icons-round">close</mat-icon> |
|||
</button> |
|||
} |
|||
<p class="tb-tour-popup-text" [innerHTML]="text"></p> |
|||
<div class="tb-tour-popup-actions"> |
|||
@if (count) { |
|||
<span class="tb-tour-popup-count">{{ count }}</span> |
|||
} |
|||
@if (skipLabel) { |
|||
<button mat-button type="button" class="tb-tour-popup-skip" (click)="skip.emit()">{{ skipLabel }}</button> |
|||
} |
|||
<button mat-flat-button type="button" class="tb-tour-popup-go" (click)="next.emit()">{{ nextLabel }}</button> |
|||
</div> |
|||
</div> |
|||
`,
|
|||
styleUrls: ['./tour-popup.component.scss'], |
|||
encapsulation: ViewEncapsulation.None, |
|||
standalone: false, |
|||
changeDetection: ChangeDetectionStrategy.OnPush |
|||
}) |
|||
export class TourPopupComponent { |
|||
|
|||
private static count = 0; |
|||
|
|||
readonly titleId = 'tb-tour-popup-title-' + (++TourPopupComponent.count); |
|||
|
|||
@Input() title: string; |
|||
|
|||
@Input() text: string; |
|||
|
|||
@Input() count: string | null = null; |
|||
|
|||
@Input() skipLabel: string | null = null; |
|||
|
|||
@Input() nextLabel: string; |
|||
|
|||
@Input() closable = true; |
|||
|
|||
@Output() next = new EventEmitter<void>(); |
|||
|
|||
@Output() skip = new EventEmitter<void>(); |
|||
|
|||
@Output() closed = new EventEmitter<void>(); |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
import { Injectable, Renderer2, ViewContainerRef } from '@angular/core'; |
|||
import { TbPopoverService } from '@shared/components/popover.service'; |
|||
import { TbPopoverComponent } from '@shared/components/popover.component'; |
|||
import { PopoverPreferredPlacement } from '@shared/components/popover.models'; |
|||
import { TourPopupComponent } from '@shared/components/tour/tour-popup.component'; |
|||
|
|||
export interface TourPopupConfig { |
|||
target: Element; |
|||
hostView: ViewContainerRef; |
|||
renderer: Renderer2; |
|||
placement: PopoverPreferredPlacement; |
|||
title: string; |
|||
text: string; |
|||
nextLabel: string; |
|||
count?: string | null; |
|||
skipLabel?: string | null; |
|||
closable?: boolean; |
|||
onNext?: () => void; |
|||
onSkip?: () => void; |
|||
onClose?: () => void; |
|||
onHidden?: () => void; |
|||
} |
|||
|
|||
export const escapeTourText = (text: string): string => |
|||
text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); |
|||
|
|||
export interface TourPopupRef { |
|||
close(): void; |
|||
} |
|||
|
|||
@Injectable() |
|||
export class TourPopupService { |
|||
|
|||
constructor(private popoverService: TbPopoverService) {} |
|||
|
|||
show(config: TourPopupConfig): TourPopupRef { |
|||
let open = true; |
|||
const popover: TbPopoverComponent<TourPopupComponent> = this.popoverService.displayPopover({ |
|||
trigger: config.target, |
|||
renderer: config.renderer, |
|||
componentType: TourPopupComponent, |
|||
hostView: config.hostView, |
|||
preferredPlacement: config.placement, |
|||
hideOnClickOutside: false, |
|||
showCloseButton: false, |
|||
context: { |
|||
title: config.title, |
|||
text: config.text, |
|||
nextLabel: config.nextLabel, |
|||
count: config.count ?? null, |
|||
skipLabel: config.skipLabel ?? null, |
|||
closable: config.closable ?? true |
|||
}, |
|||
visibleFn: visible => { |
|||
if (!visible && open) { |
|||
open = false; |
|||
config.onHidden?.(); |
|||
} |
|||
} |
|||
}); |
|||
popover.tbOverlayClassName = 'tb-tour-popover'; |
|||
popover.updateStyles(); |
|||
const instance = popover.tbComponentRef.instance; |
|||
instance.next.subscribe(() => config.onNext?.()); |
|||
instance.skip.subscribe(() => config.onSkip?.()); |
|||
instance.closed.subscribe(() => config.onClose?.()); |
|||
return { |
|||
close: () => { |
|||
if (open) { |
|||
open = false; |
|||
popover.hide(); |
|||
} |
|||
} |
|||
}; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue