for the page's
style given as a preset name; max_pins, keys and labels are
.
The engine's script and CSS, ready to add to a page.
tip_on() and tip_define() attach it for you; use this when
you build the page's head yourself, or to give the page a look. The dependency is versioned with the engine, not
with this package. The engine reads Bootstrap's colours where the page has them (bslib), and plain colours otherwise.
Which names on the page your own CSS and JavaScript may rely on, and which are internal, is in the section "What is
public on the page" of the
README.
Arguments
- style
as a preset name,
as a style object. How the tips look on the whole page, or
NULL(the default) to take the page's own bslib variables, so a page with abslib::bs_theme()follows it, light and dark, with nothing more. One of:a preset name from
tip_presets(), such as"sober";a
tip_style(), which bundles a preset, a theme, a class for the tip box, and its motion and size;one part of a style, read as
tip_style(<part>): atip_theme(), or abslib::bs_theme(), read through its variables (bslib 0.6.0 or later). The tip is a shade of the page: its fill is the theme's tertiary background and its words the theme's text colour, with the border colour, corner and font.
A tag's own
style(seetip_on()) beats the page's, and a value set nearer wins, value by value. A named list is not taken: givetip_theme()the roles, ortip_style(theme = list(...))a list of roles or of CSS variables such aslist("--hovercraft-tip-bg" = "#1b3a6b"). A string that holds:or;is not a style: it looks like CSS, andstyletakes no CSS.- max_pins
How many pinned tips the app keeps open, a whole number from 1 to 10; the default,
1, is one at a time. At the limit the oldest pin closes when a new one opens. Give it once, in the app's UI: a seconduse_hovercraft()with another number is seen by the page, which warns in the browser's console and keeps the first (a call that leavesmax_pinsout says nothing, so give it explicitly, even1, to be seen). Atip_table()with its ownmax_pinshas its own count, outside this one. All the pins open together, the app's and the tables', cannot pass 10, the engine's cap. On a viewport narrower than 600 pixels the engine shows a pin as a bottom sheet and keeps one at a time, somax_pins = 3means one there.- keys
The letter keys of a tip:
TRUE(the default) for all,FALSEfor none, or a named logical vector with one switch per key,c(pin = FALSE)orc(more = FALSE); a key left out stays on.pinis the key that pins the tagged item (P), which works while the focus is on the item or the pointer rests on it, and never inside a field;moreis the key that opens a tip's long form (M), whichtip_more()adds. Both work from a hover, so this is the page's switch: it turns a key off for every reader, and there is no switch for one reader. Escape always closes a tip. Switchingpinoff takes the key's announcement (aria-keyshortcuts) off the items too; the pin button stays. Give it once: a seconduse_hovercraft(keys = )that differs warns in the console and the first holds.- labels
The words the tips show themselves on the whole page, or
NULL(the default) for the built-in ones. A named character vector, such asc(copy = "Copy code", close = "Dismiss"); a word left out keeps its built-in one. The keys, with their built-in words, arecopy(Copy),copied(Copied),copy_failed(Copy failed),close(Close),not_available(Not available:),pinned({label}: details pinned. Tab to reach them.),code_line(code: {first}),code_line_empty(code, 1 line),code_lines(code, {n} lines, starting {first}),code_lines_empty(code, {n} lines),more(More),more_pinned(More when pinned),less(Less),pin(Pin this tip). Four keys take placeholders, which the page fills in:pinnedtakes{label}(the name of the item),code_linetakes{first}(the first line of the code) andcode_linesandcode_lines_emptytake{n}(the number of lines;code_linestakes{first}too); other braces stay as written. An unknown key, an empty or blank word, or a value that is not words stops with an error; the unknown key's error lists the keys. A tag's ownlabels(seetip_on()) beat the page's, key by key, andtip_more(label = )beats both for the buttons of one tip. Unlikekeys, where the first call holds, a seconduse_hovercraft(labels = )adds its words to the first, and a key that both give takes the later one. Useful for a page in another language.
Value
A list of htmltools::htmlDependency() objects: the engine's script and style sheet, then, with a style
that sets something, hovercraft-style, which holds the page's theme CSS and sets the page's preset and class as
the engine's attributes on the page, with a max_pins, keys or labels that is given one of their own, and last
hovercraft-runtime, which starts the engine and the layers (the names of these dependencies are internal and may
change). Put it
once in the page's UI, for example bslib::page_fluid(use_hovercraft(style = "sober"), ...).
Nothing in them is inline script or style: they are files and data, so a page served with
Content-Security-Policy: script-src 'self'; style-src 'self' works. A style sheet that is made from a theme is
data too, which a script applies as a constructed style sheet; it comes after the page's own style sheets in the
cascade. The scripts read their names and tip_define()'s templates from JSON, which a browser does not run, and
set styles through the browser's style object, which a policy on inline markup does not cover. Every dependency is
a folder of the installed package, so a cached document or a shared cache can use them in another R process.
What such a page still needs, because it is not hovercraft's markup:
a policy that has
default-srcorimg-srcmust also allowdata:images, or three small icons are not drawn: the lock before a reason (when_disabled), the pin button (pin) and the built-in icon ofmarker = "icon". The words of the first two still show; the marker has no words, so an icon marker is then invisible (an icon of your own, given as a tag, is not affected);a
styleattribute written in markup, such as the width thatshiny::actionButton()andshiny::plotOutput()write, is blocked bystyle-src 'self'whoever writes it.style-src-attr 'unsafe-inline'allows them, and nothing else, or the page can use classes and a style sheet instead.
See also
Other tooltips:
tip_blocks,
tip_define(),
tip_marker(),
tip_more(),
tip_on(),
tip_output(),
tip_presets(),
tip_server,
tip_spec(),
tip_style(),
tip_table(),
tip_template(),
tip_theme()
Examples
use_hovercraft()
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
use_hovercraft(style = "modern")
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-style"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJwYWdlIiwiYXR0cmlidXRlcyI6eyJkYXRhLWhvdmVyY3JhZnQtdGlwLXByZXNl\ndCI6Im1vZGVybiJ9fV0="
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[3]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
use_hovercraft(style = tip_theme(light = list(bg = "#1b3a6b", text = "#ffffff")))
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-style"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJjc3MiLCJpZCI6ImFmZTI5YjA0NmYxYWYyYzkiLCJ0ZXh0IjoiYm9keSB7XG4g\nIC0taG92ZXJjcmFmdC10aXAtYmc6ICMxYjNhN"| __truncated__
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[3]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
use_hovercraft(style = tip_style("sober", theme = list("--hovercraft-tip-radius" = "8px")))
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-style"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJjc3MiLCJpZCI6Ijg1MzFiODk3ZjU5YWUyNmQiLCJ0ZXh0IjoiYm9keSB7XG4g\nIC0taG92ZXJjcmFmdC10aXAtcmFkaXVzOiA4c"| __truncated__
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[3]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
use_hovercraft(max_pins = 3, keys = c(pin = FALSE))
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-max-pins-3"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJtYXhQaW5zIiwidmFsdWUiOjN9XQ=="
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[3]]
#> List of 10
#> $ name : chr "hovercraft-keys-pin"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJrZXlzIiwib2ZmIjpbInBpbiJdfV0="
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[4]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
use_hovercraft(
labels = c(copy = "Copy code", close = "Dismiss", more_pinned = "Open to read more")
)
#> [[1]]
#> List of 10
#> $ name : chr "hovercraft"
#> $ version : chr "0.60.0"
#> $ src :List of 1
#> ..$ file: chr "engine/www"
#> $ meta : NULL
#> $ script : chr "tip.js"
#> $ stylesheet: chr "tip.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[2]]
#> List of 10
#> $ name : chr "hovercraft-labels-6fbba16ef6a3"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-ops: chr "W3sib3AiOiJsYWJlbHMiLCJsYWJlbHMiOnsiY29weSI6IkNvcHkgY29kZSIsImNsb3NlIjoi\nRGlzbWlzcyIsIm1vcmVfcGlubmVkIjoiT3Blb"| __truncated__
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>
#> [[3]]
#> List of 10
#> $ name : chr "hovercraft-runtime"
#> $ version : chr "0.0.90"
#> $ src :List of 1
#> ..$ file: chr "runtime"
#> $ meta :List of 1
#> ..$ hovercraft-config: chr "eyJhdHRyaWJ1dGVzIjp7ImlkIjoiZGF0YS1ob3ZlcmNyYWZ0LXRpcC1pZCIsInBpbnMiOiJk\nYXRhLWhvdmVyY3JhZnQtdGlwLXBpbnMiLCJwa"| __truncated__
#> $ script : chr [1:2] "shiny.js" "runtime.js"
#> $ stylesheet: chr [1:2] "shiny.css" "status.css"
#> $ head : NULL
#> $ attachment: NULL
#> $ package : chr "hovercraft"
#> $ all_files : logi FALSE
#> - attr(*, "class")= chr "html_dependency"
#>