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: 9aec6bec8ed2
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: cdeb29766a18
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Jan 17, 2021

  1. Copy the full SHA
    cdeb297 View commit details
Showing with 79 additions and 61 deletions.
  1. +22 −18 src/Page/Options.elm
  2. +4 −14 src/Page/Packages.elm
  3. +23 −0 src/Search.elm
  4. +30 −29 src/index.less
40 changes: 22 additions & 18 deletions src/Page/Options.elm
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import Html.Attributes
( class
, href
, target
, classList
)
import Html.Events
exposing
@@ -151,14 +152,13 @@ viewResultItem :
viewResultItem channel _ show item =
let
showHtml value =
[ div [] <|
div [] <|
case Html.Parser.run value of
Ok nodes ->
Html.Parser.Util.toVirtualDom nodes

Err _ ->
[]
]

default =
"Not given"
@@ -212,7 +212,7 @@ viewResultItem channel _ show item =

showDetails =
if Just item.source.name == show then
[ div [ Html.Attributes.map SearchMsg Search.trapClick ]
div [ Html.Attributes.map SearchMsg Search.trapClick ]
[ div [] [ text "Default value" ]
, div [] [ withEmpty (wrapped asPreCode) item.source.default ]
, div [] [ text "Type" ]
@@ -222,31 +222,35 @@ viewResultItem channel _ show item =
, div [] [ text "Declared in" ]
, div [] [ withEmpty asGithubLink item.source.source ]
]
]
|> Just

else
[]
Nothing

open =
toggle =
SearchMsg (Search.ShowDetails item.source.name)

isOpen =
Just item.source.name == show
in
li
[ class "option"
, onClick open
, classList [ ( "opened", isOpen ) ]
, Search.elementId item.source.name
]
(showDetails
|> List.append
(item.source.description
|> Maybe.map showHtml
|> Maybe.withDefault []
)
|> List.append
[ Html.button
[ class "search-result-button" ]
<|
List.filterMap identity
[ Just <|
Html.button
[ class "search-result-button"
, onClick toggle
]
[ text item.source.name ]
]
)
, Maybe.map showHtml item.source.description
, Just <|
Search.showMoreButton toggle isOpen
, showDetails
]



18 changes: 4 additions & 14 deletions src/Page/Packages.elm
Original file line number Diff line number Diff line change
@@ -546,11 +546,12 @@ viewResultItem channel showNixOSDetails show item =

trapClick =
Html.Attributes.map SearchMsg Search.trapClick
isOpen =
Just item.source.attr_name == show
in
li
[ class "package"
, classList
[ ( "opened", Just item.source.attr_name == show ) ]
, classList [ ( "opened", isOpen) ]
, Search.elementId item.source.attr_name
]
([]
@@ -563,18 +564,7 @@ viewResultItem channel showNixOSDetails show item =
[ text item.source.attr_name ]
, div [] [ text <| Maybe.withDefault "" item.source.description ]
, shortPackageDetails
, a
[ href "#"
, onClick toggle
]
[ text
(if Just item.source.attr_name == show then
"▲▲▲ Hide package details ▲▲▲"

else
"▾▾▾ Show more package details ▾▾▾"
)
]
, Search.showMoreButton toggle isOpen
]
)

23 changes: 23 additions & 0 deletions src/Search.elm
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ module Search exposing
, makeRequestBody
, onClickStop
, shouldLoad
, showMoreButton
, trapClick
, update
, view
@@ -1143,6 +1144,28 @@ decodeAggregationBucketItem =



-- Html Helper elemetnts


showMoreButton : msg -> Bool -> Html msg
showMoreButton toggle isOpen =
div [ class "result-item-show-more-wrapper" ]
[ a
[ href "#"
, onClick toggle
, class "result-item-show-more"
]
[ text <|
if isOpen then
"▲▲▲ Hide package details ▲▲▲"

else
"▾▾▾ Show more package details ▾▾▾"
]
]



-- Html Event Helpers


59 changes: 30 additions & 29 deletions src/index.less
Original file line number Diff line number Diff line change
@@ -18,6 +18,34 @@
text-decoration: underline;
}
}

.result-item-show-more-wrapper {
text-align: center;
}

// show longer details link
.result-item-show-more {
margin: 0 auto;
display: none;
text-align: center;
text-decoration: none;
line-height: 1.5em;
color: #666;
background: #FFF;
padding: 0 1em;
position: relative;
top: 0.75em;
outline: none;
}
&.opened,
&:hover {
padding-bottom: 0;

.result-item-show-more {
display: inline-block;
padding-top: 0.5em;
}
}
}

/* ------------------------------------------------------------------------- */
@@ -276,7 +304,6 @@ header .navbar.navbar-static-top {
font-size: 0.7em;
}
}

}

// Search results list
@@ -289,7 +316,6 @@ header .navbar.navbar-static-top {
border-bottom: 1px solid #ccc;
padding-bottom: 2em;
margin-bottom: 2em;
text-align: center;

&:last-child {
border-bottom: 0;
@@ -337,30 +363,6 @@ header .navbar.navbar-static-top {
}
}

// show longer details link
& > :nth-child(4) {
margin: 0 auto;
display: none;
text-align: center;
text-decoration: none;
line-height: 1.5em;
color: #666;
background: #FFF;
padding: 0 1em;
position: relative;
top: 0.75em;
outline: none;
}
&.opened,
&:hover {
padding-bottom: 0;

& > :nth-child(4) {
display: inline-block;
padding-top: 0.5em;
}
}

// longer details of a pacakge
& > :nth-child(5) {
margin: 2em 0 1em 1em;
@@ -413,9 +415,8 @@ header .navbar.navbar-static-top {
.search-result-item();

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