Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/main/scala/pgkn/pages/KaptenAlloc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,34 @@ object KaptenAlloc:
private def renderTableRow(
entry: pgkn.model.FormattedKaptenAllocEntry,
selectedId: Option[String],
showToast: Var[Boolean]
showToast: Var[Boolean],
searchQuery: Var[String]
): HtmlElement =

def tdFilter(data: String): HtmlElement = {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps consider declaring this function outside the renderTableRow function with the additional parameter searchQuery. I don't know if this applies to Laminar, but for example in React you don't want to declare a component inside another component, as that will lead to the inner component being redeclared each time the outer component re-runs. Do you understand what I mean? Otherwise, very nice.

td(
span(data,
onClick.mapTo(data) --> searchQuery
)
)
}

tr(
dataAttr("entry-id") := entry.id,
className := selectedId
.filter(_ == entry.id)
.map(_ => "selected")
.getOrElse(""),
onMountCallback(ctx => scrollToEntry(ctx, entry.id, selectedId)),
onClick --> (_ => copyEntryLink(entry.id, showToast)),
td(entry.entryType),
td(entry.dateStr),
td(entry.weekNum),
td(entry.dayStr),
td(entry.timeStr),
td(entry.group),
td(entry.room),
td(entry.supervisor)
//onClick --> (_ => copyEntryLink(entry.id, showToast)),
tdFilter(entry.entryType),
tdFilter(entry.dateStr),
tdFilter(entry.weekNum),
tdFilter(entry.dayStr),
tdFilter(entry.timeStr),
tdFilter(entry.group),
tdFilter(entry.room),
tdFilter(entry.supervisor)
)

def apply(
Expand Down Expand Up @@ -259,7 +269,7 @@ object KaptenAlloc:
),
tbody(
children <-- filteredFormattedEntries.map(
_.map(entry => renderTableRow(entry, selectedId, showToast))
_.map(entry => renderTableRow(entry, selectedId, showToast, searchQuery))
Comment thread
eflisback marked this conversation as resolved.
)
)
)
Expand Down
5 changes: 5 additions & 0 deletions styles/pages/kapten-alloc.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
cursor: pointer;
}

.kapten-alloc-table tbody tr:nth-child(n + 1) span:hover {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this complex CSS selector? Wouldn't it work with just .kapten-alloc-table tbody tr span:hover?

text-decoration: underline;
color: var(--color-text);
}

.kapten-alloc-table tbody tr:nth-child(odd) {
background-color: var(--color-bg);
}
Expand Down