Parcourir la source

feat(sidebar): add discarded tab styling

Jocelyn Boullier il y a 6 ans
Parent
commit
dac96cb882
2 fichiers modifiés avec 18 ajouts et 3 suppressions
  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%;
   width: 100%;
 }
 }
 
 
@@ -30,6 +31,10 @@ html, body {
   background-color: #b2dceb;
   background-color: #b2dceb;
 }
 }
 
 
+.tab.discarded {
+  color: grey;
+}
+
 .tab-title {
 .tab-title {
   display: inline-block;
   display: inline-block;
   align-self: center;
   align-self: center;
@@ -52,6 +57,10 @@ html, body {
   vertical-align: middle;
   vertical-align: middle;
 }
 }
 
 
+.tab.discarded > .tab-favicon {
+  filter: brightness(70%);
+}
+
 .close-button-parent {
 .close-button-parent {
   width: 17px;
   width: 17px;
   height: 17px;
   height: 17px;
@@ -74,7 +83,7 @@ html, body {
   margin-top: 1.2px;
   margin-top: 1.2px;
   background-color: black;
   background-color: black;
   transform: rotate(45deg);
   transform: rotate(45deg);
-  Z-index: 1;
+  z-index: 1;
 }
 }
 
 
 .close-button-inner {
 .close-button-inner {
@@ -82,7 +91,7 @@ html, body {
   width: 2px;
   width: 2px;
   background-color: black;
   background-color: black;
   transform: rotate(90deg);
   transform: rotate(90deg);
-  Z-index: 2;
+  z-index: 2;
 }
 }
 
 
 .close-button-parent:hover .close-button-outer {
 .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.setAttr "id" tab.id tabDiv
   J.on "click" onTabClick tabDiv
   J.on "click" onTabClick tabDiv
   if tab.active then (J.addClass "active" tabDiv) else (pure unit)
   if tab.active then (J.addClass "active" tabDiv) else (pure unit)
+  if isDiscarded tab then (J.addClass "discarded" tabDiv) else (pure unit)
   -- favicon
   -- favicon
   faviconDiv <- J.create "<div>"
   faviconDiv <- J.create "<div>"
   J.addClass "tab-favicon" faviconDiv
   J.addClass "tab-favicon" faviconDiv
@@ -85,6 +86,10 @@ createTabElement port (Tab tab) = do
   onTabClick :: J.JQueryEvent -> J.JQuery -> Effect Unit
   onTabClick :: J.JQueryEvent -> J.JQuery -> Effect Unit
   onTabClick event j = Runtime.postMessageJson port $ SbTabActived tab.id
   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 :: Effect J.JQuery
 createCloseButton = do
 createCloseButton = do
   parent <- J.create "<div>"
   parent <- J.create "<div>"
@@ -117,6 +122,7 @@ updateTabInfo tid (ChangeInfo cinfo) (Tab tab) = do
       Just "loading" -> Just "Loading ..."
       Just "loading" -> Just "Loading ..."
       _ -> Just tab.title
       _ -> Just tab.title
   maybe (pure unit) (\t -> J.setText t tabTitleDiv) newTitle
   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")
   tabFaviconDiv <- J.select ("#" <> (show tid) <> " > .tab-favicon")
   setFaviconUrl cinfo.favIconUrl tabFaviconDiv
   setFaviconUrl cinfo.favIconUrl tabFaviconDiv