Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
frontend: much cleaner search result rendering
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
emidoots committed May 13, 2022
1 parent 258bab8 commit 30dd127
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
45 changes: 40 additions & 5 deletions frontend/src/Pages/Home_.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Pages.Home_ exposing (Model, Msg, page)
import APISchema
import Browser.Dom
import Element as E
import Element.Border as Border
import Element.Font as Font
import Element.Lazy
import Gen.Params.Home_ exposing (Params)
Expand Down Expand Up @@ -262,13 +263,33 @@ searchResults request =
Just response ->
case response of
Ok results ->
E.column []
E.column [ E.width E.fill ]
(List.map
(\r ->
E.link []
{ url = Url.Builder.absolute [ r.projectName, "-", r.language, "-", r.path ] [ Url.Builder.string "id" r.id ]
, label = E.el [ Font.underline ] (E.text r.searchKey)
}
E.row
[ E.width E.fill
, E.paddingXY 0 8
, Border.color (E.rgb255 210 210 210)
, Border.widthEach { top = 0, left = 0, bottom = 1, right = 0 }
]
[ E.column []
[ E.link [ E.paddingEach { top = 0, right = 0, bottom = 4, left = 0 } ]
{ url = Url.Builder.absolute [ r.projectName, "-", r.language, "-", r.path ] [ Url.Builder.string "id" r.id ]
, label = E.el [ Font.underline ] (E.text r.searchKey)
}
, E.el
[ Font.color (E.rgb 0.6 0.6 0.6)
, Font.size 14
]
(E.text (shortProjectName r.path))
]
, E.el
[ E.alignRight
, Font.color (E.rgb 0.6 0.6 0.6)
, Font.size 14
]
(E.text (shortProjectName r.projectName))
]
)
results
)
Expand All @@ -278,3 +299,17 @@ searchResults request =

Nothing ->
E.text "loading.."


shortProjectName : String -> String
shortProjectName name =
trimPrefix name "github.com/"


trimPrefix : String -> String -> String
trimPrefix str prefix =
if String.startsWith prefix str then
String.dropLeft (String.length prefix) str

else
str
5 changes: 1 addition & 4 deletions frontend/src/ProjectPage.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module ProjectPage exposing (Model, Msg, init, page, subscriptions, update, view)

import APISchema
import Browser
import Browser.Dom
import Dict exposing (keys)
import Effect exposing (Effect)
Expand All @@ -21,8 +20,6 @@ import Shared
import Style
import Task
import Url.Builder
import Url.Parser
import Url.Parser.Query
import Util exposing (httpErrorToString)
import View exposing (View)

Expand Down Expand Up @@ -181,7 +178,7 @@ subscriptions model =

view : Shared.Model -> Maybe ProjectURI -> Model -> View Msg
view shared projectURI model =
{ title = "TODO"
{ title = "doctree"
, body =
[ case shared.projectIndexes of
Just response ->
Expand Down

0 comments on commit 30dd127

Please sign in to comment.