Skip to content

Commit d4efab2

Browse files
do not return undefined colors when splitting brand
fixes #13369
1 parent e4c6439 commit d4efab2

File tree

6 files changed

+87
-18
lines changed

6 files changed

+87
-18
lines changed

news/changelog-1.8.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## In this release
44

5+
- ([#13369](https://github.com/quarto-dev/quarto-cli/issues/13369)): Fix failure in theme compilation when `brand.color.primary` is specified for light or dark but not both.
56
- ([#13383](https://github.com/quarto-dev/quarto-cli/issues/13383)): Fix failure when combining `minimal: true` with brand.yml.
67
- ([#13396](https://github.com/quarto-dev/quarto-cli/issues/13396)): Fix `quarto publish connect` regression.
78
- ([#13418](https://github.com/quarto-dev/quarto-cli/issues/13418)): Resolve logo paths specified directly in `brand.logo.{size}`.

src/core/brand/brand.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -675,42 +675,44 @@ export function splitUnifiedBrand(
675675
? typography.headings
676676
: {
677677
...typography.headings,
678-
color: headingsColor && headingsColor[mode],
678+
...(headingsColor?.[mode] && { color: headingsColor[mode] }),
679679
},
680680
monospace:
681681
!typography.monospace || typeof typography.monospace === "string"
682682
? typography.monospace
683683
: {
684684
...typography.monospace,
685-
color: monospaceColor && monospaceColor[mode],
686-
"background-color": monospaceBackgroundColor &&
687-
monospaceBackgroundColor[mode],
685+
...(monospaceColor?.[mode] && { color: monospaceColor[mode] }),
686+
...(monospaceBackgroundColor?.[mode] &&
687+
{ "background-color": monospaceBackgroundColor[mode] }),
688688
},
689689
"monospace-inline": !typography["monospace-inline"] ||
690690
typeof typography["monospace-inline"] === "string"
691691
? typography["monospace-inline"]
692692
: {
693693
...typography["monospace-inline"],
694-
color: monospaceInlineColor && monospaceInlineColor[mode],
695-
"background-color": monospaceInlineBackgroundColor &&
696-
monospaceInlineBackgroundColor[mode],
694+
...(monospaceInlineColor?.[mode] &&
695+
{ color: monospaceInlineColor[mode] }),
696+
...(monospaceInlineBackgroundColor?.[mode] &&
697+
{ "background-color": monospaceInlineBackgroundColor[mode] }),
697698
},
698699
"monospace-block": !typography["monospace-block"] ||
699700
typeof typography["monospace-block"] === "string"
700701
? typography["monospace-block"]
701702
: {
702703
...typography["monospace-block"],
703-
color: monospaceBlockColor && monospaceBlockColor[mode],
704-
"background-color": monospaceBlockBackgroundColor &&
705-
monospaceBlockBackgroundColor[mode],
704+
...(monospaceBlockColor?.[mode] &&
705+
{ color: monospaceBlockColor[mode] }),
706+
...(monospaceBlockBackgroundColor?.[mode] &&
707+
{ "background-color": monospaceBlockBackgroundColor[mode] }),
706708
},
707709
link: !typography.link || typeof typography.link === "string"
708710
? typography.link
709711
: {
710712
...typography.link,
711-
color: linkColor && linkColor[mode],
712-
"background-color": linkBackgroundColor &&
713-
linkBackgroundColor[mode],
713+
...(linkColor?.[mode] && { color: linkColor[mode] }),
714+
...(linkBackgroundColor?.[mode] &&
715+
{ "background-color": linkBackgroundColor[mode] }),
714716
},
715717
};
716718
const logos = unifiedBrand.logo && splitLogo(unifiedBrand.logo);
@@ -733,10 +735,12 @@ export function splitUnifiedBrand(
733735
if (!unifiedBrand.color[colorName]) {
734736
continue;
735737
}
736-
({
737-
light: lightBrand.color![colorName],
738-
dark: darkBrand.color![colorName],
739-
} = splitColorLightDark(unifiedBrand.color![colorName]));
738+
const { light, dark } = splitColorLightDark(
739+
unifiedBrand.color[colorName],
740+
);
741+
742+
if (light !== undefined) lightBrand.color![colorName] = light;
743+
if (dark !== undefined) darkBrand.color![colorName] = dark;
740744
}
741745
}
742746
return {

src/core/sass/brand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const fileFontImportString = (brand: Brand, description: BrandFontFile) => {
165165
}
166166
parts.push(`@font-face {
167167
font-family: '${description.family}';
168-
src: url('${join(pathPrefix, path).replace(/\\/g, '/')}');
168+
src: url('${join(pathPrefix, path).replace(/\\/g, "/")}');
169169
font-weight: ${weight || "normal"};
170170
font-style: ${style || "normal"};
171171
}\n`);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: primary only
3+
brand:
4+
color:
5+
background:
6+
light: '#f3f3f8'
7+
foreground:
8+
light: '#0f0412'
9+
dark: '#f8f8f8'
10+
_quarto:
11+
tests:
12+
html:
13+
printsMessage:
14+
level: WARN
15+
regex: '"[a-z]*" is not a valid CSS color name'
16+
negate: true
17+
---
18+
19+
---
20+
21+
Here is some text [with a link](https://example.com).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: primary only
3+
brand:
4+
color:
5+
background:
6+
light: '#f3f3f8'
7+
dark: '#0f0412'
8+
foreground:
9+
dark: '#f8f8f8'
10+
_quarto:
11+
tests:
12+
html:
13+
printsMessage:
14+
level: WARN
15+
regex: '"[a-z]*" is not a valid CSS color name'
16+
negate: true
17+
---
18+
19+
---
20+
21+
Here is some text [with a link](https://example.com).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: primary only
3+
brand:
4+
color:
5+
background:
6+
light: '#f3f3f8'
7+
dark: '#0f0412'
8+
foreground:
9+
light: '#113322'
10+
dark: '#f8f8f8'
11+
primary:
12+
dark: '#20bbff'
13+
_quarto:
14+
tests:
15+
html:
16+
printsMessage:
17+
level: WARN
18+
regex: '"[a-z]*" is not a valid CSS color name'
19+
negate: true
20+
---
21+
22+
Here is some text [with a link](https://example.com).

0 commit comments

Comments
 (0)