sprintify-ui 0.5.9 → 0.5.11

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.
@@ -3,6 +3,7 @@ interface Notification {
3
3
  id: string;
4
4
  text: string;
5
5
  to?: RouteLocationRaw;
6
+ read?: boolean;
6
7
  created_at?: string;
7
8
  }
8
9
  export { Notification };
@@ -148,6 +148,7 @@ export interface Notification {
148
148
  * App Notification
149
149
  */
150
150
  export interface NotificationsConfig {
151
+ count: number;
151
152
  items: AppNotification[];
152
153
  footerLabel?: string;
153
154
  footerTo?: RouteLocationRaw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -19,17 +19,17 @@
19
19
  :class="[iconClasses]"
20
20
  />
21
21
  <BaseCounter
22
- v-if="notificationsConfig.items.length"
22
+ v-if="unreadNotifications.length"
23
23
  class="absolute top-0 right-0"
24
24
  :size="counterSize"
25
- :count="notificationsConfig.items.length"
25
+ :count="unreadNotifications.length"
26
26
  />
27
27
  </div>
28
28
  </template>
29
29
 
30
30
  <template #items>
31
31
  <template
32
- v-for="notification in notificationsConfig.items"
32
+ v-for="notification in notificationsConfig.items.slice(0, 4)"
33
33
  :key="notification.id + 'link'"
34
34
  >
35
35
  <BaseLayoutNotificationItem
@@ -104,6 +104,10 @@ const props = defineProps({
104
104
  },
105
105
  });
106
106
 
107
+ const unreadNotifications = computed(() => {
108
+ return props.notificationsConfig.items.filter(i => !i.read);
109
+ });
110
+
107
111
  const breakpoints = useBreakpoints();
108
112
 
109
113
  const mobile = computed((): boolean => {
@@ -4,7 +4,8 @@
4
4
  :class="[active ? 'bg-slate-100' : '']"
5
5
  >
6
6
  <div
7
- class="text-sm leading-tight text-slate-800"
7
+ class="text-sm leading-tight"
8
+ :class="textClasses"
8
9
  v-html="notification.text"
9
10
  />
10
11
  <BaseDisplayRelativeTime
@@ -12,7 +13,10 @@
12
13
  v-slot="{ readableDate }"
13
14
  :value="notification.created_at"
14
15
  >
15
- <p class="mt-1 text-xs text-slate-400">
16
+ <p
17
+ class="mt-1 text-xs text-slate-400"
18
+ :class="[notification.read ? 'opacity-70' : 'opacity-100']"
19
+ >
16
20
  {{ readableDate }}
17
21
  </p>
18
22
  </BaseDisplayRelativeTime>
@@ -23,8 +27,15 @@
23
27
  import { Notification } from '@/types/Notification';
24
28
  import BaseDisplayRelativeTime from './BaseDisplayRelativeTime.vue';
25
29
 
26
- defineProps<{
30
+ const props = defineProps<{
27
31
  active: boolean;
28
32
  notification: Notification;
29
33
  }>();
34
+
35
+ const textClasses = computed(() => {
36
+ return props.notification.read ?
37
+ 'text-slate-500' :
38
+ "text-black font-medium before:bg-red-500 before:inline-block before:rounded-full before:mr-1 before:relative before:-top-px before:h-2 before:w-2 before:content-['']";
39
+ });
40
+
30
41
  </script>
@@ -91,12 +91,21 @@ export default {
91
91
  id: '1',
92
92
  text: 'You have a new message',
93
93
  to: '/',
94
+ read: false,
94
95
  created_at: '2022-12-08T19:16:10Z',
95
96
  },
96
97
  {
97
98
  id: '2',
98
99
  text: 'Your inbox is now full. Please empty your inbox before it goes bang.',
99
100
  to: '/',
101
+ read: true,
102
+ created_at: '2022-01-01T00:00:00',
103
+ },
104
+ {
105
+ id: '3',
106
+ text: 'You are running out of credits. Please top up your account.',
107
+ to: '/',
108
+ read: true,
100
109
  created_at: '2022-01-01T00:00:00',
101
110
  },
102
111
  ],
@@ -4,6 +4,7 @@ interface Notification {
4
4
  id: string;
5
5
  text: string;
6
6
  to?: RouteLocationRaw;
7
+ read?: boolean;
7
8
  created_at?: string;
8
9
  }
9
10
 
@@ -188,6 +188,7 @@ export interface Notification {
188
188
  */
189
189
 
190
190
  export interface NotificationsConfig {
191
+ count: number;
191
192
  items: AppNotification[];
192
193
  footerLabel?: string;
193
194
  footerTo?: RouteLocationRaw;