Browse Source

feat(sidebar): add discarded tab styling

Jocelyn Boullier 5 năm trước cách đây
mục cha
commit
dac96cb882
2 tập tin đã thay đổi với 18 bổ sung3 xóa
  1. 12 3
      extension/sidebar.css
  2. 6 0
      src/Sidebar.purs

+ 12 - 3
extension/sidebar.css

@@ -1,4 +1,5 @@
-html, body {
+html,
+body {
   width: 100%;
 }
 
@@ -30,6 +31,10 @@ html, body {
   background-color: #b2dceb;
 }
 
+.tab.discarded {
+  color: grey;
+}
+
 .tab-title {
   display: inline-block;
   align-self: center;
@@ -52,6 +57,10 @@ html, body {
   vertical-align: middle;
 }
 
+.tab.discarded > .tab-favicon {
+  filter: brightness(70%);
+}
+
 .close-button-parent {
   width: 17px;
   height: 17px;
@@ -74,7 +83,7 @@ html, body {
   margin-top: 1.2px;
   background-color: black;
   transform: rotate(45deg);
-  Z-index: 1;
+  z-index: 1;
 }
 
 .close-button-inner {
@@ -82,7 +91,7 @@ html, body {
   width: 2px;
   background-color: black;
   transform: rotate(90deg);
-  Z-index: 2;
+  z-index: 2;
 }
 
 .close-button-parent:hover .close-button-outer {

+ 6 - 0
src/Sidebar.purs

@@ -63,6 +63,7 @@ createTabElement port (Tab tab) = do
   J.setAttr "id" tab.id tabDiv
   J.on "click" onTabClick tabDiv
   if tab.active then (J.addClass "active" tabDiv) else (pure unit)
+  if isDiscarded tab then (J.addClass "discarded" tabDiv) else (pure unit)
   -- favicon
   faviconDiv <- J.create "<div>"
   J.addClass "tab-favicon" faviconDiv
@@ -85,6 +86,10 @@ createTabElement port (Tab tab) = do
   onTabClick :: J.JQueryEvent -> J.JQuery -> Effect Unit
   onTabClick event j = Runtime.postMessageJson port $ SbTabActived tab.id
 
+  isDiscarded :: forall r. { discarded :: Maybe Boolean | r } -> Boolean
+  isDiscarded { discarded: Just true } = true
+  isDiscarded _ = false
+
 createCloseButton :: Effect J.JQuery
 createCloseButton = do
   parent <- J.create "<div>"
@@ -117,6 +122,7 @@ updateTabInfo tid (ChangeInfo cinfo) (Tab tab) = do
       Just "loading" -> Just "Loading ..."
       _ -> Just tab.title
   maybe (pure unit) (\t -> J.setText t tabTitleDiv) newTitle
+  maybe (pure unit) (\discarded -> J.setClass "discarded" discarded tabTitleDiv) tab.discarded
   tabFaviconDiv <- J.select ("#" <> (show tid) <> " > .tab-favicon")
   setFaviconUrl cinfo.favIconUrl tabFaviconDiv