@bbki.ng/site 5.2.0 → 5.2.2
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/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/src/blog/components/article/index.tsx +1 -1
- package/src/blog/components/comment/comment-btn.tsx +15 -0
- package/src/blog/components/comment/comment-icon.tsx +20 -0
- package/src/blog/components/comment/index.tsx +0 -70
- package/src/blog/components/index.tsx +0 -2
- package/src/blog/components/reaction/emojis.tsx +0 -3
- package/src/blog/components/reaction/oh_reaction.tsx +13 -10
- package/src/blog/components/share/share-btn.tsx +6 -1
- package/src/blog/components/share/share-icon.tsx +0 -1
- package/src/blog/components/comment/use_cusdis_event.ts +0 -37
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbki.ng/site",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "code behind bbki.ng",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sonner": "1.4.0",
|
|
21
21
|
"swr": "^2.2.5",
|
|
22
22
|
"vaul": "1.1.2",
|
|
23
|
-
"@bbki.ng/components": "5.2.
|
|
23
|
+
"@bbki.ng/components": "5.2.1",
|
|
24
24
|
"@bbki.ng/stylebase": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@ export const ArticlePage = (props: ArticlePageProps) => {
|
|
|
42
42
|
loading={false}
|
|
43
43
|
>
|
|
44
44
|
<article className={articleCls}>{props.children}</article>
|
|
45
|
-
<div className="relative left-
|
|
45
|
+
<div className="relative -left-8">
|
|
46
46
|
{allTags.length ? <Tags tags={allTags} className="mb-32" /> : null}
|
|
47
47
|
<Reaction title={title} url={window.location.href} />
|
|
48
48
|
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, ButtonType } from "@bbki.ng/components";
|
|
3
|
+
import { CommentIcon } from "./comment-icon";
|
|
4
|
+
export const CommentBtn = () => {
|
|
5
|
+
return (
|
|
6
|
+
<Button
|
|
7
|
+
size="small"
|
|
8
|
+
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200 px-0"
|
|
9
|
+
type={ButtonType.GHOST}
|
|
10
|
+
onClick={() => {}}
|
|
11
|
+
>
|
|
12
|
+
<CommentIcon />
|
|
13
|
+
</Button>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const CommentIcon = () => {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
data-testid="geist-icon"
|
|
7
|
+
stroke-linejoin="round"
|
|
8
|
+
viewBox="0 0 16 16"
|
|
9
|
+
height="12"
|
|
10
|
+
width="12"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fill-rule="evenodd"
|
|
14
|
+
clip-rule="evenodd"
|
|
15
|
+
d="M2.8914 10.4028L2.98327 10.6318C3.22909 11.2445 3.5 12.1045 3.5 13C3.5 13.3588 3.4564 13.7131 3.38773 14.0495C3.69637 13.9446 4.01409 13.8159 4.32918 13.6584C4.87888 13.3835 5.33961 13.0611 5.70994 12.7521L6.22471 12.3226L6.88809 12.4196C7.24851 12.4724 7.61994 12.5 8 12.5C11.7843 12.5 14.5 9.85569 14.5 7C14.5 4.14431 11.7843 1.5 8 1.5C4.21574 1.5 1.5 4.14431 1.5 7C1.5 8.18175 1.94229 9.29322 2.73103 10.2153L2.8914 10.4028ZM2.8135 15.7653C1.76096 16 1 16 1 16C1 16 1.43322 15.3097 1.72937 14.4367C1.88317 13.9834 2 13.4808 2 13C2 12.3826 1.80733 11.7292 1.59114 11.1903C0.591845 10.0221 0 8.57152 0 7C0 3.13401 3.58172 0 8 0C12.4183 0 16 3.13401 16 7C16 10.866 12.4183 14 8 14C7.54721 14 7.10321 13.9671 6.67094 13.9038C6.22579 14.2753 5.66881 14.6656 5 15C4.23366 15.3832 3.46733 15.6195 2.8135 15.7653Z"
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import { ReactCusdis } from "react-cusdis";
|
|
4
|
-
import { BgColors } from "@/types/color";
|
|
5
|
-
import { CUSDIS_ATTRS, CUSDIS_OFFICIAL_SITE_ADDRESS } from "@/constants/cusdis";
|
|
6
|
-
import { useCusidsEvent } from "@/components/comment/use_cusdis_event";
|
|
7
|
-
import { CornerPromptBox } from "@/components";
|
|
8
|
-
import { Link, LinkColor } from "@bbki.ng/components";
|
|
9
|
-
|
|
10
|
-
type CommentProps = {
|
|
11
|
-
title: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const Comment = (props: CommentProps) => {
|
|
15
|
-
const path = location.href;
|
|
16
|
-
const cusdisAttrs = Object.assign({}, CUSDIS_ATTRS, {
|
|
17
|
-
pageTitle: props.title,
|
|
18
|
-
pageUrl: path,
|
|
19
|
-
pageId: path,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const [ready, setReady] = useState(false);
|
|
23
|
-
const [showBox, setShowBox] = useState(false);
|
|
24
|
-
|
|
25
|
-
useCusidsEvent({
|
|
26
|
-
handleCommentLoaded: () => {
|
|
27
|
-
setReady(true);
|
|
28
|
-
},
|
|
29
|
-
handleCommentSent: () => {
|
|
30
|
-
setShowBox(true);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div
|
|
36
|
-
className={classnames(
|
|
37
|
-
"overflow-hidden",
|
|
38
|
-
"transition-all",
|
|
39
|
-
BgColors.WHITE_GRAY,
|
|
40
|
-
{
|
|
41
|
-
"max-h-0": !ready,
|
|
42
|
-
"p-5": ready,
|
|
43
|
-
"mb-8": ready,
|
|
44
|
-
}
|
|
45
|
-
)}
|
|
46
|
-
>
|
|
47
|
-
<ReactCusdis attrs={cusdisAttrs} />
|
|
48
|
-
<CornerPromptBox
|
|
49
|
-
autoCancelAfter={3000}
|
|
50
|
-
content="评论已发送,等待 18+ 内容审核。"
|
|
51
|
-
showBox={showBox}
|
|
52
|
-
cancelLabel="关闭"
|
|
53
|
-
onCancel={() => {
|
|
54
|
-
console.log("cancel");
|
|
55
|
-
setShowBox(false);
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
<div className="text-center">
|
|
59
|
-
<Link
|
|
60
|
-
to={CUSDIS_OFFICIAL_SITE_ADDRESS}
|
|
61
|
-
external
|
|
62
|
-
color={LinkColor.GRAY}
|
|
63
|
-
className="px-1"
|
|
64
|
-
>
|
|
65
|
-
powered by discus
|
|
66
|
-
</Link>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -15,7 +15,6 @@ const heart = (
|
|
|
15
15
|
height={HEART_SIZE}
|
|
16
16
|
width={HEART_SIZE}
|
|
17
17
|
stroke-linejoin="round"
|
|
18
|
-
className="text-gray-400 hover:text-red-400 transition-colors ease-in duration-200"
|
|
19
18
|
viewBox="0 0 16 16"
|
|
20
19
|
>
|
|
21
20
|
<path
|
|
@@ -49,7 +48,6 @@ const happyFace = (
|
|
|
49
48
|
stroke-linejoin="round"
|
|
50
49
|
height={HEART_SIZE}
|
|
51
50
|
width={HEART_SIZE}
|
|
52
|
-
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
|
|
53
51
|
viewBox="0 0 16 16"
|
|
54
52
|
>
|
|
55
53
|
<path
|
|
@@ -92,7 +90,6 @@ const unhappyFace = (
|
|
|
92
90
|
viewBox="0 0 16 16"
|
|
93
91
|
height={HEART_SIZE}
|
|
94
92
|
width={HEART_SIZE}
|
|
95
|
-
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
|
|
96
93
|
>
|
|
97
94
|
<path
|
|
98
95
|
fill-rule="evenodd"
|
|
@@ -6,9 +6,10 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from "react";
|
|
8
8
|
import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
|
|
9
|
-
import { BlinkDot } from "@bbki.ng/components";
|
|
9
|
+
import { BlinkDot, Button, ButtonType } from "@bbki.ng/components";
|
|
10
10
|
import { faces, hearts, ReactionEmojiPair, sadFaces } from "./emojis";
|
|
11
11
|
import { ShareBtn } from "../share/share-btn";
|
|
12
|
+
import { CommentBtn } from "../comment/comment-btn";
|
|
12
13
|
|
|
13
14
|
declare global {
|
|
14
15
|
namespace JSX {
|
|
@@ -71,25 +72,25 @@ export const OpenHeartReaction = (props: {
|
|
|
71
72
|
|
|
72
73
|
return (
|
|
73
74
|
<open-heart
|
|
74
|
-
style={{
|
|
75
|
-
display: "inline-flex",
|
|
76
|
-
padding: 4,
|
|
77
|
-
marginRight: "4px",
|
|
78
|
-
position: "relative",
|
|
79
|
-
}}
|
|
80
75
|
ref={ohRef}
|
|
81
76
|
href={`https://oh.bbki.ng/?id=${title}`}
|
|
82
77
|
emoji={emojiPair.val}
|
|
83
|
-
onClick={handleHeartClick}
|
|
84
78
|
>
|
|
85
|
-
|
|
79
|
+
<Button
|
|
80
|
+
size="small"
|
|
81
|
+
type={ButtonType.GHOST}
|
|
82
|
+
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
|
|
83
|
+
onClick={handleHeartClick}
|
|
84
|
+
>
|
|
85
|
+
{sent || pressed() ? emojiPair.on : emojiPair.off}
|
|
86
|
+
</Button>
|
|
86
87
|
</open-heart>
|
|
87
88
|
);
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
export const Reaction = (props: { title: string; url: string }) => {
|
|
91
92
|
return (
|
|
92
|
-
<div>
|
|
93
|
+
<div className="flex items-center">
|
|
93
94
|
<OpenHeartReaction title={props.title} emojiPair={hearts} />
|
|
94
95
|
<OpenHeartReaction title={props.title} emojiPair={faces} />
|
|
95
96
|
<OpenHeartReaction title={props.title} emojiPair={sadFaces} />
|
|
@@ -100,6 +101,8 @@ export const Reaction = (props: { title: string; url: string }) => {
|
|
|
100
101
|
url: props.url,
|
|
101
102
|
}}
|
|
102
103
|
/>
|
|
104
|
+
|
|
105
|
+
{/*<CommentBtn />*/}
|
|
103
106
|
</div>
|
|
104
107
|
);
|
|
105
108
|
};
|
|
@@ -19,7 +19,12 @@ export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
|
-
<Button
|
|
22
|
+
<Button
|
|
23
|
+
size="small"
|
|
24
|
+
className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
|
|
25
|
+
type={ButtonType.GHOST}
|
|
26
|
+
onClick={handleShare}
|
|
27
|
+
>
|
|
23
28
|
<ShareIcon />
|
|
24
29
|
</Button>
|
|
25
30
|
);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { cusdisEvent } from "../../types/cusdis";
|
|
3
|
-
|
|
4
|
-
type cusdisEventHandlers = {
|
|
5
|
-
handleCommentLoaded?: () => void;
|
|
6
|
-
handleCommentSent?: () => void;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const noop = () => null;
|
|
10
|
-
|
|
11
|
-
export const useCusidsEvent = (handlers: cusdisEventHandlers) => {
|
|
12
|
-
const { handleCommentLoaded = noop, handleCommentSent = noop } = handlers;
|
|
13
|
-
const onMessage = (e: MessageEvent) => {
|
|
14
|
-
try {
|
|
15
|
-
const msg = JSON.parse(e.data);
|
|
16
|
-
if (msg.from === "cusdis") {
|
|
17
|
-
switch (msg.event) {
|
|
18
|
-
case cusdisEvent.COMMENTS_LOADED:
|
|
19
|
-
handleCommentLoaded();
|
|
20
|
-
break;
|
|
21
|
-
case cusdisEvent.COMMENT_SENT:
|
|
22
|
-
handleCommentSent();
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} catch (e) {}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
window.addEventListener("message", onMessage);
|
|
33
|
-
return () => {
|
|
34
|
-
window.removeEventListener("message", onMessage);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
};
|