2
2
# '
3
3
# ' Scoutbar react widget for Shiny.
4
4
# '
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
+ # '
5
10
# ' @importFrom reactR createReactShinyInput
6
11
# ' @importFrom htmltools htmlDependency tags
7
12
# '
15
20
# ' @param ... Any other configuration parameter. See
16
21
# ' \url{https://www.scoutbar.co/docs/features}.
17
22
# '
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.
18
26
# ' @export
19
- # ' @rdname scout-bar
27
+ # ' @rdname scoutbar
20
28
scoutbar <- function (
21
29
inputId ,
22
30
theme = c(" light" , " dark" , " auto" ),
@@ -51,20 +59,42 @@ scoutbar <- function(
51
59
# ' Can embed \link{scout_action} on a separate
52
60
# ' view of the Scoutbar.
53
61
# '
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
+ # '
54
67
# ' @param label Page label.
55
68
# ' @param ... Expect \link{scout_action}.
56
69
# ' @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
+ # ' }
57
76
# ' @export
58
77
scout_page <- function (label , ... , .list = NULL ) {
59
78
scout_container(" scout_page" , .list , label , ... )
60
79
}
61
80
62
81
# ' Creates a scout section
63
82
# '
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}.
65
88
# '
66
89
# ' @param label Section label.
67
90
# ' @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
+ # ' }
68
98
# ' @export
69
99
scout_section <- function (label , ... , .list = NULL ) {
70
100
scout_container(" scout_section" , .list , label , ... )
@@ -81,14 +111,26 @@ scout_container <- function(cl, .list, label, ...) {
81
111
82
112
# ' Creates a scout action
83
113
# '
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.
85
121
# '
86
122
# ' @param id Unique id.
87
123
# ' @param label Action label.
88
124
# ' @param description Action description.
89
125
# ' @param closeOnClick Whether to close the scoutbar whenever this action is
90
126
# ' clicked. Default to TRUE.
91
127
# ' @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
+ # ' }
92
134
# ' @export
93
135
scout_action <- function (id , label , description , closeOnClick = TRUE , ... ) {
94
136
props <- list (
@@ -110,19 +152,22 @@ scout_action <- function(id, label, description, closeOnClick = TRUE, ...) {
110
152
111
153
# ' Update a Scoutbar widget on the client
112
154
# '
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} .
115
157
# '
116
158
# ' @export
117
159
# ' @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
121
165
update_scoutbar <- function (
122
166
session = shiny :: getDefaultReactiveDomain(),
123
167
inputId ,
124
- configuration = NULL ) {
168
+ ... ) {
125
169
message <- list ()
170
+ configuration <- list (... )
126
171
if (! is.null(configuration )) {
127
172
message $ configuration <- c(
128
173
configuration ,
0 commit comments