~jack/casaaaaa

349946a1d55a93de4d5e39798969e5ba154163ff — Jack Kelly 2 years ago a9c6971
Avoid creating <div> until necessary
1 files changed, 17 insertions(+), 8 deletions(-)

M Main.hs
M Main.hs => Main.hs +17 -8
@@ 81,12 81,19 @@ body =
      divClass "container" . el "form" $
        liftA2 (,) searchWidget searchFuncWidget

    divClass "container" . networkView $ do
      searchFuncD >>= \case
        Nothing -> pure $ dimText "Select something to search over."
    networkView $ do
      searchFuncM <- searchFuncD
      case searchFuncM of
        Nothing ->
          pure . divClass "container" $
            dimText "Select something to search over."
        Just searchFunc ->
          let searchResultsD = fmap (\s -> searchFunc (T.unpack s) "" "" False) <$> searchTermD
           in searchResultsD <&> maybe blank searchResultsWidget
          let searchResultsD =
                (fmap . fmap)
                  (\s -> searchFunc (T.unpack s) "" "" False)
                  searchTermD
           in searchResultsD
                <&> maybe blank (divClass "container" . searchResultsWidget)

    divClass "container" . el "details" $ do
      el "summary" $ text "Legal Stuff"


@@ 98,10 105,10 @@ body =
            "GNU Affero General Public License (3.0 or later) for more details."
          ]
      el "p" . el "small" $ do
        text $ "The "
        text "The "
        elAttr "a" ("href" =: "https://git.sr.ht/~jack/casaaaaa") $
          text "source code"
        text $ " for this tool is available on sourcehut."
        text " for this tool is available on sourcehut."

    pure ()



@@ 190,4 197,6 @@ searchResultsWidget =
            el "td" . text . T.pack $ r ^. source

dimText :: DomBuilder t m => Text -> m ()
dimText = elAttr "div" ("style" =: "text-align: center; color: var(--muted-color)") . text
dimText =
  elAttr "div" ("style" =: "text-align: center; color: var(--muted-color)")
    . text