on master help sign in
Merge pull request #14 from vagos/frontend-imprs

Frontend improvements

commit2f60ea2cb48ee6686d72c70847e5862e3e04243a authorEvangelos Lamprou <vagoslabrou@gmail.com> dateMon 23 Oct 2023, 19:30 (3 years ago) parent13363fddd5f5bc
4 files changed+57−8
dev/elm-live.sh+6−1 frontend/assets/css/main.css+12 frontend/elm.json+5 frontend/src/Main.elm+34−7
dev/elm-live.sh+6−1
@@ -4,4 +4,9 @@ set -e
44
55cd "$(dirname "$0")/../frontend"
66
7−nix run nixpkgs#elmPackages.elm-live -- src/Main.elm --start-page=index.html -- --debug --output=elm.js "$@"
7+if [[ -z $(command -v nix) ]] && [[ -z $(command -v elm-live) ]]; then
8+ echo "Please install either 'nix' or 'elm-live'" && exit 1
9+fi
10+
11+command -v nix && nix run nixpkgs#elmPackages.elm-live -- src/Main.elm --start-page=index.html -- --debug --output=elm.js "$@"
12+command -v elm-live && elm-live src/Main.elm --start-page=index.html -- --debug --output=elm.js "$@"
frontend/assets/css/main.css+12
@@ -49,3 +49,15 @@
4949 top: 0px;
5050 }
5151}
52+
53+.result-link {
54+ color: #000;
55+ text-decoration: none;
56+ font-size: 12px !important;
57+}
58+
59+.result-title {
60+ color: #000;
61+ text-decoration: none;
62+ font-size: 16px;
63+}
frontend/elm.json+5
@@ -7,6 +7,7 @@
77 "elm-version": "0.19.1",
88 "dependencies": {
99 "direct": {
10+ "Evelios/elm-hash": "1.0.0",
1011 "TSFoster/elm-bytes-extra": "1.3.0",
1112 "avh4/elm-color": "1.0.0",
1213 "cmditch/elm-bigint": "2.0.1",
@@ -32,6 +33,7 @@
3233 "ianmackenzie/elm-units": "2.10.0",
3334 "jasonliang-dev/elm-heroicons": "2.0.0",
3435 "jxxcarlson/hex": "4.0.0",
36+ "marcosh/elm-html-to-unicode": "1.0.4",
3537 "mdgriffith/elm-animator": "1.1.1",
3638 "mdgriffith/elm-ui": "1.1.8",
3739 "rtfeldman/elm-css": "18.0.0",
@@ -43,6 +45,8 @@
4345 "AdrianRibao/elm-derberos-date": "1.2.3",
4446 "NoRedInk/elm-string-conversions": "1.0.1",
4547 "bitsoflogic/elm-radixint": "2.0.0",
48+ "bonzaico/murmur3": "1.0.0",
49+ "chain-partners/elm-bignum": "1.0.1",
4650 "elm/file": "1.0.5",
4751 "elm/parser": "1.1.0",
4852 "elm/random": "1.0.0",
@@ -55,6 +59,7 @@
5559 "ianmackenzie/elm-interval": "3.1.0",
5660 "ianmackenzie/elm-units-interval": "3.2.0",
5761 "ktonon/elm-word": "2.1.2",
62+ "myrho/elm-round": "1.0.5",
5863 "robinheghan/murmur3": "1.0.0"
5964 }
6065 },
frontend/src/Main.elm+34−7
@@ -31,6 +31,10 @@ import Ur.Jam exposing (isSig)
3131import Ur.Run
3232import Ur.Sub
3333import Ur.Types exposing (Noun(..))
34+import Url
35+import ElmEscapeHtml
36+import Json.Encode
37+import Hash
3438
3539url : String
3640url =
@@ -188,7 +192,18 @@ aboutView = row [ centerX, padding 10, spacing 10]
188192 , subtleLinkView "[Code]" "https://github.com/ilyakooo0/seax"
189193 ]
190194
191−
195+titleEmoji : String -> String
196+titleEmoji title =
197+ let maxUnicode = 0x1F3F0
198+ minUnicode = 0x1F300
199+ in title |> Hash.fromString
200+ |> Hash.toString
201+ |> String.toInt
202+ |> Maybe.withDefault 0
203+ |> (\x -> ((modBy (maxUnicode - minUnicode) x) + minUnicode))
204+ |> Char.fromCode
205+ |> String.fromChar
206+ |> (\x -> x ++ " ")
192207
193208
194209view : Model -> Element Msg
@@ -292,7 +307,7 @@ view model =
292307 |> Maybe.map Tuple.first
293308 |> Maybe.withDefault (Animator.init 0)
294309 )
295− (\i -> toFloat i * 47 |> Animator.at)
310+ (\i -> toFloat i * 0 |> Animator.at)
296311 |> String.fromFloat
297312 )
298313 ++ "px"
@@ -302,14 +317,26 @@ view model =
302317 , Html.Attributes.style "padding" "0.5em" |> htmlAttribute
303318 , Html.Attributes.class "result" |> htmlAttribute
304319 ]
305− [ text (stripTags title)
306− |> el
307− [ Font.size 16
320+ [ (Element.html
321+ (Html.a
322+ [ Html.Attributes.href link
323+ , Html.Attributes.class "result-title"
324+ , Html.Attributes.target "_blank"
308325 ]
326+ [ Html.text
327+ (Maybe.withDefault ""
328+ (Url.percentDecode
329+ (ElmEscapeHtml.unescape
330+ (stripTags
331+ ((titleEmoji title) ++ title)
332+ ))))
333+ ]
334+ )
335+ )
309336 , text link
310337 |> el
311− [ Font.size 12
312− , Font.color (rgb 0.7 0.7 0.7)
338+ [ Font.color (rgb 0.7 0.7 0.7)
339+ , Html.Attributes.class "result-link" |> htmlAttribute
313340 ]
314341 ]
315342 )