Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brand yaml logo feature parity: dashboard, revealjs #11446

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/format/reveal/format-reveal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,25 @@ const determineRevealLogo = (format: Format): string | undefined => {
function revealMarkdownAfterBody(format: Format) {
const lines: string[] = [];
lines.push("::: {.quarto-auto-generated-content style='display: none;'}\n");
const revealLogo = (format.metadata[kSlideLogo] as (string | undefined)) ??
determineRevealLogo(format);
let revealLogo = format
.metadata[kSlideLogo] as (string | { path: string } | undefined);
if (revealLogo) {
if (typeof revealLogo === "object") {
revealLogo = revealLogo.path;
}
if (["small", "medium", "large"].includes(revealLogo)) {
const brandData = format.render.brand?.processedData;
const logoInfo = brandData?.logo
?.[revealLogo as ("medium" | "small" | "large")];
if (typeof logoInfo === "string") {
revealLogo = logoInfo;
} else {
revealLogo = logoInfo?.light.path ?? logoInfo?.dark.path;
}
}
} else {
revealLogo = determineRevealLogo(format);
}
if (revealLogo) {
lines.push(
`<img src="${revealLogo}" class="slide-logo" />`,
Expand Down
38 changes: 38 additions & 0 deletions src/resources/filters/quarto-post/dashboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,44 @@ function render_dashboard()
return doc
end
end
}, {
-- todo: dark mode
Meta = function(meta)
local logo = meta.logo
local resolved
if logo then
local which
if pandoc.utils.type(logo) == 'Inlines' then
which = logo[1].text
local brandLogo = _quarto.modules.brand.get_logo(logo[1].text)
resolved = brandLogo and brandLogo.light
elseif type(logo) == 'table' then
local brandLogo = _quarto.modules.brand.get_logo(logo.path[1].text)
if brandLogo then
resolved = brandLogo.light
if logo.alt then
resolved.alt = logo.alt
end
else
resolved = {
path = logo.path,
alt = logo.alt
}
end
end
else
logo = _quarto.modules.brand.get_logo('small')
or _quarto.modules.brand.get_logo('medium')
or _quarto.modules.brand.get_logo('large')
resolved = logo and logo.light
end
if resolved then
meta.logo = resolved.path
meta['logo-alt'] = resolved.alt
end

return meta
end
}
}
end
31 changes: 31 additions & 0 deletions tests/docs/smoke-all/brand/logo/choose-logo-resource.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: brand and base logo
format:
dashboard: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
logo: large
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
31 changes: 31 additions & 0 deletions tests/docs/smoke-all/brand/logo/default-logo.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: brand and base logo
format:
dashboard: default
revealjs: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="quarto\.png" alt="quarto logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="quarto\.png" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
33 changes: 33 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-path-alt.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: brand and base logo
format:
dashboard: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
logo:
path: posit-logo-2024.svg
alt: posit logo
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
32 changes: 32 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-path.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: brand and base logo
format:
dashboard: default
revealjs: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
logo: posit-logo-2024.svg
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" alt=""'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
28 changes: 28 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-resource-alt.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: brand and base logo
format:
dashboard: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
logo:
path: large
alt: logo of posit
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" alt="logo of posit"'
- []
---

{{< lipsum 4 >}}
32 changes: 32 additions & 0 deletions tests/docs/smoke-all/brand/logo/override-logo-resource.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: brand and base logo
format:
dashboard: default
brand:
logo:
images:
quarto:
path: quarto.png
alt: quarto logo
posit:
path: posit-logo-2024.svg
alt: posit logo
medium: quarto
large: posit
logo:
path: large
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" alt="posit logo"'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="posit-logo-2024\.svg" class="slide-logo">'
- []
---

{{< lipsum 4 >}}
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/brand/logo/posit-logo-2024.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/docs/smoke-all/brand/logo/quarto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading