@bbki.ng/site 5.1.4 → 5.2.1

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.2.1
4
+
5
+ ## 5.2.0
6
+
3
7
  ## 5.1.4
4
8
 
5
9
  ## 5.1.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.1.4",
3
+ "version": "5.2.1",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,8 +20,8 @@
20
20
  "sonner": "1.4.0",
21
21
  "swr": "^2.2.5",
22
22
  "vaul": "1.1.2",
23
- "@bbki.ng/components": "5.1.3",
24
- "@bbki.ng/stylebase": "3.0.2"
23
+ "@bbki.ng/components": "5.2.1",
24
+ "@bbki.ng/stylebase": "3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@mdx-js/mdx": "2.0.0-next.9",
@@ -59,7 +59,7 @@
59
59
  "vite-plugin-mdx": "^3.5.8",
60
60
  "vite-plugin-pwa": "0.19",
61
61
  "workbox-window": "^6.3.0",
62
- "@bbki.ng/stylebase": "3.0.2"
62
+ "@bbki.ng/stylebase": "3.1.0"
63
63
  },
64
64
  "author": "bbbottle",
65
65
  "license": "MIT",
@@ -4,6 +4,7 @@ import { ROUTES } from "@/constants";
4
4
  import classNames from "classnames";
5
5
  import { Reaction } from "../reaction/oh_reaction";
6
6
  import { useNavigate } from "react-router-dom";
7
+ import { ShareBtn } from "../share/share-btn";
7
8
 
8
9
  export type ArticlePageProps = {
9
10
  tags?: string[];
@@ -41,9 +42,9 @@ export const ArticlePage = (props: ArticlePageProps) => {
41
42
  loading={false}
42
43
  >
43
44
  <article className={articleCls}>{props.children}</article>
44
- <div className="relative left-[-4px]">
45
+ <div className="relative -left-8">
45
46
  {allTags.length ? <Tags tags={allTags} className="mb-32" /> : null}
46
- <Reaction title={title} />
47
+ <Reaction title={title} url={window.location.href} />
47
48
  </div>
48
49
  </Article>
49
50
  <div className="">
@@ -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
- };
@@ -25,8 +25,6 @@ export { CornerPromptBox } from "./corner_prompt_box";
25
25
 
26
26
  export { Tags } from "./tags";
27
27
 
28
- export { Comment } from "./comment";
29
-
30
28
  export { MySuspense } from "./my_suspense";
31
29
 
32
30
  export const CenterLinkList = (props: any) => {
@@ -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,8 +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
+ import { ShareBtn } from "../share/share-btn";
12
+ import { CommentBtn } from "../comment/comment-btn";
11
13
 
12
14
  declare global {
13
15
  namespace JSX {
@@ -70,28 +72,37 @@ export const OpenHeartReaction = (props: {
70
72
 
71
73
  return (
72
74
  <open-heart
73
- style={{
74
- display: "inline-flex",
75
- padding: 4,
76
- marginRight: "4px",
77
- position: "relative",
78
- }}
79
75
  ref={ohRef}
80
76
  href={`https://oh.bbki.ng/?id=${title}`}
81
77
  emoji={emojiPair.val}
82
- onClick={handleHeartClick}
83
78
  >
84
- {sent || pressed() ? emojiPair.on : emojiPair.off}
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>
85
87
  </open-heart>
86
88
  );
87
89
  };
88
90
 
89
- export const Reaction = (props: { title: string }) => {
91
+ export const Reaction = (props: { title: string; url: string }) => {
90
92
  return (
91
- <div>
93
+ <div className="flex items-center">
92
94
  <OpenHeartReaction title={props.title} emojiPair={hearts} />
93
95
  <OpenHeartReaction title={props.title} emojiPair={faces} />
94
96
  <OpenHeartReaction title={props.title} emojiPair={sadFaces} />
97
+
98
+ <ShareBtn
99
+ shareInfo={{
100
+ title: props.title,
101
+ url: props.url,
102
+ }}
103
+ />
104
+
105
+ {/*<CommentBtn />*/}
95
106
  </div>
96
107
  );
97
108
  };
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { Button, ButtonType } from "@bbki.ng/components";
3
+ import { ShareIcon } from "./share-icon";
4
+ import { toast } from "sonner";
5
+
6
+ export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
7
+ const handleShare = async () => {
8
+ try {
9
+ await navigator.share(shareInfo);
10
+ toast.success("已分享");
11
+ } catch (error) {
12
+ const isAbortError = (error as Error).name === "AbortError";
13
+ if (isAbortError) {
14
+ return;
15
+ }
16
+
17
+ toast.error((error as Error).message);
18
+ }
19
+ };
20
+
21
+ return (
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
+ >
28
+ <ShareIcon />
29
+ </Button>
30
+ );
31
+ };
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+
3
+ export const ShareIcon = () => (
4
+ <svg
5
+ data-testid="geist-icon"
6
+ height="12"
7
+ stroke-linejoin="round"
8
+ // style="color:currentColor"
9
+ viewBox="0 0 16 16"
10
+ width="12"
11
+ >
12
+ <path
13
+ fill-rule="evenodd"
14
+ clip-rule="evenodd"
15
+ d="M7.29289 1.39644C7.68342 1.00592 8.31658 1.00592 8.70711 1.39644L11.7803 4.46966L12.3107 4.99999L11.25 6.06065L10.7197 5.53032L8.75 3.56065V10.25V11H7.25V10.25V3.56065L5.28033 5.53032L4.75 6.06065L3.68934 4.99999L4.21967 4.46966L7.29289 1.39644ZM13.5 9.24999V13.5H2.5V9.24999V8.49999H1V9.24999V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.24999V8.49999H13.5V9.24999Z"
16
+ fill="currentColor"
17
+ ></path>
18
+ </svg>
19
+ );
@@ -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
- };