on master help sign in
Merge pull request #7 from ilyakooo0/frontend

Added %seax logo Impovements on search results page

commitacb599cbe5f6dd684f1ab31277adaf367272a36d authorEvangelos Lamprou <vagoslabrou@gmail.com> dateFri 20 Oct 2023, 13:37 (3 years ago) parent750c642272b0c3
6 files changed+193−31
frontend/assets/css/main.css+57 frontend/assets/img/logo.png frontend/assets/js/tilt.js+51 frontend/elm.json+19−3 frontend/index.html+2 frontend/src/Main.elm+64−28
frontend/assets/css/main.cssnew file+57
@@ -0,0 +1,57 @@
1+@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200&family=Roboto+Mono:wght@200&family=Roboto:wght@300&display=swap');
2+
3+#tilt:hover {
4+ /* box-shadow: 0px 0px 30px rgba(0,0,0, 0.6); */
5+ /* cursor: pointer; */
6+ /* transition: all 0.1s ease-in-out; */
7+}
8+
9+.button {
10+ border: none;
11+ color: white;
12+ padding: 15px 32px;
13+ text-align: center;
14+ text-decoration: none;
15+ font-size: 16px;
16+ display: inline-block;
17+ margin: 4px 2px;
18+ cursor: pointer;
19+ border-radius: 0;
20+ box-shadow: 0 2px 2px #888888;
21+}
22+
23+.shadow {
24+ shadow: 0 2px 2px #888888;
25+}
26+
27+.result {
28+}
29+
30+.result:hover {
31+ text-decoration: underline;
32+}
33+
34+.search:hover {
35+ text-decoration: underline;
36+}
37+
38+.wavy {
39+ animation-name: wavy;
40+ animation-duration: 4.2s;
41+ animation-timing-function: ease-in-out;
42+ animation-iteration-count: infinite;
43+ position: relative;
44+ top: 0;
45+ left: 0;
46+}
47+@keyframes wavy {
48+ 0% {
49+ top: 0px;
50+ }
51+ 50% {
52+ top: -15px;
53+ }
54+ 100% {
55+ top: 0px;
56+ }
57+}
frontend/assets/img/logo.pngnew file

Binary file not shown.

