From cb3248117f08b5daba85a4d1f36634d7fb88f3fa Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:35:31 -0800 Subject: [PATCH] Enhancement: icons-only bookmarks style (#4384) --- docs/configs/settings.md | 16 ++++++++++++ src/components/bookmarks/group.jsx | 10 ++++++-- src/components/bookmarks/item.jsx | 39 +++++++++++++++++++++--------- src/components/bookmarks/list.jsx | 22 +++++++++++------ src/pages/index.jsx | 3 +++ 5 files changed, 69 insertions(+), 21 deletions(-) diff --git a/docs/configs/settings.md b/docs/configs/settings.md index 7e1815bb1..5fe30874f 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -118,6 +118,22 @@ As an example, this would produce the following layout: Screenshot 2022-09-15 at 8 03 57 PM +### Icons-Only Layout + +You can also specify the an icon-only layout for bookmarks, either like so: + +```yaml +layout: + Media: + iconsOnly: true +``` + +or globally: + +```yaml +bookmarksStyle: icons +``` + ### Sorting Service groups and bookmark groups can be mixed in order, **but should use different group names**. If you do not specify any bookmark groups they will all show at the bottom of the page. diff --git a/src/components/bookmarks/group.jsx b/src/components/bookmarks/group.jsx index 3a9f8323a..9deb1b6a2 100644 --- a/src/components/bookmarks/group.jsx +++ b/src/components/bookmarks/group.jsx @@ -7,7 +7,13 @@ import ErrorBoundary from "components/errorboundry"; import List from "components/bookmarks/list"; import ResolvedIcon from "components/resolvedicon"; -export default function BookmarksGroup({ bookmarks, layout, disableCollapse, groupsInitiallyCollapsed }) { +export default function BookmarksGroup({ + bookmarks, + layout, + disableCollapse, + groupsInitiallyCollapsed, + bookmarksStyle, +}) { const panel = useRef(); useEffect(() => { @@ -64,7 +70,7 @@ export default function BookmarksGroup({ bookmarks, layout, disableCollapse, gro > - + diff --git a/src/components/bookmarks/item.jsx b/src/components/bookmarks/item.jsx index 690970890..48698cc16 100644 --- a/src/components/bookmarks/item.jsx +++ b/src/components/bookmarks/item.jsx @@ -4,12 +4,17 @@ import classNames from "classnames"; import { SettingsContext } from "utils/contexts/settings"; import ResolvedIcon from "components/resolvedicon"; -export default function Item({ bookmark }) { +export default function Item({ bookmark, iconOnly = false }) { const description = bookmark.description ?? new URL(bookmark.href).hostname; const { settings } = useContext(SettingsContext); return ( -
  • +
  • -
    -
    + {iconOnly ? ( +
    {bookmark.icon && ( -
    +
    )} {!bookmark.icon && bookmark.abbr}
    -
    -
    {bookmark.name}
    -
    - {description} + ) : ( +
    +
    + {bookmark.icon && ( +
    + +
    + )} + {!bookmark.icon && bookmark.abbr} +
    +
    +
    {bookmark.name}
    +
    + {description} +
    -
    + )}
  • ); diff --git a/src/components/bookmarks/list.jsx b/src/components/bookmarks/list.jsx index 521ca7fb9..194bb43af 100644 --- a/src/components/bookmarks/list.jsx +++ b/src/components/bookmarks/list.jsx @@ -4,16 +4,22 @@ import { columnMap } from "../../utils/layout/columns"; import Item from "components/bookmarks/item"; -export default function List({ bookmarks, layout }) { +export default function List({ bookmarks, layout, bookmarksStyle }) { + let classes = + layout?.style === "row" ? `grid ${columnMap[layout?.columns]} gap-x-2` : "flex flex-col mt-3 bookmark-list"; + const style = {}; + if (layout?.iconsOnly || bookmarksStyle === "icons") { + classes = "grid gap-3 mt-3 bookmark-list"; + style.gridTemplateColumns = "repeat(auto-fill, minmax(60px, 1fr))"; + } return ( -