Skip to content

Commit

Permalink
Merge pull request #25 from atusy/fuzzyhelp-resize
Browse files Browse the repository at this point in the history
feat(fuzzyhelp): improve Shiny UI
  • Loading branch information
atusy authored May 5, 2024
2 parents 70c9a60 + a1734dc commit a4ed5a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
11 changes: 8 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# felp 0.5.1

- Fixed `fuzzyhelp()` not showing preview on RStudio Server.
# felp 0.6.0

- Fixed `fuzzyhelp()` not showing preview on RStudio Server (#23).
- Remove **covr** and **rmarkdown** from suggests (#24).
- Improved Shiny UI of `fuzzyhelp()` (#25)
- resize with CSS instead of JS so that resize works properly on Chrome and Firefox
- increase height of help viewer
- theming TOC to be striped, be dense, and to highlight hovered-row

# felp 0.5.0

Expand Down
42 changes: 12 additions & 30 deletions R/fuzzyhelp.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,42 +277,17 @@ create_ui <- function(query = "", background = FALSE) {
miniUI::miniContentPanel(
shiny::textInput(
"query",
label = "Search query",
label = NULL,
placeholder = "Search query",
value = paste(query, collapse = " "),
width = "100%"
),
reactable::reactableOutput("tocViewer", width = "100%", height = "200px"),
htmltools::tags$div(
id = "bar",
style = paste(
"width: 100%; height: 8px; cursor: row-resize;",
"background-color: transparent;"
),
draggable = "true"
),
shiny::uiOutput("helpViewer"),
style = "display: grid; grid-template-rows: auto auto auto 1fr"
style = "display: grid; grid-template-rows: auto auto 1fr"
),
htmltools::tags$style("
#tocViewer {
overflow: hidden;
}
"),
htmltools::tags$script("
(function(){
// Resize tocViewer
const toc = document.getElementById('tocViewer');
const bar = document.getElementById('bar');
let screenY, tocHeight
bar.addEventListener('dragstart', function() {
screenY = window.event.screenY;
tocHeight = toc.getBoundingClientRect().height;
});
bar.addEventListener('drag', function() {
const diff = window.event.screenY - screenY;
toc.style.height = tocHeight + diff + 'px';
});
})();
#tocViewer { overflow: hidden; resize: vertical; margin-bottom: 15px }
"),
style = "display: grid; grid-template-rows: auto 1fr; height: 100vh"
)
Expand Down Expand Up @@ -350,7 +325,14 @@ create_server <- function(
defaultPageSize = 20,
selection = "single",
defaultSelected = if (nrow(toc_matched) != 0) 1L,
onClick = "select"
onClick = "select",
striped = TRUE,
highlight = TRUE,
theme = reactable::reactableTheme(
cellPadding = "2px",
style = list(fontSize = "0.9em"),
highlight = "beige"
)
)
}))
reactiveSelection <- shiny::reactive({
Expand Down

0 comments on commit a4ed5a5

Please sign in to comment.