浏览代码

Add another field to Header, to validate the concept

jherve 1 年之前
父节点
当前提交
c99efc8140
共有 1 个文件被更改,包括 12 次插入6 次删除
  1. 12 6
      src/LinkedIn/ArtDecoCardAlt.purs

+ 12 - 6
src/LinkedIn/ArtDecoCardAlt.purs

@@ -19,7 +19,8 @@ import Web.DOM.Node (nodeName)
 
 data ArtDecoCenterHeaderAlt a = ArtDecoCenterHeaderAlt {
   bold :: a,
-  normal :: Maybe a
+  normal :: Maybe a,
+  light :: Maybe (NonEmptyList a)
 }
 
 derive instance Generic (ArtDecoCenterHeaderAlt a) _
@@ -35,10 +36,12 @@ instance Foldable ArtDecoCenterHeaderAlt where
   foldr = \x -> foldrDefault x
 
 instance Traversable ArtDecoCenterHeaderAlt where
-  sequence (ArtDecoCenterHeaderAlt {bold, normal}) = ado
-    b <- bold
-    n <- sequence normal
-  in ArtDecoCenterHeaderAlt {bold: b, normal: n}
+  sequence :: forall a m. Applicative m => ArtDecoCenterHeaderAlt (m a) -> m (ArtDecoCenterHeaderAlt a)
+  sequence (ArtDecoCenterHeaderAlt {bold, normal, light}) = ado
+    b <- bold :: m a
+    n <- sequence normal :: m (Maybe a)
+    l <- sequence (map sequence light) :: m (Maybe (NonEmptyList a))
+  in ArtDecoCenterHeaderAlt {bold: b, normal: n, light: l}
 
   traverse = \x -> traverseDefault x
 
@@ -75,8 +78,11 @@ queryArtDecoCenterHeaderAlt n = do
   normal <-
     ignoreNotFound $
     runOne ":scope span.t-normal:not(t-black--light) > span[aria-hidden=true]" n
+  light <-
+    ignoreNotFound $
+    runAll ":scope span.t-black--light > span[aria-hidden=true]" n
 
-  pure $ ArtDecoCenterHeaderAlt {bold, normal: normal}
+  pure $ ArtDecoCenterHeaderAlt {bold, normal, light}
 
 queryArtDecoCardAlt ∷ QueryRunner (ArtDecoCardAltElement Node)
 queryArtDecoCardAlt n = do