Looks up the effective label/help/placeholder for a single UI element,
applying the defaults -> params -> layers specificity chain and
interpolating the {param} / {layer} tokens. Placeholder authors can
call this inside a custom build_ui hook so their control is labelled
through the same override chain as the built-in controls.
Usage
ptr_resolve_ui_text(
component,
keyword = NULL,
param = NULL,
layer_name = NULL,
ui_text = NULL
)Arguments
- component
One of
title,draw_button,draw_all_button,layer_picker,data_subtab,controls_subtab,upload_file,upload_name,layer_checkbox, orcontrol(for a placeholder control, in which casekeywordis required).- keyword
Placeholder keyword (e.g.
"ppVar","ppNum"); required whencomponent = "control".- param
Optional parameter / aesthetic name (e.g.
"x"); only used whencomponent = "control".- layer_name
Optional layer name (e.g.
"facet_wrap"); only used whencomponent = "control", to pick up alayers$<layer>$...override.- ui_text
NULL, a list of overrides, or an already-mergedptr_ui_textobject (seeptr_ui_text()).
Examples
# Resolve copy for the title element
ptr_resolve_ui_text("title")
#> $label
#> [1] "ggpaintr Plot Builder"
#>
# Resolve copy for a var control on the x-axis
ptr_resolve_ui_text("control", keyword = "ppVar", param = "x")
#> $label
#> [1] "Choose the x-axis column"
#>
#> $empty_text
#> [1] "Choose one column"
#>
# Inside a custom `build_ui` hook, label the control through the same
# override chain ggpaintr uses for built-in controls:
my_build_ui <- function(node, label, ...) {
copy <- ptr_resolve_ui_text(
"control",
keyword = node$keyword,
param = node$param,
ui_text = list(...)$ui_text
)
shiny::textInput(node$id, label = copy$label %||% label)
}
