mirror of
https://github.com/daylinmorgan/nimpkgs.git
synced 2024-12-21 18:50:43 -06:00
maintain sort settings better
This commit is contained in:
parent
f8b3c959bd
commit
e0fc3b6d83
4 changed files with 25 additions and 15 deletions
|
@ -3,7 +3,7 @@ import std/[strutils, sequtils, uri, random]
|
||||||
import karax/[kbase, karax, karaxdsl, vdom, jstrutils, ]
|
import karax/[kbase, karax, karaxdsl, vdom, jstrutils, ]
|
||||||
|
|
||||||
import ../[packages, style, context]
|
import ../[packages, style, context]
|
||||||
import ../components/tag
|
import ../components/[tag, search]
|
||||||
import ../lib
|
import ../lib
|
||||||
|
|
||||||
randomize()
|
randomize()
|
||||||
|
@ -50,7 +50,7 @@ proc card*(pkg: NimPackage): VNode =
|
||||||
if pkg.isAlias:
|
if pkg.isAlias:
|
||||||
tdiv:
|
tdiv:
|
||||||
text "alias for: "
|
text "alias for: "
|
||||||
span(onClick = setSearchUrl("name:" & pkg.alias),
|
span(onClick = setSearchInput("name:" & pkg.alias),
|
||||||
class = "link"):
|
class = "link"):
|
||||||
text pkg.alias
|
text pkg.alias
|
||||||
else:
|
else:
|
||||||
|
@ -58,7 +58,7 @@ proc card*(pkg: NimPackage): VNode =
|
||||||
tdiv(class = "flex flex-wrap text-xs md:text-md overflow-x-auto"):
|
tdiv(class = "flex flex-wrap text-xs md:text-md overflow-x-auto"):
|
||||||
for t in pkg.tags:
|
for t in pkg.tags:
|
||||||
tdiv(
|
tdiv(
|
||||||
onClick = setSearchUrl("tag:" & t.replace(" ", "-")),
|
onClick = setSearchInput("tag:" & t.replace(" ", "-")),
|
||||||
class = "link"):
|
class = "link"):
|
||||||
t.renderTag
|
t.renderTag
|
||||||
|
|
||||||
|
@ -78,8 +78,6 @@ proc recentPackageVersionsList*(): VNode =
|
||||||
href = "/#/pkg/" & pkg.name):
|
href = "/#/pkg/" & pkg.name):
|
||||||
span(class = textStyle & "group-hover:text-ctp-mauve font-bold font-mono-casual"): text pkg.name
|
span(class = textStyle & "group-hover:text-ctp-mauve font-bold font-mono-casual"): text pkg.name
|
||||||
span(class = "group-hover:text-ctp-mauve"): text pkg.versions[0].tag
|
span(class = "group-hover:text-ctp-mauve"): text pkg.versions[0].tag
|
||||||
# span:
|
|
||||||
# text " (" & (getTime() - pkg.versions[0].time).inDays.jss & " days ago)"
|
|
||||||
|
|
||||||
proc randomPackage*(ctx: Context): VNode =
|
proc randomPackage*(ctx: Context): VNode =
|
||||||
let pkgName = ctx.nimpkgs.packages.keys().toSeq().sample()
|
let pkgName = ctx.nimpkgs.packages.keys().toSeq().sample()
|
||||||
|
|
|
@ -61,15 +61,6 @@ proc getSearchFromUri*(): kstring =
|
||||||
if k == "query":
|
if k == "query":
|
||||||
return v.kstring
|
return v.kstring
|
||||||
|
|
||||||
proc getSearchInput*() =
|
|
||||||
let searchInput = getVNodeById("search").getInputText
|
|
||||||
let sortNode = getVNodeById("sort-select")
|
|
||||||
let sortMethod = SortMethod(
|
|
||||||
if sortNode != nil: parseInt(sortNode.getInputText)
|
|
||||||
else: 0
|
|
||||||
)
|
|
||||||
setSearchUrl(searchInput, sortMethod)()
|
|
||||||
|
|
||||||
proc searchBar*(value = jss""): Vnode =
|
proc searchBar*(value = jss""): Vnode =
|
||||||
buildHtml(tdiv(class = "flex flex-row my-2 grow")):
|
buildHtml(tdiv(class = "flex flex-row my-2 grow")):
|
||||||
input(`type` = "text", class = "bg-ctp-crust md:mx-3 mx-1 p-2 grow".kstring & borderStyle, `id` = "search",
|
input(`type` = "text", class = "bg-ctp-crust md:mx-3 mx-1 p-2 grow".kstring & borderStyle, `id` = "search",
|
||||||
|
|
21
src/lib.nim
21
src/lib.nim
|
@ -41,3 +41,24 @@ proc setSearchUrl*(searchQuery: kstring, sortMethod = smAlphabetical): proc() =
|
||||||
scrollIntoView(node)
|
scrollIntoView(node)
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
|
proc getSearchInput*() =
|
||||||
|
let searchInput = getVNodeById("search").getInputText
|
||||||
|
let sortNode = getVNodeById("sort-select")
|
||||||
|
let sortMethod = SortMethod(
|
||||||
|
if sortNode != nil: parseInt($sortNode.getInputText)
|
||||||
|
else: 0
|
||||||
|
)
|
||||||
|
setSearchUrl(searchInput, sortMethod)()
|
||||||
|
|
||||||
|
|
||||||
|
proc setSearchInput*(q: kstring): proc() =
|
||||||
|
result = proc() =
|
||||||
|
let sortNode = getVNodeById("sort-select")
|
||||||
|
let sortMethod = SortMethod(
|
||||||
|
if sortNode != nil: parseInt($sortNode.getInputText)
|
||||||
|
else: 0
|
||||||
|
)
|
||||||
|
setSearchUrl(q, sortMethod)()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ proc scrollToAnchor(a: string): proc() =
|
||||||
|
|
||||||
proc letterlink(activeLinks: seq[char]): VNode = buildHtml:
|
proc letterlink(activeLinks: seq[char]): VNode = buildHtml:
|
||||||
tdiv(
|
tdiv(
|
||||||
class = "flex flex-wrap md:text-xl text-lg capitalize w-full justify-evenly gap-x-2 md:gap-x-auto"
|
class = "flex flex-wrap md:text-xl text-lg capitalize w-full justify-evenly gap-x-2 md:gap-x-auto"
|
||||||
):
|
):
|
||||||
for l in LowercaseLetters:
|
for l in LowercaseLetters:
|
||||||
tdiv(class = "w-5"):
|
tdiv(class = "w-5"):
|
||||||
|
|
Loading…
Reference in a new issue