Skip to content

Commit c7a95ec

Browse files
committed
hide link for small screens
1 parent bafa010 commit c7a95ec

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

frontend/components/Bookmark/BookmarkCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface BookmarkProp {
2727
*/
2828
async function addTagToBookmark(
2929
bookmark: Bookmark,
30-
tag: string
30+
tag: string,
3131
): Promise<TagAction> {
3232
let action: TagAction = {
3333
type: "add",
@@ -159,7 +159,7 @@ export default function BookmarkCard({ bookmark }: Readonly<BookmarkProp>) {
159159

160160
const isChanges = (
161161
beforeEdit: RefObject<Bookmark>,
162-
edit: RefObject<Bookmark>
162+
edit: RefObject<Bookmark>,
163163
) => {
164164
return JSON.stringify(beforeEdit.current) != JSON.stringify(edit.current);
165165
};
@@ -201,7 +201,7 @@ export default function BookmarkCard({ bookmark }: Readonly<BookmarkProp>) {
201201
const tagId = bookmark.tags[idx].id;
202202
if (currentBookmark.current) {
203203
currentBookmark.current.tags = currentBookmark.current.tags.filter(
204-
(t, i) => i !== idx
204+
(_t, i) => i !== idx,
205205
);
206206
}
207207
api.deleteTagById(bookmark.id, tagId);

frontend/components/Bookmark/CardBody.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Bookmark from "@type/Bookmarks/Bookmark";
44
import EditableField from "./EditableField";
55
import { ScrapableBookmarkToggle } from "./ScrapableToggle";
66
import style from "./bookmarkCard.module.scss";
7+
import { ScreenSizeProvider } from "@/contexts/ScreenSizeContext";
78

89
interface CardBodyProp {
910
bookmark: Readonly<Bookmark>;
@@ -22,9 +23,15 @@ export default function CardBody({
2223
}: Readonly<CardBodyProp>) {
2324
const [isScrapable, setIsScrapable] = useState(bookmark.scrapable);
2425

26+
const handleClick = () => {
27+
const isMobile = window.innerWidth < 768;
28+
if (isMobile) {
29+
window.open(bookmark.url);
30+
}
31+
};
2532
return (
2633
<Card.Body className={``}>
27-
<Card.Title className={`${style.cTitle}`}>
34+
<Card.Title className={`${style.cTitle}`} onClick={handleClick}>
2835
{inEditMode ? (
2936
<EditableField
3037
fieldValue={bookmark.title}
@@ -62,9 +69,11 @@ export default function CardBody({
6269
</div>
6370
</div>
6471
) : (
65-
<Card.Link target="_blank" href={bookmark.url}>
66-
{bookmark.url}
67-
</Card.Link>
72+
<ScreenSizeProvider>
73+
<Card.Link target="_blank" href={bookmark.url}>
74+
{bookmark.url}
75+
</Card.Link>
76+
</ScreenSizeProvider>
6877
)}
6978
{highlight ? (
7079
<div>

0 commit comments

Comments
 (0)