From b56e62caec1985bfda5452eaa66cbbff5375bcea Mon Sep 17 00:00:00 2001
From: brios <127139797+balazs-szucs@users.noreply.github.com>
Date: Tue, 11 Aug 2026 16:17:36 +0200
Subject: [PATCH] refactor(sidebar): Replace custom sidebars (bookmark,
attachment etc...) with reusable sidebar component (#7143)
# Description of Changes
This helps keeps them consistent and similar/same in regards to design,
colour scheme and so on. Generally, we would want to improve upon this,
as UX bit lacking here and there e.g., with the button
fluidness/conssitency what the button does. Bookmark open sidebar
editor, the other two redirects to the page, those may be made more
consistent.
Changes:
* Refactored `AttachmentSidebar`, `BookmarkSidebar`, and
`CommentsSidebar` to use the new `SidebarBase` component, replacing
custom header, search, and layout code for a more consistent and
maintainable UI.
* Added search functionality to `CommentsSidebar`, including filtering
by comment content and author, and displaying a message when no comments
match the search.
* Updated search placeholders and empty state messages for attachments,
bookmarks, and comments to use translation keys, improving localization
and user feedback.
### New
### Old
---
## Checklist
### General
- [X] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [X] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [X] I have performed a self-review of my own code
- [X] My changes generate no new warnings
### Documentation
- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)
### Translations (if applicable)
- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)
### UI Changes (if applicable)
- [X] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)
### Testing (if applicable)
- [X] I have run `task check` to verify linters, typechecks, and tests
pass
- [X] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing)
for more details.
---
.../public/locales/en-US/translation.toml | 6 +
.../components/viewer/AttachmentSidebar.tsx | 282 +++++------
.../components/viewer/BookmarkSidebar.tsx | 454 ++++++++----------
.../components/viewer/CommentsSidebar.tsx | 386 ++++++++-------
.../core/components/viewer/EmbedPdfViewer.tsx | 2 +-
.../core/components/viewer/LayerSidebar.tsx | 192 +++-----
.../core/components/viewer/SidebarBase.tsx | 121 +++++
7 files changed, 709 insertions(+), 734 deletions(-)
create mode 100644 frontend/editor/src/core/components/viewer/SidebarBase.tsx
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml
index 58e667e4e9..ed1b61e098 100644
--- a/frontend/editor/public/locales/en-US/translation.toml
+++ b/frontend/editor/public/locales/en-US/translation.toml
@@ -11328,12 +11328,15 @@ searchPlaceholder = "Search attachments"
title = "Attachments"
[viewer.bookmarks]
+addBookmark = "Add bookmark"
bookmarkTitle = "Bookmark title"
bookmarkTitleRequired = "Bookmark title is required"
closeSidebar = "Close bookmarks sidebar"
collapseAll = "Collapse all bookmarks"
+empty = "No bookmarks in this document"
expandAll = "Expand all bookmarks"
searchPlaceholder = "Search bookmarks"
+title = "Bookmarks"
[viewer.comments]
addComment = "Add comment"
@@ -11355,10 +11358,12 @@ locateAnnotation = "Locate in document"
moreActions = "More actions"
nComments_one = "{{count}} comment"
nComments_other = "{{count}} comments"
+noMatch = "No comments match your search"
pageLabel = "Page {{page}}"
placingHint = "Click a page to place… (cancel)"
removeCommentOnly = "Remove comment only"
saveReply = "Save reply"
+searchPlaceholder = "Search comments"
title = "Comments"
typeComment = "Comment"
typeInsertText = "Insert Text"
@@ -11381,6 +11386,7 @@ unsavedDesc = "You have unsaved changes"
closeSidebar = "Close layers sidebar"
hideAll = "Hide all layers"
showAll = "Show all layers"
+title = "Layers"
[viewer.link]
delete = "Delete link"
diff --git a/frontend/editor/src/core/components/viewer/AttachmentSidebar.tsx b/frontend/editor/src/core/components/viewer/AttachmentSidebar.tsx
index 4dcc61fe2b..fe0bd8414b 100644
--- a/frontend/editor/src/core/components/viewer/AttachmentSidebar.tsx
+++ b/frontend/editor/src/core/components/viewer/AttachmentSidebar.tsx
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useRef, useState, useCallback } from "react";
-import { Box, ScrollArea, Text, Loader, Stack, TextInput } from "@mantine/core";
+import { Text, Loader, Stack } from "@mantine/core";
import LocalIcon from "@app/components/shared/LocalIcon";
import { Button } from "@app/ui/Button";
import { ActionIcon } from "@app/ui/ActionIcon";
@@ -9,7 +9,7 @@ import { PdfAttachmentObject } from "@embedpdf/models";
import AttachmentIcon from "@mui/icons-material/AttachmentRounded";
import DownloadIcon from "@mui/icons-material/DownloadRounded";
import { useTranslation } from "react-i18next";
-import "@app/components/viewer/SidebarBase.css";
+import { SidebarBase } from "@app/components/viewer/SidebarBase";
import "@app/components/viewer/AttachmentSidebar.css";
interface AttachmentSidebarProps {
@@ -20,8 +20,6 @@ interface AttachmentSidebarProps {
preloadCacheKeys?: string[];
}
-const SIDEBAR_WIDTH = "15rem";
-
interface AttachmentCacheEntry {
status: "idle" | "loading" | "success" | "error";
attachments: PdfAttachmentObject[] | null;
@@ -360,179 +358,129 @@ export const AttachmentSidebar = ({
const showNoDocument = attachmentSupport && !documentCacheKey;
return (
- }
+ rightOffset={`${(thumbnailVisible ? 15 : 0) + (bookmarkVisible ? 15 : 0)}rem`}
+ visible={visible}
+ onClose={toggleAttachmentSidebar}
+ closeLabel={t(
+ "viewer.attachments.closeSidebar",
+ "Close attachments sidebar",
+ )}
+ searchTerm={searchTerm}
+ searchPlaceholder={t(
+ "viewer.attachments.searchPlaceholder",
+ "Search attachments",
+ )}
+ onSearchChange={setSearchTerm}
>
-