Skip to content

Commit 6117f83

Browse files
committed
improve doc + refs
1 parent 19d8795 commit 6117f83

13 files changed

+173
-96
lines changed

DESCRIPTION

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Package: scoutbaR
2-
Title: Scoutbar 'React' Widget for 'shiny'
2+
Title: A Spotlight 'React' Widget for 'shiny' Apps
33
Version: 0.0.1
4-
Authors@R:
5-
person("David", "Granjon", , "[email protected]", role = c("aut", "cre"))
4+
Authors@R: c(
5+
person("David", "Granjon", , "[email protected]", role = c("aut", "cre")),
6+
person("Adenekan", "Wonderful", , "[email protected]", role = c("cph"), comment = "Scoutbar React library: <https://github.com/adenekan41/scoutbar>"))
67
Description: Creates a contextual menu that can be triggered with keyboard shortcuts or programmatically.
78
This can replace traditional sidebars or navigation bars, thereby enhancing the
89
user experience with lighter user interfaces.

R/scoutbar.R

+54-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#'
33
#' Scoutbar react widget for Shiny.
44
#'
5+
#' Provides a contextual menu users can activate
6+
#' with keyboard shortcut or prommatically with \link{update_scoutbar}.
7+
#' Scoutbar may be seen as an alternative to sidebars and navbars, as it allows
8+
#' to construct better navigation menus.
9+
#'
510
#' @importFrom reactR createReactShinyInput
611
#' @importFrom htmltools htmlDependency tags
712
#'
@@ -15,8 +20,11 @@
1520
#' @param ... Any other configuration parameter. See
1621
#' \url{https://www.scoutbar.co/docs/features}.
1722
#'
23+
#' @return A list of shiny tags containing all the web dependencies
24+
#' and scoutbar elements required to instantiate the Scoutbar React widget from
25+
#' JavaScript.
1826
#' @export
19-
#' @rdname scout-bar
27+
#' @rdname scoutbar
2028
scoutbar <- function(
2129
inputId,
2230
theme = c("light", "dark", "auto"),
@@ -51,20 +59,42 @@ scoutbar <- function(
5159
#' Can embed \link{scout_action} on a separate
5260
#' view of the Scoutbar.
5361
#'
62+
#' Whenever many \link{scout_action} share a similar topic,
63+
#' or have nested topics, this function allows you to provide a better
64+
#' experience by isolating some actions in a separate view. You can nest
65+
#' pages within other pages and combine it with \link{scout_section}.
66+
#'
5467
#' @param label Page label.
5568
#' @param ... Expect \link{scout_action}.
5669
#' @param .list To pass a list of \link{scout_action}.
70+
#' \itemize{
71+
#' \item children: a sublist where are passed the \link{scout_action}.
72+
#' \item label: The page label.
73+
#' \item class: a character vector to identify the page on the JavaScript side.
74+
#' You are not expected to modify it as it will break the JavaScript binding.
75+
#' }
5776
#' @export
5877
scout_page <- function(label, ..., .list = NULL) {
5978
scout_container("scout_page", .list, label, ...)
6079
}
6180

6281
#' Creates a scout section
6382
#'
64-
#' Can sort \link{scout_action} on the same view.
83+
#' Sort \link{scout_action} on the same view.
84+
#'
85+
#' Whenever many \link{scout_action} share a similar topic,
86+
#' you may use this function to sort them in the UI and offer
87+
#' a better user experience. You can combine it with \link{scout_page}.
6588
#'
6689
#' @param label Section label.
6790
#' @inheritParams scout_page
91+
#' @return A list containing:
92+
#' \itemize{
93+
#' \item children: a sublist where are passed the \link{scout_action}.
94+
#' \item label: The section label.
95+
#' \item class: a character vector to identify the section on the JavaScript side.
96+
#' You are not expected to modify it as it will break the JavaScript binding.
97+
#' }
6898
#' @export
6999
scout_section <- function(label, ..., .list = NULL) {
70100
scout_container("scout_section", .list, label, ...)
@@ -81,14 +111,26 @@ scout_container <- function(cl, .list, label, ...) {
81111

82112
#' Creates a scout action
83113
#'
84-
#' Can sort \link{scout_action} on the same view.
114+
#' Creates an item that can perform actions on the server side.
115+
#'
116+
#' This function is meant to be embeded directly within
117+
#' \link{scoutbar} or via a more structured way within \link{scout_page}
118+
#' or \link{scout_section}. It serves as a bridge between R and JavaScript to
119+
#' communicate with the Scoutbar React API, so you are not expected to call it on its
120+
#' own.
85121
#'
86122
#' @param id Unique id.
87123
#' @param label Action label.
88124
#' @param description Action description.
89125
#' @param closeOnClick Whether to close the scoutbar whenever this action is
90126
#' clicked. Default to TRUE.
91127
#' @param ... Other options. See \url{https://www.scoutbar.co/docs/actions}.
128+
#' @return A list containing:
129+
#' \itemize{
130+
#' \item children: a sublist where are passed the options.
131+
#' \item class: a character vector to identify the action on the JavaScript side.
132+
#' You are not expected to modify it as it will break the JavaScript binding.
133+
#' }
92134
#' @export
93135
scout_action <- function(id, label, description, closeOnClick = TRUE, ...) {
94136
props <- list(
@@ -110,19 +152,22 @@ scout_action <- function(id, label, description, closeOnClick = TRUE, ...) {
110152

111153
#' Update a Scoutbar widget on the client
112154
#'
113-
#' Usee this function from the server side of
114-
#' your Shiny app.
155+
#' Use this function from the server side of
156+
#' your Shiny app to update a \link{scoutbar}.
115157
#'
116158
#' @export
117159
#' @param session Shiny session object.
118-
#' @param configuration Scoutbar configuration. Expect a list of properties.
119-
#' See possible values here at \url{https://www.scoutbar.co/docs/features}.
120-
#' @rdname scout-bar
160+
#' @param ... Scoutbar configuration. Expect a list of properties
161+
#' like in \link{scoutbar}. See possible values here at \url{https://www.scoutbar.co/docs/features}.
162+
#' @return This function is called for its side effect. It sends a message to JavaScript
163+
#' through the current websocket connection, leveraging the shiny session object.
164+
#' @rdname scoutbar
121165
update_scoutbar <- function(
122166
session = shiny::getDefaultReactiveDomain(),
123167
inputId,
124-
configuration = NULL) {
168+
...) {
125169
message <- list()
170+
configuration <- list(...)
126171
if (!is.null(configuration)) {
127172
message$configuration <- c(
128173
configuration,

README.Rmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ devtools::install_github("cynkra/scoutbaR")
3838

3939
## Example
4040

41-
`{scoutbaR}` is easy to use:
41+
`{scoutbaR}` is easy to use. The app below shows how to leverage `scout_action()`, `scout_section()` and `scout_page()`:
4242

4343
```r
4444
library(scoutbaR)
@@ -105,11 +105,11 @@ ui <- page_fillable(
105105
server <- function(input, output, session) {
106106

107107
observeEvent(input$update, {
108-
update_scoutbar(session, "scoutbar", list(revealScoutbar = TRUE))
108+
update_scoutbar(session, "scoutbar", revealScoutbar = TRUE)
109109
})
110110

111111
observeEvent(input$theme, {
112-
update_scoutbar(session, "scoutbar", list(theme = input$theme))
112+
update_scoutbar(session, "scoutbar", theme = input$theme)
113113
})
114114
output$textOutput <- renderText({
115115
sprintf("You entered: %s", input$scoutbar)

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ devtools::install_github("cynkra/scoutbaR")
3232

3333
## Example
3434

35-
`{scoutbaR}` is easy to use:
35+
`{scoutbaR}` is easy to use. The app below shows how to leverage
36+
`scout_action()`, `scout_section()` and `scout_page()`:
3637

3738
``` r
3839
library(scoutbaR)
@@ -99,11 +100,11 @@ ui <- page_fillable(
99100
server <- function(input, output, session) {
100101

101102
observeEvent(input$update, {
102-
update_scoutbar(session, "scoutbar", list(revealScoutbar = TRUE))
103+
update_scoutbar(session, "scoutbar", revealScoutbar = TRUE)
103104
})
104105

105106
observeEvent(input$theme, {
106-
update_scoutbar(session, "scoutbar", list(theme = input$theme))
107+
update_scoutbar(session, "scoutbar", theme = input$theme)
107108
})
108109
output$textOutput <- renderText({
109110
sprintf("You entered: %s", input$scoutbar)

cran-comments.md

-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
11
## R CMD check results
22

33
0 errors | 0 warnings | 1 note
4-
5-
NOTES in the window devel checks
6-
7-
* Possibly misspelled words in DESCRIPTION:
8-
programmatically
9-
10-
What is wrong with this word?
11-
12-
* Found the following (possibly) invalid URLs:
13-
URL: https://www.scoutbar.co/
14-
From: DESCRIPTION
15-
README.md
16-
Status: Error
17-
Message: Recv failure: Connection was reset
18-
URL: https://www.scoutbar.co/docs/actions
19-
From: man/scout_action.Rd
20-
Status: Error
21-
Message: Recv failure: Connection was reset
22-
URL: https://www.scoutbar.co/docs/features
23-
From: man/scout-bar.Rd
24-
Status: Error
25-
Message: Recv failure: Connection was reset
26-
27-
I am not sure how to fix this. The url works fine.

inst/examples/simple/app.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ ui <- page_fillable(
6262
server <- function(input, output, session) {
6363

6464
observeEvent(input$update, {
65-
update_scoutbar(session, "scoutbar", list(revealScoutbar = TRUE))
65+
update_scoutbar(session, "scoutbar", revealScoutbar = TRUE)
6666
})
6767

6868
observeEvent(input$theme, {
69-
update_scoutbar(session, "scoutbar", list(theme = input$theme))
69+
update_scoutbar(session, "scoutbar", theme = input$theme)
7070
})
7171
output$textOutput <- renderText({
7272
sprintf("You entered: %s", input$scoutbar)

man/scout-bar.Rd

-47
This file was deleted.

man/scout_action.Rd

+16-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scout_page.Rd

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scout_section.Rd

+22-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)