Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixos-search
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0eefabbb942a
Choose a base ref
...
head repository: NixOS/nixos-search
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bf212924d365
Choose a head ref
  • 5 commits
  • 4 files changed
  • 2 contributors

Commits on Jan 25, 2021

  1. Improve copy/paste UX in Options and packages

    - Change title from button to a to make it selectable
    - Resurect `Name` meta for Options
    - Make sure this won't break keyboard selection
    turboMaCk authored and garbas committed Jan 25, 2021
    Copy the full SHA
    5edd797 View commit details
  2. Copy the full SHA
    ae81b70 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    89322fe View commit details
  4. Copy the full SHA
    4f3fde1 View commit details
  5. hide sorting menu

    garbas committed Jan 25, 2021
    Copy the full SHA
    bf21292 View commit details
Showing with 67 additions and 30 deletions.
  1. +16 −11 src/Page/Options.elm
  2. +2 −1 src/Page/Packages.elm
  3. +34 −8 src/Search.elm
  4. +15 −10 src/index.less
27 changes: 16 additions & 11 deletions src/Page/Options.elm
Original file line number Diff line number Diff line change
@@ -152,13 +152,12 @@ viewResultItem :
viewResultItem channel _ show item =
let
showHtml value =
div [] <|
case Html.Parser.run value of
Ok nodes ->
Html.Parser.Util.toVirtualDom nodes
case Html.Parser.run value of
Ok nodes ->
Html.Parser.Util.toVirtualDom nodes

Err _ ->
[]
Err _ ->
[]

default =
"Not given"
@@ -213,7 +212,15 @@ viewResultItem channel _ show item =
showDetails =
if Just item.source.name == show then
div [ Html.Attributes.map SearchMsg Search.trapClick ]
[ div [] [ text "Default value" ]
[ div [] [ text "Name" ]
, div [] [ wrapped asPreCode item.source.name ]
, div [] [ text "Description" ]
, div [] <|
(item.source.description
|> Maybe.map showHtml
|> Maybe.withDefault []
)
, div [] [ text "Default value" ]
, div [] [ withEmpty (wrapped asPreCode) item.source.default ]
, div [] [ text "Type" ]
, div [] [ withEmpty asPre item.source.type_ ]
@@ -241,14 +248,12 @@ viewResultItem channel _ show item =
<|
List.filterMap identity
[ Just <|
Html.button
Html.a
[ class "search-result-button"
, onClick toggle
, href ""
]
[ text item.source.name ]
, Maybe.map showHtml item.source.description
, Just <|
Search.showMoreButton toggle isOpen
, showDetails
]

3 changes: 2 additions & 1 deletion src/Page/Packages.elm
Original file line number Diff line number Diff line change
@@ -540,9 +540,10 @@ viewResultItem channel showNixOSDetails show item =
([]
|> List.append longerPackageDetails
|> List.append
[ Html.button
[ Html.a
[ class "search-result-button"
, onClick toggle
, href ""
]
[ text item.source.attr_name ]
, div [] [ text <| Maybe.withDefault "" item.source.description ]
42 changes: 34 additions & 8 deletions src/Search.elm
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ type alias Model a b =
, size : Int
, buckets : Maybe String
, sort : Sort
, showSort : Bool
, showNixOSDetails : Bool
}

@@ -174,6 +175,7 @@ init args maybeModel =
|> Maybe.withDefault ""
|> fromSortId
|> Maybe.withDefault Relevance
, showSort = False
, showNixOSDetails = False
}
|> ensureLoading
@@ -213,6 +215,7 @@ elementId str =
type Msg a b
= NoOp
| SortChange Sort
| ToggleSort
| BucketsChange String
| ChannelChange String
| QueryInput String
@@ -258,6 +261,13 @@ update toRoute navKey msg model =
|> ensureLoading
|> pushUrl toRoute navKey

ToggleSort ->
( { model
| showSort = not model.showSort
}
, Cmd.none
)

BucketsChange buckets ->
{ model
| buckets =
@@ -577,7 +587,16 @@ view { toRoute, categoryName } title model viewSuccess viewBuckets outMsg =
RemoteData.Failure _ ->
"failure"
in
div [ class <| "search-page " ++ resultStatus ]
div
(List.append
[ class <| "search-page " ++ resultStatus ]
(if model.showSort then
[ onClick (outMsg ToggleSort) ]

else
[]
)
)
[ h1 [] title
, viewSearchInput outMsg categoryName model.channel model.query
, viewResult outMsg toRoute categoryName model viewSuccess viewBuckets
@@ -781,7 +800,7 @@ viewResults model result viewSuccess toRoute outMsg categoryName =
String.fromInt result.hits.total.value
in
[ div []
[ Html.map outMsg <| viewSortSelection toRoute model
[ Html.map outMsg <| viewSortSelection model
, div []
(List.append
[ text "Showing results "
@@ -812,20 +831,27 @@ viewResults model result viewSuccess toRoute outMsg categoryName =


viewSortSelection :
Route.SearchRoute
-> Model a b
Model a b
-> Html (Msg a b)
viewSortSelection toRoute model =
div [ class "btn-group dropdown pull-right" ]
viewSortSelection model =
div
[ class "btn-group dropdown pull-right"
, classList
[ ( "open", model.showSort )
]
, onClickStop NoOp
]
[ button
[ class "btn"
, attribute "data-toggle" "dropdown"
, onClick ToggleSort
]
[ span [] [ text <| "Sort: " ]
, span [ class "selected" ] [ text <| toSortTitle model.sort ]
, span [ class "caret" ] []
]
, ul [ class "dropdown-menu pull-right" ]
, ul
[ class "pull-right dropdown-menu"
]
(List.append
[ li [ class " header" ] [ text "Sort options" ]
, li [ class "divider" ] []
25 changes: 15 additions & 10 deletions src/index.less
Original file line number Diff line number Diff line change
@@ -292,7 +292,7 @@ header .navbar.navbar-static-top {

& > ul > li.header {
font-weight: bold;
padding: 3px 10px;
padding: 3px 10px 0 10px;
}

& > ul > li.header:before,
@@ -339,16 +339,16 @@ header .navbar.navbar-static-top {
display: block;
}

// Description
& > :nth-child(2) {
font-size: 1.2em;
margin-bottom: 0.5em;
text-align: left;
}

&.package {
.search-result-item();

// Description
& > :nth-child(2) {
font-size: 1.2em;
margin-bottom: 0.5em;
text-align: left;
}

// short details of a pacakge
& > :nth-child(3) {
color: #666;
@@ -418,10 +418,15 @@ header .navbar.navbar-static-top {
}

&.option {
.search-result-item();
margin: 0;
padding: 0;

& > :nth-child(1) {
padding: 0.5em 0;
}

// short details of a pacakge
& > :nth-child(4) {
& > :nth-child(2) {
margin: 2em 0 1em 1em;
display: grid;
grid-template-columns: 100px 1fr;