From 1b1c3faabae530229eb675a2e70e744c2f45cbbe Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 4 Dec 2023 08:36:02 +0100 Subject: feat: add experimental render api --- app/History/CommitHash.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/History/CommitHash.hs') diff --git a/app/History/CommitHash.hs b/app/History/CommitHash.hs index f1b8283..cbe4db1 100644 --- a/app/History/CommitHash.hs +++ b/app/History/CommitHash.hs @@ -8,6 +8,7 @@ where import Data.Binary (Binary) import Data.Text qualified as T import GHC.Generics (Generic) +import Render qualified as P data CommitHash = WorkingTree @@ -21,3 +22,16 @@ toShortText (Commit hash) = T.take 7 hash toText :: CommitHash -> T.Text toText WorkingTree = "" toText (Commit hash) = hash + +instance P.Render CommitHash where + render = P.render . P.Detailed + +instance P.Render (P.Detailed CommitHash) where + render (P.Detailed commitHash) = + P.styled [P.color P.Yellow] $ + P.render (toText commitHash) + +instance P.Render (P.Summarized CommitHash) where + render (P.Summarized commitHash) = + P.styled [P.color P.Yellow] $ + P.render (toShortText commitHash) -- cgit v1.2.3