@bbki.ng/site 2.0.40 → 2.0.41

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,7 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 2.0.41
4
+
3
5
  ## 2.0.40
4
6
 
5
7
  ## 2.0.39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "2.0.40",
3
+ "version": "2.0.41",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@extism/extism": "2.0.0-rc11",
20
- "@bbki.ng/components": "workspace:2.6.10",
20
+ "@bbki.ng/components": "workspace:2.6.11",
21
21
  "@supabase/supabase-js": "^1.35.4",
22
22
  "classnames": "2.3.1",
23
23
  "react": "^18.0.0",
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useCallback, useEffect, useRef } from "react";
2
2
  import { useLocation } from "react-router-dom";
3
3
 
4
4
  const SCROLL_STORAGE_KEY = "div-scroll-positions";
@@ -23,6 +23,19 @@ export function useBlogScrollReset() {
23
23
  }, []);
24
24
  }
25
25
 
26
+ export function useBlogScroll() {
27
+ const element = document.getElementById("blog");
28
+
29
+ const gotoTop = useCallback(() => {
30
+ if (!element) return;
31
+ element.scrollTop = 0;
32
+ }, [element]);
33
+
34
+ return {
35
+ gotoTop,
36
+ };
37
+ }
38
+
26
39
  export function useBlogScrollRestoration(debounceMs: number = 100) {
27
40
  const location = useLocation();
28
41
  const isFirstRender = useRef(true);
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ArticleList } from "./consts";
3
- import { LinkProps, DropZone } from "@bbki.ng/components";
3
+ import { LinkProps, DropZone, Button } from "@bbki.ng/components";
4
4
  import { usePosts } from "@/hooks/use_posts";
5
5
  import { CenterLinkList } from "@/components";
6
6
  import { useAuthed } from "@/hooks/use_authed";
@@ -8,7 +8,10 @@ import { useFile2Post } from "@/hooks/use_file_to_post";
8
8
  import { useSafeArticleLoading } from "@/hooks/use_safe_loading";
9
9
  import { useClipboardToPost } from "@/hooks/use_clipboard_to_post";
10
10
  import { useLocation } from "react-router-dom";
11
- import { useBlogScrollRestoration } from "@/hooks/use_blog_scroll_pos_restoration";
11
+ import {
12
+ useBlogScroll,
13
+ useBlogScrollRestoration,
14
+ } from "@/hooks/use_blog_scroll_pos_restoration";
12
15
 
13
16
  type TxtProps = {
14
17
  title?: string;
@@ -22,6 +25,8 @@ const Posts = (props: TxtProps) => {
22
25
 
23
26
  useBlogScrollRestoration();
24
27
 
28
+ const { gotoTop } = useBlogScroll();
29
+
25
30
  if (isLoading) {
26
31
  return null;
27
32
  }
@@ -36,6 +41,24 @@ const Posts = (props: TxtProps) => {
36
41
  <CenterLinkList
37
42
  links={props.articleList || links}
38
43
  loading={isGlobalLoading}
44
+ footer={
45
+ <Button onClick={gotoTop} className="mt-128">
46
+ <svg
47
+ data-testid="geist-icon"
48
+ height="16"
49
+ stroke-linejoin="round"
50
+ viewBox="0 0 16 16"
51
+ width="16"
52
+ >
53
+ <path
54
+ fill-rule="evenodd"
55
+ clip-rule="evenodd"
56
+ d="M8.70711 1.39644C8.31659 1.00592 7.68342 1.00592 7.2929 1.39644L2.21968 6.46966L1.68935 6.99999L2.75001 8.06065L3.28034 7.53032L7.25001 3.56065V14.25V15H8.75001V14.25V3.56065L12.7197 7.53032L13.25 8.06065L14.3107 6.99999L13.7803 6.46966L8.70711 1.39644Z"
57
+ fill="currentColor"
58
+ ></path>
59
+ </svg>
60
+ </Button>
61
+ }
39
62
  />
40
63
  );
41
64
  };