@ansiversa/components 0.0.103 → 0.0.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ansiversa/components",
3
- "version": "0.0.103",
3
+ "version": "0.0.105",
4
4
  "description": "Shared UI components and layouts for the Ansiversa ecosystem",
5
5
  "type": "module",
6
6
  "exports": {
@@ -18,6 +18,7 @@ interface User {
18
18
  interface Props {
19
19
  className?: string;
20
20
  user?: User;
21
+ notificationUnreadCount?: number;
21
22
 
22
23
  /** Additional HTML attributes */
23
24
  [attrs: string]: any;
@@ -26,6 +27,7 @@ interface Props {
26
27
  const {
27
28
  className = "",
28
29
  user,
30
+ notificationUnreadCount,
29
31
  ...attrs
30
32
  } = Astro.props as Props;
31
33
 
@@ -99,6 +101,9 @@ const authLink: NavLink = {
99
101
 
100
102
  const userInitial =
101
103
  (user?.name?.charAt(0) ?? user?.email?.charAt(0) ?? "?").toUpperCase();
104
+
105
+ const unreadCount = Number(notificationUnreadCount ?? 0);
106
+ const unreadBadge = unreadCount > 99 ? "99+" : `${unreadCount}`;
102
107
  ---
103
108
 
104
109
  <div class={classAttr} {...attrs}>
@@ -162,6 +167,11 @@ const userInitial =
162
167
 
163
168
  <a href={`${ROOT_URL}/notifications`} class="av-user-menu-item av-dropdown-item" role="menuitem">
164
169
  <span>Notifications</span>
170
+ {unreadCount > 0 && (
171
+ <span class="av-badge av-badge-soft" aria-label={`${unreadBadge} unread notifications`}>
172
+ {unreadBadge}
173
+ </span>
174
+ )}
165
175
  </a>
166
176
 
167
177
  <a href={`${ROOT_URL}/favorites`} class="av-user-menu-item av-dropdown-item" role="menuitem">
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import { AvButton, AvCard } from "@ansiversa/components";
3
3
  import type { QuizDashboardSummaryV1 } from "./types";
4
+ import { buildAppUrl } from "../utils/appUrls";
4
5
 
5
6
  interface Props {
6
7
  summary: QuizDashboardSummaryV1;
@@ -14,6 +15,11 @@ const formatDateTime = (value: string | null) => {
14
15
  const date = new Date(value);
15
16
  return Number.isNaN(date.getTime()) ? "No attempts yet" : date.toLocaleString();
16
17
  };
18
+ const attemptsPrevious7d = summary.kpis.attemptsPrevious7d ?? null;
19
+ const attemptsDelta = typeof attemptsPrevious7d === "number"
20
+ ? summary.kpis.attemptsLast7d - attemptsPrevious7d
21
+ : null;
22
+ const quizBaseUrl = buildAppUrl(summary.appId);
17
23
  ---
18
24
 
19
25
  <section class="av-auth-stack-lg">
@@ -26,8 +32,8 @@ const formatDateTime = (value: string | null) => {
26
32
  <p class="av-text-soft">Last attempt: {formatDateTime(summary.kpis.lastAttemptAt)}</p>
27
33
  </div>
28
34
  <div class="av-row-wrap">
29
- <AvButton href="/quiz" size="sm">Open Quiz</AvButton>
30
- <AvButton href="/results" size="sm" variant="ghost">View Results</AvButton>
35
+ <AvButton href={quizBaseUrl} size="sm">Open Quiz</AvButton>
36
+ <AvButton href={buildAppUrl(summary.appId, "/results")} size="sm" variant="ghost">View Results</AvButton>
31
37
  </div>
32
38
  </div>
33
39
 
@@ -44,6 +50,9 @@ const formatDateTime = (value: string | null) => {
44
50
  <p class="av-card-heading">Attempts (7d)</p>
45
51
  <h3 class="av-app-card-title">{summary.kpis.attemptsLast7d}</h3>
46
52
  <p class="av-text-soft">Last 7 days</p>
53
+ <p class="av-text-soft">
54
+ vs previous 7d: {attemptsDelta === null ? "—" : `${attemptsDelta >= 0 ? "+" : ""}${attemptsDelta}`}
55
+ </p>
47
56
  </div>
48
57
  </AvCard>
49
58
  <AvCard variant="soft" className="av-card--fullheight">
@@ -6,6 +6,7 @@ export type QuizDashboardSummaryV1 = {
6
6
  kpis: {
7
7
  attemptsTotal: number;
8
8
  attemptsLast7d: number;
9
+ attemptsPrevious7d?: number | null;
9
10
  avgScorePctAllTime: number;
10
11
  bestScorePctAllTime: number;
11
12
  lastAttemptAt: string | null;
@@ -7,11 +7,13 @@ import AvNavbarActions from "../AvNavbarActions.astro";
7
7
  interface Props {
8
8
  title?: string;
9
9
  description?: string;
10
+ notificationUnreadCount?: number;
10
11
  }
11
12
 
12
13
  const {
13
14
  title = "Ansiversa",
14
15
  description = "Ansiversa – A unified ecosystem of premium Apps designed to feel simple, powerful, and delightful.",
16
+ notificationUnreadCount = 0,
15
17
  } = Astro.props;
16
18
 
17
19
  const user = Astro.locals.user;
@@ -72,7 +74,7 @@ const ROOT_URL = rawDomain.match(/^https?:\/\//i)
72
74
  <!-- Top Navigation -->
73
75
  <AvNavbar>
74
76
  <AvBrand />
75
- <AvNavbarActions user={user} />
77
+ <AvNavbarActions user={user} notificationUnreadCount={notificationUnreadCount} />
76
78
  </AvNavbar>
77
79
 
78
80
  <!-- Main content -->
@@ -0,0 +1,25 @@
1
+ const ROOT_DOMAIN = "ansiversa.com";
2
+
3
+ const MINI_APP_SLUGS = new Set(["quiz"]);
4
+
5
+ export const getAppBaseUrl = (appSlug: string) => {
6
+ if (!appSlug) {
7
+ return `https://${ROOT_DOMAIN}`;
8
+ }
9
+
10
+ if (MINI_APP_SLUGS.has(appSlug)) {
11
+ return `https://${appSlug}.${ROOT_DOMAIN}`;
12
+ }
13
+
14
+ return `https://${ROOT_DOMAIN}/${appSlug}`;
15
+ };
16
+
17
+ export const buildAppUrl = (appSlug: string, path = "/") => {
18
+ const baseUrl = getAppBaseUrl(appSlug);
19
+
20
+ if (!path || path === "/") {
21
+ return baseUrl;
22
+ }
23
+
24
+ return `${baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
25
+ };