From 4156b6074f31fe0d91513c5fd6d4054741654f19 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Fri, 9 Feb 2024 15:06:28 -0600 Subject: [PATCH] Small changes for UI Use icon instead of Mark as read link Display icon tooltip for help --- core/routes.go | 12 ++++++---- static/css/style.css | 24 +++++++++++++++++++ templates/link_list.html | 51 ++++++++++++++++++++++++++-------------- 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/core/routes.go b/core/routes.go index ea6f1d4..ac2bfa3 100644 --- a/core/routes.go +++ b/core/routes.go @@ -70,7 +70,7 @@ func (s *Service) RegisterRoutes() { s.eg.POST("/add", s.OrgLinksCreate).Name = s.RouteName("link_create_post") s.eg.GET("/link/:id", s.OrgLinkDetail).Name = s.RouteName("link_detail") s.eg.GET("/click/:id", s.OrgLinkRedirect).Name = s.RouteName("link_redirect") - s.eg.GET("/read/:id", s.OrgLinkAsRead).Name = s.RouteName("link_mark_as_read") + s.eg.GET("/read/:id", s.OrgLinkAsReadToggle).Name = s.RouteName("link_mark_as_read") s.eg.GET("/star/:id", s.OrgLinkStarToggle).Name = s.RouteName("link_star_toggle") s.eg.GET("/link/:id/delete", s.OrgLinkDelete).Name = s.RouteName("link_delete") s.eg.POST("/link/:id/delete", s.OrgLinkDelete).Name = s.RouteName("link_delete") @@ -1138,6 +1138,7 @@ func (s *Service) PopularLinkList(c echo.Context) error { pd := localizer.NewPageData(lt.Translate("Bookmarks")) pd.Data["bookmark"] = lt.Translate("bookmark") pd.Data["popular"] = lt.Translate("Popular Bookmarks") + pd.Data["no_links"] = lt.Translate("No Links") links := result.PopularLinks gmap := gobwebs.Map{ @@ -1312,6 +1313,10 @@ func (s *Service) OrgLinksList(c echo.Context) error { pd.Data["starred"] = lt.Translate("Starred") pd.Data["untagged"] = lt.Translate("Untagged") pd.Data["mark_as_read"] = lt.Translate("Mark as read") + pd.Data["mark_as_unread"] = lt.Translate("Mark as unread") + pd.Data["mark_as_starred"] = lt.Translate("Starred") + pd.Data["mark_as_non_starred"] = lt.Translate("Unstarred") + pd.Data["no_links"] = lt.Translate("No Links") orgLinks := result.OrgLinks.Result gmap := gobwebs.Map{ "pd": pd, @@ -2173,7 +2178,7 @@ func (s *Service) OrgLinkStarToggle(c echo.Context) error { return c.Redirect(http.StatusMovedPermanently, redirect) } -func (s *Service) OrgLinkAsRead(c echo.Context) error { +func (s *Service) OrgLinkAsReadToggle(c echo.Context) error { gctx := c.(*server.Context) id, err := strconv.Atoi(c.Param("id")) if err != nil { @@ -2183,7 +2188,6 @@ func (s *Service) OrgLinkAsRead(c echo.Context) error { opts := &database.FilterOptions{ Filter: sq.And{ sq.Eq{"ol.id": id}, - sq.Eq{"ol.unread": true}, sq.Eq{"ol.user_id": gctx.User.GetID()}, }, Limit: 1, @@ -2209,7 +2213,7 @@ func (s *Service) OrgLinkAsRead(c echo.Context) error { } }`) op.Var("id", link.ID) - op.Var("unread", false) + op.Var("unread", !link.Unread) err = links.Execute(c.Request().Context(), op, &result) if err != nil { return err diff --git a/static/css/style.css b/static/css/style.css index 95d2a84..0cda93a 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -400,6 +400,10 @@ a.bullet-link:before { margin-right: 7px; } +.read-link { + line-height: 0; +} + .plan-selected { border: 1px solid var(--color-primary); } @@ -427,3 +431,23 @@ a.bullet-link:before { .tour-section-img { margin-top: 15px; } + +.non-starred { + color: var(--color-darkGrey); +} + +.tooltip-link[data-tooltip] { + position: relative; +} + +.tooltip-link[data-tooltip]:hover::after { + content: attr(data-tooltip); + color: var(--color-darkGrey); + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + background-color: #fff; + padding: 5px; + white-space: nowrap; +} diff --git a/templates/link_list.html b/templates/link_list.html index 93f0264..2547b82 100644 --- a/templates/link_list.html +++ b/templates/link_list.html @@ -28,24 +28,40 @@
{{if $.isOrgLink}} {{if $.canRead }} - - {{if .IsPrivate}} - - {{else}} - - {{end}} - + + {{if .IsPrivate}} + + {{else}} + + {{end}} + {{end}} - {{if not .Unread}} - - - + {{if .Unread}} + {{if eq .UserID $.currentUserID}} + + + + + + {{end}} + {{else}} + {{if eq .UserID $.currentUserID}} + + + + + + {{end}} {{end}} {{if not .Starred}} {{if eq .UserID $.currentUserID}} - + @@ -53,7 +69,7 @@ {{end}} {{else}} {{if eq .UserID $.currentUserID}} - + @@ -113,13 +129,12 @@ {{$.pd.Data.by}} {{.OrgSlug}} - {{if and .Unread (eq .UserID $.currentUserID)}} - | {{$.pd.Data.mark_as_read}} - {{end}}

{{end}} + {{else}} +

{{.pd.Data.no_links}}

{{end}} {{if or .prevURL .nextURL}} -- 2.45.2