Skip to content

Commit 1b85b37

Browse files
committed
issue #997 & issue #972 - Add bookmark categories to desktop sidebar, with expand/collapse functionality
1 parent b5a69e5 commit 1b85b37

File tree

2 files changed

+137
-6
lines changed

2 files changed

+137
-6
lines changed

packages/seed-bible/app/components/Chips.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const SharePopup = ({
144144
return (
145145
<>
146146
<div
147-
onClick={() => closePopupSettings()}
147+
onClick={() => globalThis?.closePopupSettings()}
148148
style={{
149149
position: "fixed",
150150
inset: 0,
@@ -186,7 +186,7 @@ const SharePopup = ({
186186
{popupTitle}
187187
</h2>
188188
<button
189-
onClick={() => closePopupSettings()}
189+
onClick={() => globalThis?.closePopupSettings()}
190190
style={{
191191
background: "none",
192192
border: "none",

packages/seed-bible/app/components/sideBar.tsx

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,9 @@ function SideBar({ panelsNumber }) {
871871
() => masks.mobileBookmarks || { "My bookmarks": [] }
872872
);
873873
const [showBookmarksFilter, setShowBookmarksFilter] = useState(false);
874+
const [desktopExpandedCategories, setDesktopExpandedCategories] = useState<
875+
Record<string, boolean>
876+
>({});
874877
const [showBookmarkModal, setShowBookmarkModal] = useState(false);
875878
const [showNewCategoryModal, setShowNewCategoryModal] = useState(false);
876879
const [selectedTabForBookmark, setSelectedTabForBookmark] = useState<
@@ -909,6 +912,9 @@ function SideBar({ panelsNumber }) {
909912
setTagMask(thisBot, "mobileBookmarks", updated, "local");
910913
return updated;
911914
});
915+
// Auto-enable bookmarks view and expand the category so the user sees it
916+
setShowBookmarksFilter(true);
917+
setDesktopExpandedCategories((prev) => ({ ...prev, [category]: true }));
912918
setShowBookmarkModal(false);
913919
setSelectedTabForBookmark(null);
914920
};
@@ -2460,7 +2466,9 @@ function SideBar({ panelsNumber }) {
24602466
/>
24612467
)}
24622468
<div className="tabsContainer">
2463-
<span style={{ color: "var(--pageTextColor)" }}>{t("tabs")}</span>
2469+
<span style={{ color: "var(--pageTextColor)" }}>
2470+
{showBookmarksFilter ? `${t("tabs")} & Folders` : t("tabs")}
2471+
</span>
24642472
<div
24652473
style={{ display: "flex", alignItems: "center", gap: "5px" }}
24662474
>
@@ -2673,11 +2681,91 @@ function SideBar({ panelsNumber }) {
26732681
onPointerUp={handleMouseUpTab}
26742682
className={collapsed ? "tabs-collapsed" : "tabs"}
26752683
>
2684+
{/* Bookmark folders (when bookmark filter is active) */}
2685+
{showBookmarksFilter &&
2686+
!collapsed &&
2687+
Object.entries(bookmarks).map(
2688+
([categoryName, tabIds]: [string, any]) => (
2689+
<div key={categoryName} className="desktop-bookmark-category">
2690+
<div
2691+
className="desktop-bookmark-category-header"
2692+
onClick={() =>
2693+
setDesktopExpandedCategories((prev) => ({
2694+
...prev,
2695+
[categoryName]: !prev[categoryName],
2696+
}))
2697+
}
2698+
>
2699+
<span className="desktop-bookmark-icon">
2700+
<BookMarkIcon />
2701+
</span>
2702+
<span className="desktop-category-title">
2703+
{categoryName}
2704+
</span>
2705+
<span
2706+
className={`desktop-collapse-icon ${
2707+
desktopExpandedCategories[categoryName]
2708+
? "expanded"
2709+
: ""
2710+
}`}
2711+
>
2712+
<span className="material-symbols-outlined">
2713+
expand_more
2714+
</span>
2715+
</span>
2716+
</div>
2717+
{desktopExpandedCategories[categoryName] && (
2718+
<div className="desktop-bookmark-items">
2719+
{tabIds.length > 0 ? (
2720+
tabIds.map((tabId: any) => {
2721+
const tab = tabs.find((t: any) => t.id === tabId);
2722+
return tab ? (
2723+
<Tab
2724+
key={tab.id}
2725+
el={tab}
2726+
index={0}
2727+
onlineUsers={onlineUsers}
2728+
activeTab={activeTab}
2729+
setActiveTab={setActiveTab}
2730+
setIsDragging={setIsDragging}
2731+
setElement={setElement}
2732+
collapsed={collapsed}
2733+
editMode={editMode}
2734+
setSidebarWidth={setSidebarWidth}
2735+
setCollapsed={setCollapsed}
2736+
isBookmarked={true}
2737+
onBookmarkClick={(tabId: string) => {
2738+
handleRemoveBookmark(tabId);
2739+
}}
2740+
/>
2741+
) : null;
2742+
})
2743+
) : (
2744+
<div
2745+
style={{
2746+
padding: "8px 16px",
2747+
color: "var(--text2)",
2748+
fontSize: "13px",
2749+
}}
2750+
>
2751+
No bookmarks in this category
2752+
</div>
2753+
)}
2754+
</div>
2755+
)}
2756+
</div>
2757+
)
2758+
)}
2759+
{/* Divider between bookmark folders and free tabs */}
2760+
{showBookmarksFilter &&
2761+
!collapsed &&
2762+
Object.keys(bookmarks).length > 0 && (
2763+
<div className="sidebarLine" style={{ margin: "6px 0" }}></div>
2764+
)}
2765+
{/* Tabs: always hide bookmarked tabs from the main list (they live inside bookmark folders) */}
26762766
{tabs
26772767
.filter((tab) => !tab.sharedTab)
2678-
.filter(
2679-
(tab) => !showBookmarksFilter || bookmarkedTabIds.has(tab.id)
2680-
)
2768+
.filter((tab) => !bookmarkedTabIds.has(tab.id))
26812769
.filter((tab) => {
26822770
if (!searchQuery) return true;
26832771
const query = searchQuery.toLowerCase();
@@ -3286,6 +3374,49 @@ const sidebarStyles = `
32863374
background: rgba(0, 0, 0, 0.06);
32873375
}
32883376
3377+
/* Desktop bookmark category folders */
3378+
.desktop-bookmark-category {
3379+
margin-bottom: 2px;
3380+
}
3381+
.desktop-bookmark-category-header {
3382+
display: flex;
3383+
align-items: center;
3384+
gap: 8px;
3385+
padding: 8px 10px;
3386+
cursor: pointer;
3387+
border-radius: 6px;
3388+
user-select: none;
3389+
font-weight: 500;
3390+
font-size: 14px;
3391+
color: var(--pageTextColor);
3392+
}
3393+
.desktop-bookmark-category-header:hover {
3394+
background: rgba(0, 0, 0, 0.04);
3395+
}
3396+
.desktop-bookmark-icon {
3397+
display: flex;
3398+
align-items: center;
3399+
flex-shrink: 0;
3400+
}
3401+
.desktop-category-title {
3402+
flex: 1;
3403+
overflow: hidden;
3404+
text-overflow: ellipsis;
3405+
white-space: nowrap;
3406+
}
3407+
.desktop-collapse-icon {
3408+
display: flex;
3409+
align-items: center;
3410+
transition: transform 0.2s;
3411+
transform: rotate(-90deg);
3412+
}
3413+
.desktop-collapse-icon.expanded {
3414+
transform: rotate(0deg);
3415+
}
3416+
.desktop-bookmark-items {
3417+
padding-left: 8px;
3418+
}
3419+
32893420
/* Desktop bookmark modals */
32903421
.desktop-modal-overlay {
32913422
position: fixed;

0 commit comments

Comments
 (0)