Compare moods and sizes on a single offline page. Creating the page starts no Shiny app, opens no viewer and writes no files. Printing the returned page opens the available Viewer or browser. It can also be embedded in an R Markdown or Quarto document.
Usage
mascot_preview(
character = "tessa",
...,
mood = NULL,
status = NULL,
bubble = NULL,
size = 160,
theme = NULL,
motion = FALSE
)Arguments
- character
A character id such as
"tessa", or amascot_character()helper (Knurl and Neer are experimental). Defaults to"tessa".NULLis not accepted.- ...
Must be empty. Forces the arguments after it to be named.
- mood
A mood name or
mascot_mood()object, orNULL(the default) to show every mood frommascot_moods().- status
A non-empty string or
mascot_status()object.NULL(the default) follows the mood. Text is always escaped, even insidehtmltools::HTML().- bubble
A non-empty string, an
htmltoolstag or tag list, or amascot_bubble()object.NULL(the default) shows no bubble. A plain string gets the defaults ofmascot_bubble(): five seconds and a close button. Plain text is escaped;htmltools::HTML()or tags supply HTML. Tags with dependencies or head content are not supported.- size
A finite number of CSS pixels (at least
24), a positive percentage string such as"20%", or amascot_size()object. Defaults to160. Percentages follow the comparison cell width.NULLis not accepted.- theme
A palette id string from
mascot_palettes(), a named list of colour roles, abslib::bs_theme()or amascot_theme()object.NULL(the default) keeps the character's own colours. A palette sets the base colours for light and dark mode;"original"selects the character's own colours. Roles you leave unset follow the character's rules.- motion
A logical flag or
mascot_motion_settings()object. Defaults toFALSEfor steady faces;TRUEallows movement unless the visitor prefers reduced motion.NULLis not accepted.
Value
A browsable htmltools tag list. Its contrast attribute is a data
frame with role, colour, background, ratio and mode columns, one row
per supplied colour below 3:1. With no findings it is a zero-row data frame
with the same columns. Colours are not changed. R gives one combined
warning unless mascot.contrast_warnings is FALSE.
Details
Comparison grid. Rows are moods; columns are the requested size, then
160, 96 and 24 CSS pixels. The first column keeps your percentage and
small_screen settings; the fixed columns do not change on narrow
screens. Every size draws the full character. Each cell keeps its status text,
since small faces lose fine detail.
Theme and contrast. A palette id string works as in mascot().
Built-in palette colours do not add contrast warnings. When the theme gives
both a light and a dark map, both are shown, even if it sets one mode.
Backgrounds are white and #212529, or the bslib theme's
bg and body-bg-dark; text uses fg and body-color-dark. Only supplied
colour roles are checked, using the same contrast calculation as mascot().
The browser reads colours from experimental CSS variables and checks them. Any
warnings appear in the browser's developer console, not in the R contrast attribute.
Bubbles. Cells without a bubble leave out its space; a supplied bubble keeps its normal space and timing. Each cell is wide enough to hold it, so bubbles never cover neighbouring cells.
See also
mascot(), mascot_colour_roles(), mascot_theme()
Other mascot helpers:
mascot_action(),
mascot_anchors(),
mascot_bubble(),
mascot_character(),
mascot_characters(),
mascot_check_character(),
mascot_colour_roles(),
mascot_families(),
mascot_gesture(),
mascot_gestures(),
mascot_mood(),
mascot_moods(),
mascot_motion_settings(),
mascot_palettes(),
mascot_placement(),
mascot_popup_menu(),
mascot_read_character(),
mascot_size(),
mascot_status(),
mascot_theme()
Experimental
Experimental Its purpose, arguments and page layout may change in a later release.
Examples
page <- mascot_preview(mood = "happy", size = 96)
attr(page, "contrast")
#> [1] role colour background ratio mode
#> <0 rows> (or 0-length row.names)
if (FALSE) { # interactive()
mascot_preview()
}
