sprintify-ui 0.0.60 → 0.0.62

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.
@@ -0,0 +1,24 @@
1
+ import { Notification } from '@/types/Notification';
2
+ import { PropType } from 'vue';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ active: {
5
+ default: boolean;
6
+ type: BooleanConstructor;
7
+ };
8
+ notification: {
9
+ required: true;
10
+ type: PropType<Notification>;
11
+ };
12
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
13
+ active: {
14
+ default: boolean;
15
+ type: BooleanConstructor;
16
+ };
17
+ notification: {
18
+ required: true;
19
+ type: PropType<Notification>;
20
+ };
21
+ }>>, {
22
+ active: boolean;
23
+ }>;
24
+ export default _default;
@@ -2,7 +2,7 @@ import { RouteLocationRaw } from 'vue-router';
2
2
  interface Notification {
3
3
  id: string;
4
4
  text: string;
5
- to: RouteLocationRaw;
5
+ to?: RouteLocationRaw;
6
6
  created_at?: string;
7
7
  }
8
8
  export { Notification };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -1,32 +1,43 @@
1
1
  <template>
2
- <router-link v-slot="{ href, navigate }" custom :to="notification.to">
2
+ <router-link
3
+ v-if="notification.to"
4
+ v-slot="{ href, navigate }"
5
+ custom
6
+ :to="notification.to"
7
+ >
3
8
  <MenuItem
4
9
  v-slot="{ active }"
5
10
  as="a"
6
11
  :href="href"
7
12
  @click.prevent="onClick(navigate)"
8
13
  >
9
- <div class="px-3 py-2" :class="[active ? 'bg-slate-100' : '']">
10
- <div
11
- class="text-sm leading-tight text-slate-800"
12
- v-html="notification.text"
13
- ></div>
14
- <p v-if="createdAt" class="mt-1 text-xs text-slate-400">
15
- {{ createdAt }}
16
- </p>
17
- </div>
14
+ <BaseLayoutNotificationItemContent
15
+ :active="active"
16
+ :notification="notification"
17
+ ></BaseLayoutNotificationItemContent>
18
18
  </MenuItem>
19
19
  </router-link>
20
+ <div v-else>
21
+ <MenuItem
22
+ v-slot="{ active }"
23
+ as="button"
24
+ class="w-full text-left"
25
+ @click.prevent="onClick()"
26
+ >
27
+ <BaseLayoutNotificationItemContent
28
+ :active="active"
29
+ :notification="notification"
30
+ ></BaseLayoutNotificationItemContent>
31
+ </MenuItem>
32
+ </div>
20
33
  </template>
21
34
 
22
35
  <script lang="ts" setup>
23
36
  import { Notification } from '@/types/Notification';
24
37
  import { MenuItem } from '@headlessui/vue';
25
- import { DateTime } from 'luxon';
26
38
  import { PropType } from 'vue';
27
- import humanizeDuration from 'humanize-duration';
39
+ import BaseLayoutNotificationItemContent from './BaseLayoutNotificationItemContent.vue';
28
40
 
29
- const i18n = useI18n();
30
41
  const emit = defineEmits(['click']);
31
42
 
32
43
  const props = defineProps({
@@ -36,34 +47,10 @@ const props = defineProps({
36
47
  },
37
48
  });
38
49
 
39
- const now = ref(DateTime.now());
40
-
41
- const intervalId = setInterval(() => {
42
- now.value.plus({ second: 1 });
43
- }, 1000);
44
-
45
- const createdAt = computed(() => {
46
- if (props.notification.created_at) {
47
- const duration = DateTime.fromISO(props.notification.created_at, {
48
- zone: 'utc',
49
- }).diff(now.value).milliseconds;
50
-
51
- const durationHuman = humanizeDuration(duration, {
52
- language: i18n.locale.value,
53
- round: true,
54
- largest: 1,
55
- });
56
-
57
- return i18n.t('sui.x_ago', { duration: durationHuman });
58
- }
59
- });
60
-
61
- onBeforeUnmount(() => {
62
- clearInterval(intervalId);
63
- });
64
-
65
- function onClick(navigate: () => void) {
50
+ function onClick(navigate: (() => void) | null) {
66
51
  emit('click', props.notification);
67
- navigate();
52
+ if (navigate) {
53
+ navigate();
54
+ }
68
55
  }
69
56
  </script>
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <div class="px-3 py-2" :class="[active ? 'bg-slate-100' : '']">
3
+ <div
4
+ class="text-sm leading-tight text-slate-800"
5
+ v-html="notification.text"
6
+ ></div>
7
+ <p v-if="createdAt" class="mt-1 text-xs text-slate-400">
8
+ {{ createdAt }}
9
+ </p>
10
+ </div>
11
+ </template>
12
+
13
+ <script lang="ts" setup>
14
+ import { Notification } from '@/types/Notification';
15
+ import { DateTime } from 'luxon';
16
+ import { PropType } from 'vue';
17
+ import humanizeDuration from 'humanize-duration';
18
+
19
+ const i18n = useI18n();
20
+
21
+ const props = defineProps({
22
+ active: {
23
+ default: false,
24
+ type: Boolean,
25
+ },
26
+ notification: {
27
+ required: true,
28
+ type: Object as PropType<Notification>,
29
+ },
30
+ });
31
+
32
+ const now = ref(DateTime.now());
33
+
34
+ const intervalId = setInterval(() => {
35
+ now.value.plus({ second: 1 });
36
+ }, 1000);
37
+
38
+ const createdAt = computed(() => {
39
+ if (props.notification.created_at) {
40
+ const duration = DateTime.fromISO(props.notification.created_at, {
41
+ zone: 'utc',
42
+ }).diff(now.value).milliseconds;
43
+
44
+ const durationHuman = humanizeDuration(duration, {
45
+ language: i18n.locale.value,
46
+ round: true,
47
+ largest: 1,
48
+ });
49
+
50
+ return i18n.t('sui.x_ago', { duration: durationHuman });
51
+ }
52
+ });
53
+
54
+ onBeforeUnmount(() => {
55
+ clearInterval(intervalId);
56
+ });
57
+ </script>
@@ -77,7 +77,6 @@ export default {
77
77
  {
78
78
  id: '1',
79
79
  text: 'You have a new message',
80
- to: '/',
81
80
  created_at: '2022-01-01T00:00:00',
82
81
  },
83
82
  {
@@ -3,7 +3,7 @@ import { RouteLocationRaw } from 'vue-router';
3
3
  interface Notification {
4
4
  id: string;
5
5
  text: string;
6
- to: RouteLocationRaw;
6
+ to?: RouteLocationRaw;
7
7
  created_at?: string;
8
8
  }
9
9