frontend/assets/js/tilt.jsnew file+51
@@ -0,0 +1,51 @@
1+/* Store the element in el */
2+let el = document.getElementById('tilt')
3+
4+/* Get the height and width of the element */
5+const height = el.clientHeight
6+const width = el.clientWidth
7+
8+/* Define function a */
9+function handleMove(e) {
10+
11+ if (el.id != 'tilt') return; /* TODO: Fix this hack. */
12+
13+ /*
14+ * Get position of mouse cursor
15+ * With respect to the element
16+ * On mouseover
17+ */
18+ /* Store the x position */
19+ const xVal = e.layerX
20+ /* Store the y position */
21+ const yVal = e.layerY
22+
23+ /*
24+ * Calculate rotation valuee along the Y-axis
25+ * Here the multiplier 20 is to
26+ * Control the rotation
27+ * You can change the value and see the results
28+ */
29+ const yRotation = 20 * ((xVal - width / 2) / width)
30+
31+ /* Calculate the rotation along the X-axis */
32+ const xRotation = -20 * ((yVal - height / 2) / height)
33+
34+ /* Generate string for CSS transform property */
35+ const string = 'perspective(500px) scale(1.0) rotateX(' + xRotation + 'deg) rotateY(' + yRotation + 'deg)'
36+
37+ /* Apply the calculated transformation */
38+ el.style.transform = string
39+}
40+
41+/* Add listener for mouseout event, remove the rotation */
42+el.addEventListener('mouseout', function() {
43+ el.style.transform = 'perspective(500px) scale(1) rotateX(0) rotateY(0)'
44+})
45+
46+/*
47+ * Add a listener for mousemove event
48+ * Which will trigger function 'handleMove'
49+ * On mousemove
50+ */
51+let mouseMoveEL = el.addEventListener('mousemove', handleMove)
frontend/elm.json+19−3
@@ -8,6 +8,7 @@
88 "dependencies": {
99 "direct": {
1010 "TSFoster/elm-bytes-extra": "1.3.0",
11+ "avh4/elm-color": "1.0.0",
1112 "cmditch/elm-bigint": "2.0.1",
1213 "elm/browser": "1.0.2",
1314 "elm/bytes": "1.0.8",
@@ -20,24 +21,39 @@
2021 "elm/url": "1.0.0",
2122 "elm-community/list-extra": "8.7.0",
2223 "elm-community/maybe-extra": "5.3.0",
24+ "elm-community/string-extra": "4.0.1",
2325 "figbus/elm-urbit-api": "4.0.1",
26+ "hecrj/html-parser": "2.4.0",
27+ "ianmackenzie/elm-1d-parameter": "1.0.1",
28+ "ianmackenzie/elm-3d-camera": "3.1.0",
29+ "ianmackenzie/elm-3d-scene": "1.0.1",
30+ "ianmackenzie/elm-geometry": "3.11.0",
31+ "ianmackenzie/elm-triangular-mesh": "1.1.0",
32+ "ianmackenzie/elm-units": "2.10.0",
2433 "jasonliang-dev/elm-heroicons": "2.0.0",
2534 "jxxcarlson/hex": "4.0.0",
2635 "mdgriffith/elm-animator": "1.1.1",
2736 "mdgriffith/elm-ui": "1.1.8",
37+ "rtfeldman/elm-css": "18.0.0",
2838 "rtfeldman/elm-hex": "1.0.0",
29− "toastal/either": "3.6.3"
39+ "toastal/either": "3.6.3",
40+ "zwilias/elm-html-string": "2.0.2"
3041 },
3142 "indirect": {
3243 "AdrianRibao/elm-derberos-date": "1.2.3",
33− "avh4/elm-color": "1.0.0",
44+ "NoRedInk/elm-string-conversions": "1.0.1",
3445 "bitsoflogic/elm-radixint": "2.0.0",
3546 "elm/file": "1.0.5",
3647 "elm/parser": "1.1.0",
3748 "elm/random": "1.0.0",
3849 "elm/regex": "1.0.0",
3950 "elm/virtual-dom": "1.0.3",
40− "ianmackenzie/elm-units": "2.10.0",
51+ "elm-explorations/linear-algebra": "1.0.3",
52+ "elm-explorations/webgl": "1.1.3",
53+ "ianmackenzie/elm-float-extra": "1.1.0",
54+ "ianmackenzie/elm-geometry-linear-algebra-interop": "2.0.2",
55+ "ianmackenzie/elm-interval": "3.1.0",
56+ "ianmackenzie/elm-units-interval": "3.2.0",
4157 "ktonon/elm-word": "2.1.2",
4258 "robinheghan/murmur3": "1.0.0"
4359 }
frontend/index.html+2
@@ -2,6 +2,7 @@
22<html lang="en">
33 <head>
44 <meta charset="UTF-8" />
5+ <link rel="stylesheet" href="assets/css/main.css" >
56 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
67 <style>
78 body {
@@ -30,5 +31,6 @@
3031 <script src="/elm.js"></script>
3132 <script type="module" src="/script.js"></script>
3233 </body>
34+ <script type="text/javascript" src="assets/js/tilt.js" defer></script>
3335</html>
3436
frontend/src/Main.elm+64−28
@@ -11,6 +11,9 @@ import Element.Font as Font
1111import Element.Input as Input
1212import Element.Keyed as Keyed
1313import Html.Attributes
14+import Html.String
15+import Html.Styled.Attributes exposing (css)
16+import Html exposing (Html, hr)
1417import Json.Decode as JD
1518import List.Extra
1619import Set exposing (Set)
@@ -22,6 +25,11 @@ import Ur.Jam exposing (isSig)
2225import Ur.Run
2326import Ur.Sub
2427import Ur.Types exposing (Noun(..))
28+import Html.String
29+import List
30+import Html.Styled.Attributes exposing (css)
31+import Html.Parser
32+import String.Extra exposing (stripTags)
2533
2634
2735url : String
@@ -61,7 +69,6 @@ type alias SearchResult =
6169 , engines : Set String
6270 }
6371
64−
6572type Msg
6673 = Noop
6774 | GotShipName String
@@ -100,7 +107,8 @@ main =
100107 [ view model
101108 |> layout
102109 [ Font.family
103− [ Font.typeface "system-ui"
110+ [ Font.typeface "monospace"
111+ , Font.typeface "system-ui"
104112 , Font.typeface "-apple-system"
105113 , Font.typeface "BlinkMacSystemFont"
106114 , Font.typeface "Segoe UI"
@@ -108,12 +116,9 @@ main =
108116 , Font.typeface "Helvetica"
109117 , Font.typeface "Arial"
110118 , Font.sansSerif
111− , Font.typeface "Apple Color Emoji"
112− , Font.typeface "Segoe UI Emoji"
113− , Font.typeface "Segoe UI Symbol"
114119 ]
115120 , clipX
116− ]
121+ ]
117122 ]
118123 }
119124 , subscriptions = \model -> Animator.toSubscription Tick model (animator model)
@@ -150,20 +155,51 @@ main =
150155 }
151156
152157
158+logoView : List (Attribute Msg) -> Element Msg
159+logoView attributes =
160+ Element.image (List.append [ Html.Attributes.id "tilt" |> htmlAttribute ] attributes)
161+ { src = "assets/img/logo.png", description = "%seax logo" }
162+
163+noSearchResultsView : Element Msg
164+noSearchResultsView = Element.el
165+ [ Html.Attributes.style "padding" "1em" |> htmlAttribute
166+ , width (px 500)
167+ , Font.size 15
168+ , Html.Attributes.class "wavy" |> htmlAttribute
169+ ]
170+ (Element.text """No results found... :)
171+We'll try and find you something.
172+Just come back later.""")
173+
174+subtleLink : String -> String -> Element Msg
175+subtleLink text href =
176+ Element.el
177+ [ Font.size 15
178+ , pointer
179+ , mouseOver
180+ [ Font.color (rgb 0.7 0.7 0.7)
181+ ]
182+ ]
183+ (Element.html (Html.a [ Html.Attributes.href href ] [ Html.text text ]))
184+
185+
153186view : Model -> Element Msg
154187view model =
155188 case model.initiatedSearch of
156189 Nothing ->
157190 column [ centerX, centerY, padding 8, spacing 16 ]
158− [ el [ centerX, Font.size 67, Font.heavy ] (text "%seax")
191+ [ logoView [ centerX, width (px 510), height (px 161) ]
159192 , searchView model
160193 ]
161194
162195 Just _ ->
163196 column [ width fill, spacing 16 ]
164− [ column [ spacing 16, width (minimum 0 fill), padding 8 ]
165− [ searchView model |> el []
197+ [ column [ spacing 16, width (minimum 0 fill), padding 8]
198+ [ row [] [ logoView [height (px 40)], searchView model |> el [] ]
166199 , row [ spacing 8, paddingEach { top = 16, bottom = 16, left = 0, right = 0 } ]
200+ (if List.isEmpty model.engines then
201+ []
202+ else
167203 [ text "Sources: "
168204 , model.engines
169205 |> List.filter (\( _, state ) -> state /= Failed)
@@ -203,12 +239,14 @@ view model =
203239 |> wrappedRow
204240 [ spacing 8
205241 , width fill
206−
207− -- , padding 16
208242 ]
209243 ]
244+ )
210245 ]
211− , Keyed.column [ width (minimum 0 fill), padding 8 ]
246+ , (if List.isEmpty model.searchResults then
247+ noSearchResultsView
248+ else
249+ Keyed.column [ width (minimum 0 fill), padding 8 ]
212250 (model.searchResults
213251 |> List.filter
214252 (\{ engines } ->
@@ -251,12 +289,13 @@ view model =
251289 ++ "px"
252290 )
253291 |> htmlAttribute
254− , Html.Attributes.style "position" "absolute" |> htmlAttribute
292+ , Html.Attributes.style "margin-bottom" "1em" |> htmlAttribute
293+ , Html.Attributes.style "padding" "0.5em" |> htmlAttribute
294+ , Html.Attributes.class "result" |> htmlAttribute
255295 ]
256− [ text title
296+ [ text (stripTags title)
257297 |> el
258298 [ Font.size 16
259− , width fill
260299 ]
261300 , text link
262301 |> el
@@ -266,14 +305,19 @@ view model =
266305 ]
267306 )
268307 )
269− )
308+ ))
309+ , Element.html (Html.hr [Html.Attributes.style "width" "95%"] [])
310+ , row [ centerX, padding 10, spacing 10]
311+ [ subtleLink "[About]" "https://vagos.github.io/seax"
312+ , subtleLink "[Code]" "https://github.com/ilyakooo0/seax"
270313 ]
314+ ]
271315
272316
273317searchView : { a | search : String } -> Element Msg
274318searchView model =
275319 row [ spacing 8 ]
276− [ Input.text [ width (px 250) ]
320+ [ Input.text [ Html.Attributes.class "shadow" |> htmlAttribute, width (px 400)]
277321 { onChange = UpdateSearch
278322 , placeholder = Nothing
279323 , text = model.search
@@ -283,23 +327,15 @@ searchView model =
283327 { label =
284328 text "search"
285329 |> el
286− [ Border.width 4
287− , padding 4
330+ [ Html.Attributes.class "search" |> htmlAttribute
331+ , Border.width 2
332+ , padding 6
288333 , Font.size 29
289− , Font.bold
290− , Border.color (rgb 0 0 0)
291− , Background.color (rgb 0 0 0)
292− , Font.color (rgb 1 1 1)
293− , mouseOver
294− [ Font.color (rgb 0 0 0)
295− , Background.color (rgb 1 1 1)
296− ]
297334 ]
298335 , onPress = Just (Search model.search)
299336 }
300337 ]
301338
302−
303339update : Msg -> Model -> ( Model, Ur.Cmd.Cmd Msg )
304340update msg model =
305341 case msg of