Skip to content

Commit

Permalink
Merge pull request #30 from ropensci-review-tools/reviews
Browse files Browse the repository at this point in the history
change reviews page to observable for #12
  • Loading branch information
mpadge authored Apr 23, 2024
2 parents 9bd1930 + 6657b02 commit bb89f18
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 235 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ on:
workflow_dispatch:
push:
branches: main
pull_request:
branches: main
schedule:
- cron: 0 0 * * *

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashboard
Title: What the Package Does (One Line, Title Case)
Version: 0.1.8.024
Version: 0.1.8.040
Authors@R:
person(given = "First",
family = "Last",
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "dashboard: What the Package Does (One Line, Title Case)",
"codeRepository": "https://github.com/ropensci-review-tools/dashboard",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.8.024",
"version": "0.1.8.040",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
72 changes: 72 additions & 0 deletions quarto/_colorTable_fn.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,75 @@ function colorTable(data, {
return form;
}
```

```{ojs}
// And modified verison for open reviews table
function reviewTable(data, {
colorColumn,
colorOpacity = 0.5,
issueNumColumn,
titleColumn,
columns = undefined,
format = {}, ...options}) {
const [row] = data;
if(!row) return Inputs.table(data, options);
let index = Object.keys(row).indexOf(colorColumn);
if(index < 0) throw Error("colorColumn not found in data");
if(format[colorColumn]) throw Error("colorColumn is reserved");
if(columns && columns.indexOf(colorColumn) < 0) columns.push(colorColumn);
if(columns) index = columns.indexOf(colorColumn);
const nth = `nth-child(${index + 2})`;
// Observable Table doesn't know about rows, so need to convert the
// "titleColumn" into an array with the title and issue number
// so then pass to the `format` call below to construct <a> href
// objects:
const preprocessedData = data.map(row => ({
...row,
[titleColumn]: [row[titleColumn],row[issueNumColumn]]
}));``
const form = Inputs.table(preprocessedData, {
format: {
...format,
[colorColumn]: d => htl.html`<div style="--row-color:${d}">`,
[issueNumColumn]: d => htl.html`<a href="https://github.com/ropensci/software-review/issues/${d}">${d}</a>`,
[titleColumn]: d => htl.html`<span style="white-space:break-spaces;"><a href="https://github.com/ropensci/software-review/issues/${d[1]}">${d[0]}</a></span>`,
},
columns,
...options
});
const scope = DOM.uid().id;
form.classList.add(scope);
form.append(htl.html`<style>
/* Ensure that the sticky header always stays on top */
.${scope} thead { position: relative; z-index: 2 }
/* Hide the last column */
.${scope} th:${nth},
.${scope} td:${nth} { width: 0; padding: 0 }
.${scope} th:${nth} { visibility: hidden }
/* Inject the background color */
.${scope} tr { position: relative }
.${scope} td:${nth} div:after {
opacity: ${colorOpacity};
content: "";
display: block;
height: 100%;
width: 100%;
position: absolute;
left: 0;
top: 0;
z-index: -1;
background-color: var(--row-color);
}
`);
return form;
}
```
5 changes: 0 additions & 5 deletions quarto/ed-reviews.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ format:

```{r load-pkg-ed-rev, echo = FALSE, message = FALSE}
library (dashboard)
library (gt)
library (ggplot2)
library (tidyr)
library (dplyr)
library (viridis)
```

```{r get-ed-dat, echo = FALSE, message = FALSE}
Expand Down
Loading

0 comments on commit bb89f18

Please sign in to comment.