aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/IssueEvent.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-04 08:36:02 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-05 06:07:41 +0100
commit1b1c3faabae530229eb675a2e70e744c2f45cbbe (patch)
treeacc3e8eede9053fb5e639deeb553aa600c994598 /app/History/IssueEvent.hs
parent3a76b6f0fc0c9c23000dd82870922c885c34ffa6 (diff)
feat: add experimental render api
Diffstat (limited to 'app/History/IssueEvent.hs')
-rw-r--r--app/History/IssueEvent.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/History/IssueEvent.hs b/app/History/IssueEvent.hs
index 0900f13..93bd133 100644
--- a/app/History/IssueEvent.hs
+++ b/app/History/IssueEvent.hs
@@ -2,7 +2,10 @@ module History.IssueEvent (IssueEvent (..)) where
import History.CommitHash (CommitHash)
import Issue (Issue)
+import Issue.Render qualified as I
import Patch (Patch)
+import Render ((<<<))
+import Render qualified as P
data IssueEvent
= IssueCreated
@@ -22,3 +25,28 @@ data IssueEvent
patch :: Patch
}
deriving (Show)
+
+instance P.Render IssueEvent where
+ render = P.render . P.Detailed
+
+instance P.Render (P.Detailed IssueEvent) where
+ render (P.Detailed issueEvent) =
+ P.Summarized issueEvent
+ <<< P.hardline @P.AnsiStyle
+ <<< issueEvent.patch
+
+instance P.Render (P.Summarized IssueEvent) where
+ render (P.Summarized issueEvent) =
+ case issueEvent of
+ IssueCreated {hash, issue} ->
+ P.Summarized hash
+ <<< P.styled [P.color P.Green] "created"
+ <<< I.IssueTitle issue
+ IssueChanged {hash, issue} ->
+ P.Summarized hash
+ <<< P.styled [P.color P.Green] "changed"
+ <<< I.IssueTitle issue
+ IssueDeleted {hash, issue} ->
+ P.Summarized hash
+ <<< P.styled [P.color P.Green] "deleted"
+ <<< I.IssueTitle issue