pukaad-ui-lib 1.384.0 → 1.386.0
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/dist/module.json +1 -1
- package/dist/runtime/components/card/card-content/card-content-menu.d.vue.ts +2 -0
- package/dist/runtime/components/card/card-content/card-content-menu.vue +2 -0
- package/dist/runtime/components/card/card-content/card-content-menu.vue.d.ts +2 -0
- package/dist/runtime/components/card/card-content/card-content-time.vue +1 -1
- package/dist/runtime/components/card/card-content/card-content.vue +1 -0
- package/dist/runtime/components/card/card-reaction.vue +25 -3
- package/dist/runtime/composables/useContentCard.d.ts +1 -0
- package/dist/runtime/composables/useContentCard.js +3 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -2,6 +2,7 @@ import type { CardContentMenuState } from "#pukaad-ui/types/components/card/card
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
state?: CardContentMenuState;
|
|
4
4
|
isPinned?: boolean;
|
|
5
|
+
isLiked?: boolean;
|
|
5
6
|
isBookmarked?: boolean;
|
|
6
7
|
isShow?: boolean;
|
|
7
8
|
};
|
|
@@ -11,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
11
12
|
onAction?: ((name: string) => any) | undefined;
|
|
12
13
|
}>, {
|
|
13
14
|
isPinned: boolean;
|
|
15
|
+
isLiked: boolean;
|
|
14
16
|
isBookmarked: boolean;
|
|
15
17
|
isShow: boolean;
|
|
16
18
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -19,6 +19,7 @@ import { computed } from "vue";
|
|
|
19
19
|
const props = defineProps({
|
|
20
20
|
state: { type: String, required: false },
|
|
21
21
|
isPinned: { type: Boolean, required: false, default: false },
|
|
22
|
+
isLiked: { type: Boolean, required: false, default: false },
|
|
22
23
|
isBookmarked: { type: Boolean, required: false, default: false },
|
|
23
24
|
isShow: { type: Boolean, required: false, default: false }
|
|
24
25
|
});
|
|
@@ -38,6 +39,7 @@ const actions = computed(() => {
|
|
|
38
39
|
}
|
|
39
40
|
if (props.state === "content") {
|
|
40
41
|
return [
|
|
42
|
+
{ name: "like", icon: "lucide:heart", isActive: props.isLiked },
|
|
41
43
|
{ name: "bookmark", icon: "lucide:bookmark", isActive: props.isBookmarked },
|
|
42
44
|
{ name: "preview", icon: "lucide:tv-minimal-play" }
|
|
43
45
|
];
|
|
@@ -2,6 +2,7 @@ import type { CardContentMenuState } from "#pukaad-ui/types/components/card/card
|
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
state?: CardContentMenuState;
|
|
4
4
|
isPinned?: boolean;
|
|
5
|
+
isLiked?: boolean;
|
|
5
6
|
isBookmarked?: boolean;
|
|
6
7
|
isShow?: boolean;
|
|
7
8
|
};
|
|
@@ -11,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
11
12
|
onAction?: ((name: string) => any) | undefined;
|
|
12
13
|
}>, {
|
|
13
14
|
isPinned: boolean;
|
|
15
|
+
isLiked: boolean;
|
|
14
16
|
isBookmarked: boolean;
|
|
15
17
|
isShow: boolean;
|
|
16
18
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -39,7 +39,7 @@ const timeState = computed(() => {
|
|
|
39
39
|
color: "bg-destructive"
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const diffDays = Math.
|
|
42
|
+
const diffDays = Math.floor(target.diff(now.value, "day", true));
|
|
43
43
|
return {
|
|
44
44
|
text: `\u0E40\u0E2B\u0E25\u0E37\u0E2D ${diffDays} \u0E27\u0E31\u0E19`,
|
|
45
45
|
color: diffDays < 7 ? "bg-warning" : "bg-success"
|
|
@@ -96,7 +96,7 @@ const reactions = [
|
|
|
96
96
|
{
|
|
97
97
|
name: "bookmarked",
|
|
98
98
|
icon: "lucide:bookmark",
|
|
99
|
-
iconReacted: "
|
|
99
|
+
iconReacted: "pukaad:bookmark-solid",
|
|
100
100
|
action: toggleBookmark
|
|
101
101
|
},
|
|
102
102
|
{
|
|
@@ -128,11 +128,33 @@ async function toggleLike() {
|
|
|
128
128
|
reaction.liked = previousLiked;
|
|
129
129
|
counts.liked += previousLiked ? 1 : -1;
|
|
130
130
|
}
|
|
131
|
+
} else if (props.state === "content" && props.id) {
|
|
132
|
+
try {
|
|
133
|
+
await api(`/contents/${props.id}/like`, {
|
|
134
|
+
method: reaction.liked ? "POST" : "DELETE"
|
|
135
|
+
});
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(error);
|
|
138
|
+
reaction.liked = previousLiked;
|
|
139
|
+
counts.liked += previousLiked ? 1 : -1;
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
|
-
function toggleBookmark() {
|
|
134
|
-
|
|
143
|
+
async function toggleBookmark() {
|
|
144
|
+
const previousBookmarked = reaction.bookmarked;
|
|
145
|
+
reaction.bookmarked = !previousBookmarked;
|
|
135
146
|
counts.bookmarked += reaction.bookmarked ? 1 : -1;
|
|
147
|
+
if (props.state === "content" && props.id) {
|
|
148
|
+
try {
|
|
149
|
+
await api(`/contents/${props.id}/bookmark`, {
|
|
150
|
+
method: reaction.bookmarked ? "POST" : "DELETE"
|
|
151
|
+
});
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(error);
|
|
154
|
+
reaction.bookmarked = previousBookmarked;
|
|
155
|
+
counts.bookmarked += previousBookmarked ? 1 : -1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
136
158
|
}
|
|
137
159
|
function toggleComment() {
|
|
138
160
|
console.log("comment ");
|
|
@@ -13,9 +13,10 @@ export const mapContentToCard = (raw, options = {}) => {
|
|
|
13
13
|
const item = {
|
|
14
14
|
id: raw.id,
|
|
15
15
|
type,
|
|
16
|
-
location: place?.
|
|
16
|
+
location: place?.name || place?.address,
|
|
17
17
|
pinned: !!raw.is_pinned,
|
|
18
|
-
|
|
18
|
+
liked: !!raw.is_liked,
|
|
19
|
+
bookmarked: !!raw.is_bookmarked,
|
|
19
20
|
expireAt: options.showExpiry ? raw.expire_at : void 0
|
|
20
21
|
};
|
|
21
22
|
if (type === "postIt") {
|