Skip to content

Commit

Permalink
Add a simple session manager
Browse files Browse the repository at this point in the history
For the moment, this only allows an incognito session.
  • Loading branch information
alizarazot committed May 20, 2024
1 parent 8eea2c2 commit 457d60e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/internal/session/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import iconAccountCircle from "@material-symbols/svg-400/rounded/account_circle-fill.svg";

export interface Session {
readonly nickname: string;
readonly photo: string;
}

export function currentSession(): Session {
// TODO(alizarazot): Use Firebase here.
return {
nickname: "Invitado",
photo: iconAccountCircle,
};
}
16 changes: 15 additions & 1 deletion src/my-element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { LitElement, css, html } from "lit";
import { customElement, query } from "lit/decorators.js";
import { customElement, query, state } from "lit/decorators.js";

import {
IgcIconComponent,
IgcNavDrawerComponent,
IgcNavbarComponent,
IgcAvatarComponent,
defineComponents,
registerIcon,
} from "igniteui-webcomponents";
Expand All @@ -27,6 +28,8 @@ import type { Lesson } from "internal/pane/lesson.ts";
import type { PaneHome } from "internal/pane/home.ts";
import type { PaneDiagnosticTest } from "internal/pane/diagnostic-test.ts";

import { currentSession } from "internal/session";

@customElement("my-element")
export class MyElement extends LitElement {
static override styles = css`
Expand All @@ -51,6 +54,7 @@ export class MyElement extends LitElement {
IgcIconComponent,
IgcNavbarComponent,
IgcNavDrawerComponent,
IgcAvatarComponent,
);

registerIcon("menu", iconMenu);
Expand All @@ -60,6 +64,9 @@ export class MyElement extends LitElement {
registerServiceWorker();
}

@state()
private _currentSession = currentSession();

@query("igc-nav-drawer", true)
private _navDrawer!: IgcNavDrawerComponent;

Expand All @@ -74,6 +81,13 @@ export class MyElement extends LitElement {
}}
></igc-icon>
<h1>The Sign Link</h1>
<igc-avatar
slot="end"
shape="circle"
src=${this._currentSession.photo}
alt="User photo"
>
</igc-avatar>
</igc-navbar>
<igc-nav-drawer>
Expand Down

0 comments on commit 457d60e

Please sign in to comment.