Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fuzzyhelp): improve Shiny UI #25

Merged
merged 4 commits into from
May 5, 2024
Merged
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
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
Loading