Skip to content

Commit 756a0b4

Browse files
claude and gordon: add tests for light and dark logo
Claude got the syntax immediately, but not always the semantics, so I fixed those and we iterated. Claude and came up with many interesting edge cases, some fixed in adjacent commits. "Propose questions and answers, I'll choose the tests." Preserving all "learnings" here. This is not slop, testing light & dark logo is an ideal task for Claude! This commit adds tests for dark/light logo variants in Quarto brand configurations: Key learnings: 1. The dashboard format selects the medium size logo by default, not large 2. Direct path behavior: - Strings without path/alt structure are treated as direct paths - Alt text is empty when using direct path format without alt specification - Named resources and direct paths can be mixed within a configuration 3. Fallback behavior: - When a size is missing a dark variant, it doesn't fall back to its light variant - Instead, it falls back to another size's dark variant (large.dark) - This cross-size fallback behavior may need further specification Tests include: - dark-logo.qmd: Basic light/dark logo configuration - override-dark-logo.qmd: Top-level logo overriding brand.logo - explicit-dark-light-paths.qmd: Direct path specifications - dark-logo-only.qmd: Fallback behavior testing - mixed-logo-path.qmd: Mixed logo definitions (named resources and paths) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> claude: Add comprehensive logo behavior tests This commit adds tests exploring Quarto's logo behavior for dark/light modes: Key learnings: 1. Small is the default logo size for dashboard navbar (not medium) 2. Logo resolution follows a mode-first search algorithm: - Light mode searches small.light → medium.light → large.light - Dark mode searches small.dark → medium.dark → large.dark - It does NOT prioritize staying within same size and switching modes 3. When partial document-level overrides are used (e.g., only light or dark), the non-overridden mode inherits from brand configuration 4. Direct path strings (without .path property) have empty alt text unless explicitly provided via object syntax 5. Document-level logo settings take precedence over brand-level settings Tests include: - document-brand-precedence.qmd: Tests precedence between document and brand logos - partial-document-override.qmd: Tests overriding only one light/dark variant - mixed-specification-formats.qmd: Tests different logo specification formats - cross-size-fallbacks.qmd: Tests fallback behavior when a specific mode is missing - size-inheritance.qmd: Tests the mode-first search algorithm 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> claude: Add logo edge case tests This commit adds tests for edge case logo behaviors: Key learnings: 1. No recursive resolution of logo references is supported - Quarto does not follow chains of references between logo resources 2. Format-specific logo configuration: - Tests format.dashboard.logo taking precedence over document-level and brand logos - Allows format-specific customization while maintaining generic defaults 3. Legacy logo syntax: - A simple string logo value at document level applies to both light and dark modes - Demonstrates backward compatibility with pre-dark-mode syntax 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> claude: Rename logo tests for better clarity Renamed test files to more accurately reflect the behaviors they test: - cross-size-fallbacks.qmd → mode-first-search-algorithm.qmd Tests how light/dark modes independently search through size hierarchy - size-inheritance.qmd → dark-mode-search-priority.qmd Tests dark mode's search priority and lack of fallback to light mode - dark-logo-only.qmd → missing-medium-dark-fallback.qmd Tests specific fallback behavior when medium.dark is missing - mixed-logo-path.qmd → mixed-resource-direct-path.qmd Better describes the mix of resource references and direct paths - mixed-specification-formats.qmd → path-vs-object-specification.qmd Clarifies test comparing string paths vs object specifications with alt text 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> remove pngs it's not necessary to have the files for the tests to run claude: Add sidebar logo tests for size preference and mode-first search This commit adds tests for sidebar logo behavior: 1. Size preference order test (sidebar/size-preference-order) - Tests that sidebar logos follow the preference order: medium → small → large - Verifies that when medium.dark is missing but small.dark and large.dark exist, it correctly selects small.dark due to the preference order 2. Mode-first search algorithm test (sidebar/mode-first-search) - Tests that light/dark modes independently search through all sizes before considering the other mode - Verifies that it searches through all sizes for dark mode before considering any light mode variants These tests confirm that sidebar logo behavior follows the same mode-first search principles as dashboard logos, but with a different size preference order (medium → small → large for sidebars vs medium → large → small for dashboard). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> claude: Add navbar light/dark logo tests This commit adds tests for navbar logo behavior with light/dark variants: 1. Size Preference Test: - Tests navbar size preference order (small → medium → large) - Verifies the mode-first search algorithm in a scenario with no small logos - Confirms medium.light is selected for light mode when small is missing - Confirms large.dark is selected for dark mode when small.dark is missing 2. Alt Text Consistency Test: - Tests that alt text is properly inherited from brand definitions - Confirms that missing resources get empty alt text - Helps ensure accessibility attributes are maintained 3. Missing Logo Handling Test: - Tests behavior when logo paths point to non-existent files - Confirms img tags are generated with correct src attributes - Ensures robust rendering even with missing resources Key learnings: - Navbar DOES NOT support document-level logo overrides unlike sidebars/dashboards - Navbar follows the size preference order: small → medium → large (different from sidebar: medium → small → large and dashboard: medium → large → small) - Mode-first search applies to navbars: it exhaustively searches for a specific mode (light/dark) across all sizes before falling back to other modes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> claude: Add cross-mode logo fallback tests This commit adds tests for how Quarto handles edge cases when logos are missing for one theme mode but both light and dark modes are enabled: 1. dark-mode-no-dark-logo.qmd: Tests what happens when dark mode is enabled but only light logo exists 2. dark-mode-no-light-logo.qmd: Tests what happens when dark mode is enabled but only dark logo exists 3. document-light-brand-light-only.qmd: Tests document-level light-only logo + brand with light-only logo 4. document-dark-brand-dark-only.qmd: Tests document-level dark-only logo + brand with dark-only logo Key learnings: - Quarto implements cross-mode fallbacks where missing logos for one mode automatically use logos from the other mode - Implementation in brand.ts shows the fallback logic applies in both directions: light → dark and dark → light - Document-level logo settings take precedence over brand-level settings - The fallback system ensures logos always appear regardless of which theme mode is active, providing a consistent user experience these tests do not support revealjs default to other mode of logo
1 parent 2880dfe commit 756a0b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+939
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: brand with dark and light logos
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
quarto-dark:
15+
path: quarto-dark.png
16+
alt: quarto dark logo
17+
posit-dark:
18+
path: posit-dark.svg
19+
alt: posit dark logo
20+
medium:
21+
light: quarto
22+
dark: quarto-dark
23+
large:
24+
light: posit
25+
dark: posit-dark
26+
_quarto:
27+
tests:
28+
dashboard:
29+
ensureHtmlElements:
30+
-
31+
- 'img[src="quarto.png"][alt="quarto logo"][class="navbar-logo light-content d-inline-block"]'
32+
- 'img[src="quarto-dark.png"][alt="quarto dark logo"][class="navbar-logo dark-content d-inline-block"]'
33+
- []
34+
---
35+
36+
{{< lipsum 4 >}}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Dark Mode with No Dark Logo
3+
format:
4+
dashboard:
5+
theme:
6+
light: default
7+
dark: darkly # Explicitly enable dark mode
8+
brand:
9+
color:
10+
foreground:
11+
light: '#222'
12+
dark: '#eee'
13+
background:
14+
light: '#eee'
15+
dark: '#222'
16+
logo:
17+
images:
18+
light-logo:
19+
path: quarto.png
20+
alt: light logo
21+
medium:
22+
light: light-logo
23+
# No dark variant defined - what happens?
24+
_quarto:
25+
tests:
26+
dashboard:
27+
ensureHtmlElements:
28+
-
29+
# Light mode should use the light logo
30+
- 'img[src="quarto.png"][alt="light logo"][class="navbar-logo light-content d-inline-block"]'
31+
# For dark mode, should it use the light logo since no dark logo exists?
32+
- 'img[src="quarto.png"][alt="light logo"][class="navbar-logo dark-content d-inline-block"]'
33+
- []
34+
---
35+
36+
{{< lipsum 4 >}}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Dark Mode with No Light Logo
3+
format:
4+
dashboard:
5+
theme:
6+
light: default
7+
dark: darkly # Explicitly enable dark mode
8+
brand:
9+
color:
10+
foreground:
11+
light: '#222'
12+
dark: '#eee'
13+
background:
14+
light: '#eee'
15+
dark: '#222'
16+
logo:
17+
images:
18+
dark-logo:
19+
path: posit-logo-2024.svg
20+
alt: dark logo
21+
medium:
22+
dark: dark-logo
23+
# No light variant defined - what happens?
24+
_quarto:
25+
tests:
26+
dashboard:
27+
ensureHtmlElements:
28+
-
29+
# Dark mode should use the dark logo
30+
- 'img[src="posit-logo-2024.svg"][alt="dark logo"][class="navbar-logo dark-content d-inline-block"]'
31+
# For light mode, should it use the dark logo since no light logo exists?
32+
- 'img[src="posit-logo-2024.svg"][alt="dark logo"][class="navbar-logo light-content d-inline-block"]'
33+
- []
34+
---
35+
36+
{{< lipsum 4 >}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Size Inheritance
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
small-logo:
9+
path: small-logo.png
10+
alt: small logo
11+
medium-logo:
12+
path: medium-logo.png
13+
alt: medium logo
14+
dark-logo:
15+
path: dark-logo.png
16+
alt: dark logo
17+
# Define small and medium with light variants only
18+
small:
19+
light: small-logo
20+
medium:
21+
light: medium-logo
22+
# Define large with dark variant only
23+
large:
24+
dark: dark-logo
25+
_quarto:
26+
tests:
27+
dashboard:
28+
ensureHtmlElements:
29+
-
30+
# Small is default for dashboard navbar
31+
# Light mode: should use small.light
32+
# Dark mode: small and medium.dark are missing, should use large.dark (not any .light)
33+
- 'img[src="small-logo.png"][alt="small logo"][class="navbar-logo light-content d-inline-block"]'
34+
- 'img[src="dark-logo.png"][alt="dark logo"][class="navbar-logo dark-content d-inline-block"]'
35+
- []
36+
---
37+
38+
{{< lipsum 4 >}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Document vs Brand Logo Precedence
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
medium:
15+
light: quarto
16+
dark: quarto
17+
logo:
18+
light: posit-logo-2024.svg
19+
dark: quarto.png
20+
_quarto:
21+
tests:
22+
dashboard:
23+
ensureHtmlElements:
24+
-
25+
# Document-level logo should override brand-level logo
26+
- 'img[src="posit-logo-2024.svg"][alt=""][class="navbar-logo light-content d-inline-block"]'
27+
- 'img[src="quarto.png"][alt=""][class="navbar-logo dark-content d-inline-block"]'
28+
- []
29+
---
30+
31+
{{< lipsum 4 >}}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Document Dark Logo + Brand Dark Logo Only
3+
format:
4+
dashboard:
5+
theme:
6+
light: default
7+
dark: darkly # Explicitly enable dark mode
8+
# Document level logo with only dark defined
9+
logo:
10+
dark: direct-dark-logo.png
11+
brand:
12+
color:
13+
foreground:
14+
light: '#222'
15+
dark: '#eee'
16+
background:
17+
light: '#eee'
18+
dark: '#222'
19+
logo:
20+
images:
21+
brand-dark-logo:
22+
path: posit-logo-2024.svg
23+
alt: brand dark logo
24+
medium:
25+
dark: brand-dark-logo
26+
# No light variant defined in brand
27+
_quarto:
28+
tests:
29+
dashboard:
30+
ensureHtmlElements:
31+
-
32+
# Dark mode should use document-level dark logo (not brand)
33+
- 'img[src="direct-dark-logo.png"][alt=""][class="navbar-logo dark-content d-inline-block"]'
34+
# For light mode, should use same document-level dark logo for fallback
35+
- 'img[src="direct-dark-logo.png"][alt=""][class="navbar-logo light-content d-inline-block"]'
36+
- []
37+
---
38+
39+
{{< lipsum 4 >}}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Document Light Logo + Brand Light Logo Only
3+
format:
4+
dashboard:
5+
theme:
6+
light: default
7+
dark: darkly # Explicitly enable dark mode
8+
# Document level logo with only light defined
9+
logo:
10+
light: direct-light-logo.png
11+
brand:
12+
color:
13+
foreground:
14+
light: '#222'
15+
dark: '#eee'
16+
background:
17+
light: '#eee'
18+
dark: '#222'
19+
logo:
20+
images:
21+
brand-light-logo:
22+
path: quarto.png
23+
alt: brand light logo
24+
medium:
25+
light: brand-light-logo
26+
# No dark variant defined in brand
27+
_quarto:
28+
tests:
29+
dashboard:
30+
ensureHtmlElements:
31+
-
32+
# Light mode should use document-level light logo (not brand)
33+
- 'img[src="direct-light-logo.png"][alt=""][class="navbar-logo light-content d-inline-block"]'
34+
# For dark mode, should use same document-level light logo for fallback
35+
- 'img[src="direct-light-logo.png"][alt=""][class="navbar-logo dark-content d-inline-block"]'
36+
- []
37+
---
38+
39+
{{< lipsum 4 >}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: explicit dark and light logo paths
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
quarto:
9+
path: quarto.png
10+
alt: quarto logo
11+
posit:
12+
path: posit-logo-2024.svg
13+
alt: posit logo
14+
logo:
15+
light:
16+
path: custom-light.png
17+
alt: custom light logo
18+
dark:
19+
path: custom-dark.png
20+
alt: custom dark logo
21+
_quarto:
22+
tests:
23+
dashboard:
24+
ensureHtmlElements:
25+
-
26+
- 'img[src="custom-light.png"][alt="custom light logo"][class="navbar-logo light-content d-inline-block"]'
27+
- 'img[src="custom-dark.png"][alt="custom dark logo"][class="navbar-logo dark-content d-inline-block"]'
28+
- []
29+
---
30+
31+
{{< lipsum 4 >}}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Format-Specific Logo Configuration
3+
format:
4+
dashboard:
5+
logo:
6+
light: dashboard-light.png
7+
dark: dashboard-dark.png
8+
brand:
9+
logo:
10+
images:
11+
light-logo:
12+
path: brand-light.png
13+
alt: brand light logo
14+
dark-logo:
15+
path: brand-dark.png
16+
alt: brand dark logo
17+
small:
18+
light: light-logo
19+
dark: dark-logo
20+
# Generic document-level logo that should be overridden by format-specific
21+
logo:
22+
light: doc-light.png
23+
dark: doc-dark.png
24+
_quarto:
25+
tests:
26+
dashboard:
27+
ensureHtmlElements:
28+
-
29+
# Format-specific logo should take precedence over generic logo
30+
- 'img[src="dashboard-light.png"][alt=""][class="navbar-logo light-content d-inline-block"]'
31+
- 'img[src="dashboard-dark.png"][alt=""][class="navbar-logo dark-content d-inline-block"]'
32+
- []
33+
---
34+
35+
{{< lipsum 4 >}}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Legacy Logo Syntax with Dark/Light Mode
3+
format:
4+
dashboard: default
5+
brand:
6+
logo:
7+
images:
8+
light-logo:
9+
path: light-logo.png
10+
alt: light logo
11+
dark-logo:
12+
path: dark-logo.png
13+
alt: dark logo
14+
small:
15+
light: light-logo
16+
dark: dark-logo
17+
# Using legacy syntax (simple string) for logo
18+
logo: legacy-logo.svg
19+
_quarto:
20+
tests:
21+
dashboard:
22+
ensureHtmlElements:
23+
-
24+
# Legacy syntax should apply to both light and dark modes
25+
- 'img[src="legacy-logo.svg"][alt=""][class="navbar-logo light-content d-inline-block"]'
26+
- 'img[src="legacy-logo.svg"][alt=""][class="navbar-logo dark-content d-inline-block"]'
27+
- []
28+
---
29+
30+
{{< lipsum 4 >}}

0 commit comments

Comments
 (0)