diff --git a/index.html b/index.html new file mode 100644 index 0000000..f865999 --- /dev/null +++ b/index.html @@ -0,0 +1,128 @@ + + + + + + + + +
+
+ + + + +
+
Downloading
Gallery...
+
+ + diff --git a/src/Main.purs b/src/Main.purs index e328dc5..a37d6bc 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -1,6 +1,7 @@ module Main where import Prelude +import Aviary.FFI (removeSpinner) import Aviary.UI (component) import Aviary.Logic (fetch_and_decrypt_gallery, get_parameters) import Aviary.Model (Model(..)) @@ -8,6 +9,7 @@ import Aviary.Model (Model(..)) import Data.Either (Either(..)) import Effect (Effect) import Effect.Aff (Aff, launchAff) +import Effect.Class (liftEffect) import Halogen.Aff (awaitBody) import Halogen.VDom.Driver (runUI) @@ -18,6 +20,7 @@ main_aff = do gallery <- case parameters of Left e -> pure $ GError e Right parameters' -> fetch_and_decrypt_gallery parameters' + _ <- liftEffect $ removeSpinner _ <- runUI (component gallery) unit body pure unit diff --git a/src/UI.purs b/src/UI.purs index f45ecae..ffaa1d0 100644 --- a/src/UI.purs +++ b/src/UI.purs @@ -25,6 +25,7 @@ data Event = LoadThumbs | ThumbLoaded Int ImageData | FullLoaded Int ImageData | Focus Int + | Unfocus component :: forall query input. Model -> H.Component query input Event Aff component initialState = H.mkComponent @@ -52,8 +53,8 @@ renderThumbnail pos image = renderFocused :: forall m. Image -> H.ComponentHTML Event () m renderFocused image = HH.div - [ HP.class_ $ ClassName "focused-panel" - , HP.class_ $ ClassName "visible" + [ HP.id $ "focused-panel" + , HE.onClick \_ -> Unfocus ] ( [ HH.img $ maybe [] (HP.src >>> pure) (fullOrBlurhash image) @@ -107,11 +108,18 @@ update (Focus newFocus) = do Just focusedImage' -> fetchFullAction newFocus focusedImage' Nothing -> H.put $ GError $ UnexpectedError "Focus event raised with an out of bounds index!" +update Unfocus = H.modify_ \model -> case model of + GError e -> GError e + GLoaded gal -> GLoaded gal { focus = Nothing } render :: forall m. Model -> H.ComponentHTML Event () m render (GError e) = HH.p_ [ HH.text $ show e ] render (GLoaded {title, desc, images, focus}) = HH.div_ ((maybe [] (HH.text >>> pure >>> HH.h1_ >>> pure) title) <> (maybe [] (HH.text >>> pure >>> HH.p_ >>> pure) desc) <> - (mapWithIndex renderThumbnail images) <> + [ HH.div + [ HP.id "thumbnails" + ] + (mapWithIndex renderThumbnail images) + ] <> (maybe [] (renderFocused >>> pure) (index images =<< focus))) diff --git a/src/ffi.js b/src/ffi.js index fedef0c..39e2c11 100644 --- a/src/ffi.js +++ b/src/ffi.js @@ -21,3 +21,7 @@ export function decodeBlurhashImpl(just) { } } } + +export function removeSpinner() { + document.getElementById("spinner").remove() +} diff --git a/src/ffi.purs b/src/ffi.purs index 690c591..d2a4059 100644 --- a/src/ffi.purs +++ b/src/ffi.purs @@ -1,7 +1,10 @@ module Aviary.FFI where +import Prelude + import Data.ArrayBuffer.Types (ArrayBuffer) import Data.Maybe (Maybe(..)) +import Effect (Effect) import Web.File.Blob (Blob) -- mimeType :: String @@ -15,3 +18,5 @@ decodeBlurhash :: Int -> Int -> String -> Maybe String decodeBlurhash = decodeBlurhashImpl Just Nothing decodeBlurhash32 :: String -> Maybe String decodeBlurhash32 = decodeBlurhash 32 32 + +foreign import removeSpinner :: Effect Unit