Skip to content

Commit 7cf8050

Browse files
committed
feat(example-brand): Use brand name and logo in app
1 parent 4af29c0 commit 7cf8050

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

inst/examples-shiny/brand.yml/_brand.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
meta:
22
name:
33
full: "Retro Arcade Brand"
4-
short: "RetroArc"
4+
short: "RetroArc brand.yml demo"
55
link:
66
home: https://retro-arcade.posit.co
77
bluesky: https://bsky.app/profile/posit.co

inst/examples-shiny/brand.yml/app.R

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ if (bslib:::brand_has(brand, "typography", "fonts")) {
6767

6868
ui <- page_navbar(
6969
theme = bs_add_rules(theme_brand, sass::sass_file("_colors.scss")),
70-
title = "brand.yml Demo",
70+
title = tagList(
71+
uiOutput("brand_icon", inline = TRUE),
72+
uiOutput("brand_name", inline = TRUE)
73+
),
74+
window_title = "brand.yml Demo",
7175
fillable = TRUE,
7276

7377
sidebar = sidebar(
@@ -432,6 +436,35 @@ server <- function(input, output, session) {
432436
)
433437
})
434438

439+
output$brand_name <- renderUI({
440+
brand_name <-
441+
bslib:::brand_pluck(brand_yml(), "meta", "name", "short") %||%
442+
bslib:::brand_pluck(brand_yml(), "meta", "name")
443+
444+
if (rlang::is_string(brand_name)) brand_name else "brand.yml Demo"
445+
})
446+
447+
output$brand_icon <- renderUI({
448+
brand <- brand_yml()
449+
450+
logo <-
451+
bslib:::brand_pluck(brand, "logo", "small") %||%
452+
bslib:::brand_pluck(brand, "logo")
453+
454+
req(rlang::is_string(logo))
455+
456+
logo_path <- file.path(dirname(BRAND_PATH), logo)
457+
if (file.exists(logo_path)) {
458+
img(
459+
src = base64enc::dataURI(
460+
file = logo_path,
461+
mime = mime::guess_type(logo_path)
462+
),
463+
height = 30
464+
)
465+
}
466+
})
467+
435468
observeEvent(input$save, {
436469
validate(
437470
need(input$txt_brand_yml, "_brand.yml file contents cannot be empty.")

0 commit comments

Comments
 (0)