diff --git a/src/core/brand/brand.ts b/src/core/brand/brand.ts index 672bace81e..afeed6a309 100644 --- a/src/core/brand/brand.ts +++ b/src/core/brand/brand.ts @@ -9,6 +9,7 @@ import { Brand as BrandJson, BrandFont, + BrandLogoExplicitResource, BrandNamedLogo, BrandNamedThemeColor, BrandStringLightDark, @@ -16,6 +17,7 @@ import { BrandTypographyOptionsBase, BrandTypographyOptionsHeadings, } from "../../resources/types/schema-types.ts"; +import { InternalError } from "../lib/error.ts"; // we can't programmatically convert typescript types to string arrays, // so we have to define this manually. They should match `BrandNamedThemeColor` in schema-types.ts @@ -32,7 +34,6 @@ export const defaultColorNames: BrandNamedThemeColor[] = [ "danger", "light", "dark", - "emphasis", "link", ]; @@ -42,10 +43,15 @@ const defaultLogoNames: string[] = [ "large", ]; +type CanonicalLogoInfo = { + light: BrandLogoExplicitResource; + dark: BrandLogoExplicitResource; +}; + type ProcessedBrandData = { color: Record; typography: BrandTypography; - logo: Record; + logo: Record; }; export class Brand { @@ -86,18 +92,46 @@ export class Brand { if (link) { typography.link = link; } - const monospace = this.getFont("monospace"); + let monospace = this.getFont("monospace"); + let monospaceInline = this.getFont("monospace-inline"); + let monospaceBlock = this.getFont("monospace-block"); + if (monospace) { + if (typeof monospace === "string") { + monospace = { family: monospace }; + } typography.monospace = monospace; } - const monospaceInline = this.getFont("monospace-inline"); + if (monospaceInline && typeof monospaceInline === "string") { + monospaceInline = { family: monospaceInline }; + } + if (monospaceBlock && typeof monospaceBlock === "string") { + monospaceBlock = { family: monospaceBlock }; + } + + // cut off control flow here so the type checker knows these + // are not strings + if (typeof monospace === "string") { + throw new InternalError("should never happen"); + } + if (typeof monospaceInline === "string") { + throw new InternalError("should never happen"); + } + if (typeof monospaceBlock === "string") { + throw new InternalError("should never happen"); + } + if (monospace || monospaceInline) { typography["monospace-inline"] = { ...(monospace ?? {}), ...(monospaceInline ?? {}), }; } - const monospaceBlock = this.getFont("monospace-block"); + if (monospaceBlock) { + if (typeof monospaceBlock === "string") { + monospaceBlock = { family: monospaceBlock }; + } + } if (monospace || monospaceBlock) { typography["monospace-block"] = { ...(monospace ?? {}), @@ -105,15 +139,18 @@ export class Brand { }; } - const logo: Record = {}; - for (const logoName of Object.keys(data.logo?.images ?? {})) { - logo[logoName] = this.getLogo(logoName); - } - for (const logoName of Object.keys(data.logo ?? {})) { - if (logoName === "images") { - continue; + const logo: Record = {}; + for ( + const size of [ + "small", + "medium", + "large", + ] as ("small" | "medium" | "large")[] + ) { + const v = this.getLogo(size); + if (v) { + logo[size] = v; } - logo[logoName] = this.getLogo(logoName); } return { @@ -195,61 +232,42 @@ export class Brand { return fonts ?? []; } + getLogoResource(name: string): BrandLogoExplicitResource { + const entry = this.data.logo?.images?.[name]; + if (!entry) { + return { path: name }; + } + if (typeof entry === "string") { + return { path: entry }; + } + return entry; + } + // the same implementation as getColor except we can also return {light,dark} // assuming for now that with only contains strings, not {light,dark} - getLogo(name: string): BrandStringLightDark { - const seenValues = new Set(); - do { - if (seenValues.has(name)) { - throw new Error( - `Circular reference in _brand.yml color definitions: ${ - Array.from(seenValues).join( - " -> ", - ) - }`, - ); - } - seenValues.add(name); - if (this.data.logo?.images?.[name]) { - name = this.data.logo.images[name] as string; - } else if ( - defaultLogoNames.includes(name as BrandNamedLogo) && - this.data.logo?.[name as BrandNamedLogo] - ) { - const brandSLD: BrandStringLightDark = this.data - .logo[name as BrandNamedLogo]!; - if (typeof brandSLD == "string") { - name = brandSLD; - } else { - const ret: BrandStringLightDark = {}; - // we need to actually-recurse and not just use the loop - // because two paths light/dark - const light = brandSLD.light; - if (light) { - const brandSLD2 = this.getLogo(light); - if (typeof brandSLD2 == "string") { - ret.light = brandSLD2; - } else { - ret.light = brandSLD2.light; - } - } - const dark = brandSLD.dark; - if (dark) { - const brandSLD2 = this.getLogo(dark); - if (typeof brandSLD2 == "string") { - ret.dark = brandSLD2; - } else { - ret.dark = brandSLD2.light; - } - } - return ret; - } - } else { - return name; - } - } while (seenValues.size < 100); // 100 ought to be enough for anyone, with apologies to Bill Gates - throw new Error( - "Recursion depth exceeded 100 in _brand.yml logo definitions", - ); + getLogo(name: "small" | "medium" | "large"): CanonicalLogoInfo | undefined { + const entry = this.data.logo?.[name]; + if (!entry) { + return undefined; + } + if (typeof entry === "string") { + const res = this.getLogoResource(entry); + return { + light: res, + dark: res, + }; + } + const lightEntry = entry?.light + ? this.getLogoResource(entry.light) + : undefined; + const darkEntry = entry?.dark + ? this.getLogoResource(entry.dark) + : undefined; + if (lightEntry && darkEntry) { + return { + light: lightEntry, + dark: darkEntry, + }; + } } } diff --git a/src/core/sass/brand.ts b/src/core/sass/brand.ts index 34e268d643..59fe9083b1 100644 --- a/src/core/sass/brand.ts +++ b/src/core/sass/brand.ts @@ -285,9 +285,11 @@ const brandTypographyBundle = ( const resolveHTMLFontInformation = ( kind: FontKind, ): HTMLFontInformation | undefined => { - const resolvedFontOptions = brand.data.typography?.[kind]; + let resolvedFontOptions = brand.data.typography?.[kind]; if (!resolvedFontOptions) { return undefined; + } else if (typeof resolvedFontOptions === "string") { + resolvedFontOptions = { family: resolvedFontOptions }; } const family = resolvedFontOptions.family; const font = getFontFamilies(family); diff --git a/src/format/reveal/format-reveal.ts b/src/format/reveal/format-reveal.ts index 8cca8875ee..596ed529f7 100644 --- a/src/format/reveal/format-reveal.ts +++ b/src/format/reveal/format-reveal.ts @@ -335,7 +335,7 @@ const determineRevealLogo = (format: Format): string | undefined => { return logoInfo; } else { // what to do about light vs dark? - return logoInfo.light ?? logoInfo.dark; + return logoInfo?.light.path ?? logoInfo?.dark.path; } } } diff --git a/src/project/types/website/website-shared.ts b/src/project/types/website/website-shared.ts index 6fff5d2196..a5e3bf35ad 100644 --- a/src/project/types/website/website-shared.ts +++ b/src/project/types/website/website-shared.ts @@ -172,10 +172,9 @@ export async function websiteNavigationConfig(project: ProjectContext) { const logo = projectBrand.processedData.logo.medium ?? projectBrand.processedData.logo.small ?? projectBrand.processedData.logo.large; - if (typeof logo === "string") { - sidebars[0].logo = logo; - } else if (typeof logo === "object") { - sidebars[0].logo = logo.light; // TODO: This needs smarts to work on light+dark themes + if (logo) { + sidebars[0].logo = logo.light.path; // TODO: This needs smarts to work on light+dark themes + sidebars[0]["logo-alt"] = logo.light.alt; } } } @@ -186,10 +185,9 @@ export async function websiteNavigationConfig(project: ProjectContext) { const logo = projectBrand.processedData.logo.small ?? projectBrand.processedData.logo.medium ?? projectBrand.processedData.logo.large; - if (typeof logo === "string") { - navbar.logo = logo; - } else if (typeof logo === "object") { - navbar.logo = logo.light; // TODO: This needs smarts to work on light+dark themes + if (logo) { + navbar.logo = logo.light.path; // TODO: This needs smarts to work on light+dark themes + navbar["logo-alt"] = logo.light.alt; } } diff --git a/src/resources/editor/tools/vs-code.mjs b/src/resources/editor/tools/vs-code.mjs index 03199c2964..1f7fdee55b 100644 --- a/src/resources/editor/tools/vs-code.mjs +++ b/src/resources/editor/tools/vs-code.mjs @@ -11879,6 +11879,31 @@ var require_yaml_intelligence_resources = __commonJS({ } ] }, + { + id: "brand-logo-explicit-resource", + object: { + closed: true, + properties: { + path: "path", + alt: { + schema: "string", + description: "Alternative text for the logo, used for accessibility.\n" + } + }, + required: [ + "path" + ] + } + }, + { + id: "brand-logo-resource", + anyOf: [ + "string", + { + ref: "brand-logo-explicit-resource" + } + ] + }, { id: "brand-logo", description: "Provide definitions and defaults for brand's logo in various formats and sizes.\n", @@ -11890,7 +11915,7 @@ var require_yaml_intelligence_resources = __commonJS({ object: { additionalProperties: { schema: { - ref: "brand-string-light-dark" + ref: "brand-logo-resource" } } } @@ -12044,12 +12069,6 @@ var require_yaml_intelligence_resources = __commonJS({ ref: "brand-color-value" } }, - emphasis: { - description: "A color used to emphasize or highlight text or elements.\n", - schema: { - ref: "brand-color-value" - } - }, link: { description: "The color used for hyperlinks. If not defined, the `primary` color is used.\n", schema: { @@ -12086,7 +12105,6 @@ var require_yaml_intelligence_resources = __commonJS({ "danger", "light", "dark", - "emphasis", "link" ] }, @@ -12132,84 +12150,104 @@ var require_yaml_intelligence_resources = __commonJS({ { id: "brand-typography-options-base", description: "Typographic options.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-headings", description: "Typographic options without a font size.", - object: { - closed: true, - properties: { - family: "string", - weight: { - ref: "brand-font-weight" - }, - style: { - ref: "brand-font-style" - }, - color: { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + weight: { + ref: "brand-font-weight" + }, + style: { + ref: "brand-font-style" + }, + color: { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-monospace", description: "Typographic options for monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + } + } } } - } + ] }, { id: "brand-typography-options-monospace-inline", description: "Typographic options for inline monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + } + } } } - } + ] }, { id: "line-height-number-string", @@ -12222,44 +12260,54 @@ var require_yaml_intelligence_resources = __commonJS({ { id: "brand-typography-options-monospace-block", description: "Typographic options for block monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-link", description: "Typographic options for inline monospace elements.", - object: { - closed: true, - properties: { - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" - }, - decoration: "string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + }, + decoration: "string" + } + } } - } + ] }, { id: "brand-named-font", @@ -12282,6 +12330,9 @@ var require_yaml_intelligence_resources = __commonJS({ }, { ref: "brand-font-file" + }, + { + ref: "brand-font-system" } ] }, @@ -12369,6 +12420,23 @@ var require_yaml_intelligence_resources = __commonJS({ } } }, + { + id: "brand-font-system", + description: "A system font definition.", + object: { + super: { + resolveRef: "brand-font-common" + }, + closed: true, + properties: { + source: { + enum: [ + "system" + ] + } + } + } + }, { id: "brand-font-google", description: "A font definition from Google Fonts.", @@ -21664,6 +21732,7 @@ var require_yaml_intelligence_resources = __commonJS({ "The brand\u2019s Facebook URL.", "A link or path to the brand\u2019s light-colored logo or icon.", "A link or path to the brand\u2019s dark-colored logo or icon.", + "Alternative text for the logo, used for accessibility.", "Provide definitions and defaults for brand\u2019s logo in various formats\nand sizes.", "A link or path to the brand\u2019s small-sized logo or icon, or a link or\npath to both the light and dark versions.", "A link or path to the brand\u2019s medium-sized logo, or a link or path to\nboth the light and dark versions.", @@ -21687,7 +21756,6 @@ var require_yaml_intelligence_resources = __commonJS({ "The color used for errors, dangerous actions, or negative\ninformation.", "A bright color, used as a high-contrast foreground color on dark\nelements or low-contrast background color on light elements.", "A dark color, used as a high-contrast foreground color on light\nelements or high-contrast background color on light elements.", - "A color used to emphasize or highlight text or elements.", "The color used for hyperlinks. If not defined, the\nprimary color is used.", "A color, which may be a named brand color.", "A named brand color, taken either from color.theme or\ncolor.palette (in that order).", @@ -21714,6 +21782,11 @@ var require_yaml_intelligence_resources = __commonJS({ "The font weights to include.", "The font styles to include.", "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", + "A system font definition.", + "The font family name, which must match the name of the font on the\nfoundry website.", + "The font weights to include.", + "The font styles to include.", + "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", "A font definition from Google Fonts.", "The font family name, which must match the name of the font on the\nfoundry website.", "The font weights to include.", @@ -23782,7 +23855,8 @@ var require_yaml_intelligence_resources = __commonJS({ }, "Disambiguating year suffix in author-date styles (e.g. \u201Ca\u201D in \u201CDoe,\n1999a\u201D).", "Manuscript configuration", - "internal-schema-hack" + "internal-schema-hack", + "Alternative text for the logo, used for accessibility." ], "schema/external-schemas.yml": [ { @@ -24011,12 +24085,12 @@ var require_yaml_intelligence_resources = __commonJS({ mermaid: "%%" }, "handlers/mermaid/schema.yml": { - _internalId: 190350, + _internalId: 190453, type: "object", description: "be an object", properties: { "mermaid-format": { - _internalId: 190342, + _internalId: 190445, type: "enum", enum: [ "png", @@ -24032,7 +24106,7 @@ var require_yaml_intelligence_resources = __commonJS({ exhaustiveCompletions: true }, theme: { - _internalId: 190349, + _internalId: 190452, type: "anyOf", anyOf: [ { diff --git a/src/resources/editor/tools/yaml/web-worker.js b/src/resources/editor/tools/yaml/web-worker.js index 83170a9d09..86fac6c2a7 100644 --- a/src/resources/editor/tools/yaml/web-worker.js +++ b/src/resources/editor/tools/yaml/web-worker.js @@ -11880,6 +11880,31 @@ try { } ] }, + { + id: "brand-logo-explicit-resource", + object: { + closed: true, + properties: { + path: "path", + alt: { + schema: "string", + description: "Alternative text for the logo, used for accessibility.\n" + } + }, + required: [ + "path" + ] + } + }, + { + id: "brand-logo-resource", + anyOf: [ + "string", + { + ref: "brand-logo-explicit-resource" + } + ] + }, { id: "brand-logo", description: "Provide definitions and defaults for brand's logo in various formats and sizes.\n", @@ -11891,7 +11916,7 @@ try { object: { additionalProperties: { schema: { - ref: "brand-string-light-dark" + ref: "brand-logo-resource" } } } @@ -12045,12 +12070,6 @@ try { ref: "brand-color-value" } }, - emphasis: { - description: "A color used to emphasize or highlight text or elements.\n", - schema: { - ref: "brand-color-value" - } - }, link: { description: "The color used for hyperlinks. If not defined, the `primary` color is used.\n", schema: { @@ -12087,7 +12106,6 @@ try { "danger", "light", "dark", - "emphasis", "link" ] }, @@ -12133,84 +12151,104 @@ try { { id: "brand-typography-options-base", description: "Typographic options.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-headings", description: "Typographic options without a font size.", - object: { - closed: true, - properties: { - family: "string", - weight: { - ref: "brand-font-weight" - }, - style: { - ref: "brand-font-style" - }, - color: { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + weight: { + ref: "brand-font-weight" + }, + style: { + ref: "brand-font-style" + }, + color: { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-monospace", description: "Typographic options for monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + } + } } } - } + ] }, { id: "brand-typography-options-monospace-inline", description: "Typographic options for inline monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + } + } } } - } + ] }, { id: "line-height-number-string", @@ -12223,44 +12261,54 @@ try { { id: "brand-typography-options-monospace-block", description: "Typographic options for block monospace elements.", - object: { - closed: true, - properties: { - family: "string", - size: "string", - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" - }, - "line-height": { - ref: "line-height-number-string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + family: "string", + size: "string", + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + }, + "line-height": { + ref: "line-height-number-string" + } + } } } - } + ] }, { id: "brand-typography-options-link", description: "Typographic options for inline monospace elements.", - object: { - closed: true, - properties: { - weight: { - ref: "brand-font-weight" - }, - color: { - ref: "brand-maybe-named-color" - }, - "background-color": { - ref: "brand-maybe-named-color" - }, - decoration: "string" + anyOf: [ + "string", + { + object: { + closed: true, + properties: { + weight: { + ref: "brand-font-weight" + }, + color: { + ref: "brand-maybe-named-color" + }, + "background-color": { + ref: "brand-maybe-named-color" + }, + decoration: "string" + } + } } - } + ] }, { id: "brand-named-font", @@ -12283,6 +12331,9 @@ try { }, { ref: "brand-font-file" + }, + { + ref: "brand-font-system" } ] }, @@ -12370,6 +12421,23 @@ try { } } }, + { + id: "brand-font-system", + description: "A system font definition.", + object: { + super: { + resolveRef: "brand-font-common" + }, + closed: true, + properties: { + source: { + enum: [ + "system" + ] + } + } + } + }, { id: "brand-font-google", description: "A font definition from Google Fonts.", @@ -21665,6 +21733,7 @@ try { "The brand\u2019s Facebook URL.", "A link or path to the brand\u2019s light-colored logo or icon.", "A link or path to the brand\u2019s dark-colored logo or icon.", + "Alternative text for the logo, used for accessibility.", "Provide definitions and defaults for brand\u2019s logo in various formats\nand sizes.", "A link or path to the brand\u2019s small-sized logo or icon, or a link or\npath to both the light and dark versions.", "A link or path to the brand\u2019s medium-sized logo, or a link or path to\nboth the light and dark versions.", @@ -21688,7 +21757,6 @@ try { "The color used for errors, dangerous actions, or negative\ninformation.", "A bright color, used as a high-contrast foreground color on dark\nelements or low-contrast background color on light elements.", "A dark color, used as a high-contrast foreground color on light\nelements or high-contrast background color on light elements.", - "A color used to emphasize or highlight text or elements.", "The color used for hyperlinks. If not defined, the\nprimary color is used.", "A color, which may be a named brand color.", "A named brand color, taken either from color.theme or\ncolor.palette (in that order).", @@ -21715,6 +21783,11 @@ try { "The font weights to include.", "The font styles to include.", "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", + "A system font definition.", + "The font family name, which must match the name of the font on the\nfoundry website.", + "The font weights to include.", + "The font styles to include.", + "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", "A font definition from Google Fonts.", "The font family name, which must match the name of the font on the\nfoundry website.", "The font weights to include.", @@ -23783,7 +23856,8 @@ try { }, "Disambiguating year suffix in author-date styles (e.g. \u201Ca\u201D in \u201CDoe,\n1999a\u201D).", "Manuscript configuration", - "internal-schema-hack" + "internal-schema-hack", + "Alternative text for the logo, used for accessibility." ], "schema/external-schemas.yml": [ { @@ -24012,12 +24086,12 @@ try { mermaid: "%%" }, "handlers/mermaid/schema.yml": { - _internalId: 190350, + _internalId: 190453, type: "object", description: "be an object", properties: { "mermaid-format": { - _internalId: 190342, + _internalId: 190445, type: "enum", enum: [ "png", @@ -24033,7 +24107,7 @@ try { exhaustiveCompletions: true }, theme: { - _internalId: 190349, + _internalId: 190452, type: "anyOf", anyOf: [ { diff --git a/src/resources/editor/tools/yaml/yaml-intelligence-resources.json b/src/resources/editor/tools/yaml/yaml-intelligence-resources.json index b8c8001474..c6a710059a 100644 --- a/src/resources/editor/tools/yaml/yaml-intelligence-resources.json +++ b/src/resources/editor/tools/yaml/yaml-intelligence-resources.json @@ -4851,6 +4851,31 @@ } ] }, + { + "id": "brand-logo-explicit-resource", + "object": { + "closed": true, + "properties": { + "path": "path", + "alt": { + "schema": "string", + "description": "Alternative text for the logo, used for accessibility.\n" + } + }, + "required": [ + "path" + ] + } + }, + { + "id": "brand-logo-resource", + "anyOf": [ + "string", + { + "ref": "brand-logo-explicit-resource" + } + ] + }, { "id": "brand-logo", "description": "Provide definitions and defaults for brand's logo in various formats and sizes.\n", @@ -4862,7 +4887,7 @@ "object": { "additionalProperties": { "schema": { - "ref": "brand-string-light-dark" + "ref": "brand-logo-resource" } } } @@ -5016,12 +5041,6 @@ "ref": "brand-color-value" } }, - "emphasis": { - "description": "A color used to emphasize or highlight text or elements.\n", - "schema": { - "ref": "brand-color-value" - } - }, "link": { "description": "The color used for hyperlinks. If not defined, the `primary` color is used.\n", "schema": { @@ -5058,7 +5077,6 @@ "danger", "light", "dark", - "emphasis", "link" ] }, @@ -5104,84 +5122,104 @@ { "id": "brand-typography-options-base", "description": "Typographic options.", - "object": { - "closed": true, - "properties": { - "family": "string", - "size": "string", - "weight": { - "ref": "brand-font-weight" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "line-height": { - "ref": "line-height-number-string" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "family": "string", + "size": "string", + "weight": { + "ref": "brand-font-weight" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "line-height": { + "ref": "line-height-number-string" + } + } } } - } + ] }, { "id": "brand-typography-options-headings", "description": "Typographic options without a font size.", - "object": { - "closed": true, - "properties": { - "family": "string", - "weight": { - "ref": "brand-font-weight" - }, - "style": { - "ref": "brand-font-style" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "line-height": { - "ref": "line-height-number-string" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "family": "string", + "weight": { + "ref": "brand-font-weight" + }, + "style": { + "ref": "brand-font-style" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "line-height": { + "ref": "line-height-number-string" + } + } } } - } + ] }, { "id": "brand-typography-options-monospace", "description": "Typographic options for monospace elements.", - "object": { - "closed": true, - "properties": { - "family": "string", - "size": "string", - "weight": { - "ref": "brand-font-weight" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "background-color": { - "ref": "brand-maybe-named-color" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "family": "string", + "size": "string", + "weight": { + "ref": "brand-font-weight" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "background-color": { + "ref": "brand-maybe-named-color" + } + } } } - } + ] }, { "id": "brand-typography-options-monospace-inline", "description": "Typographic options for inline monospace elements.", - "object": { - "closed": true, - "properties": { - "family": "string", - "size": "string", - "weight": { - "ref": "brand-font-weight" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "background-color": { - "ref": "brand-maybe-named-color" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "family": "string", + "size": "string", + "weight": { + "ref": "brand-font-weight" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "background-color": { + "ref": "brand-maybe-named-color" + } + } } } - } + ] }, { "id": "line-height-number-string", @@ -5194,44 +5232,54 @@ { "id": "brand-typography-options-monospace-block", "description": "Typographic options for block monospace elements.", - "object": { - "closed": true, - "properties": { - "family": "string", - "size": "string", - "weight": { - "ref": "brand-font-weight" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "background-color": { - "ref": "brand-maybe-named-color" - }, - "line-height": { - "ref": "line-height-number-string" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "family": "string", + "size": "string", + "weight": { + "ref": "brand-font-weight" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "background-color": { + "ref": "brand-maybe-named-color" + }, + "line-height": { + "ref": "line-height-number-string" + } + } } } - } + ] }, { "id": "brand-typography-options-link", "description": "Typographic options for inline monospace elements.", - "object": { - "closed": true, - "properties": { - "weight": { - "ref": "brand-font-weight" - }, - "color": { - "ref": "brand-maybe-named-color" - }, - "background-color": { - "ref": "brand-maybe-named-color" - }, - "decoration": "string" + "anyOf": [ + "string", + { + "object": { + "closed": true, + "properties": { + "weight": { + "ref": "brand-font-weight" + }, + "color": { + "ref": "brand-maybe-named-color" + }, + "background-color": { + "ref": "brand-maybe-named-color" + }, + "decoration": "string" + } + } } - } + ] }, { "id": "brand-named-font", @@ -5254,6 +5302,9 @@ }, { "ref": "brand-font-file" + }, + { + "ref": "brand-font-system" } ] }, @@ -5341,6 +5392,23 @@ } } }, + { + "id": "brand-font-system", + "description": "A system font definition.", + "object": { + "super": { + "resolveRef": "brand-font-common" + }, + "closed": true, + "properties": { + "source": { + "enum": [ + "system" + ] + } + } + } + }, { "id": "brand-font-google", "description": "A font definition from Google Fonts.", @@ -14636,6 +14704,7 @@ "The brand’s Facebook URL.", "A link or path to the brand’s light-colored logo or icon.", "A link or path to the brand’s dark-colored logo or icon.", + "Alternative text for the logo, used for accessibility.", "Provide definitions and defaults for brand’s logo in various formats\nand sizes.", "A link or path to the brand’s small-sized logo or icon, or a link or\npath to both the light and dark versions.", "A link or path to the brand’s medium-sized logo, or a link or path to\nboth the light and dark versions.", @@ -14659,7 +14728,6 @@ "The color used for errors, dangerous actions, or negative\ninformation.", "A bright color, used as a high-contrast foreground color on dark\nelements or low-contrast background color on light elements.", "A dark color, used as a high-contrast foreground color on light\nelements or high-contrast background color on light elements.", - "A color used to emphasize or highlight text or elements.", "The color used for hyperlinks. If not defined, the\nprimary color is used.", "A color, which may be a named brand color.", "A named brand color, taken either from color.theme or\ncolor.palette (in that order).", @@ -14686,6 +14754,11 @@ "The font weights to include.", "The font styles to include.", "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", + "A system font definition.", + "The font family name, which must match the name of the font on the\nfoundry website.", + "The font weights to include.", + "The font styles to include.", + "The font display method, determines how a font face is font face is\nshown depending on its download status and readiness for use.", "A font definition from Google Fonts.", "The font family name, which must match the name of the font on the\nfoundry website.", "The font weights to include.", @@ -16754,7 +16827,8 @@ }, "Disambiguating year suffix in author-date styles (e.g. “a” in “Doe,\n1999a”).", "Manuscript configuration", - "internal-schema-hack" + "internal-schema-hack", + "Alternative text for the logo, used for accessibility." ], "schema/external-schemas.yml": [ { @@ -16983,12 +17057,12 @@ "mermaid": "%%" }, "handlers/mermaid/schema.yml": { - "_internalId": 190350, + "_internalId": 190453, "type": "object", "description": "be an object", "properties": { "mermaid-format": { - "_internalId": 190342, + "_internalId": 190445, "type": "enum", "enum": [ "png", @@ -17004,7 +17078,7 @@ "exhaustiveCompletions": true }, "theme": { - "_internalId": 190349, + "_internalId": 190452, "type": "anyOf", "anyOf": [ { diff --git a/src/resources/filters/modules/brand/brand.lua b/src/resources/filters/modules/brand/brand.lua index f46a597974..83109abed9 100644 --- a/src/resources/filters/modules/brand/brand.lua +++ b/src/resources/filters/modules/brand/brand.lua @@ -56,7 +56,6 @@ local function get_logo(name) local brand = param("brand") brand = brand and brand.processedData -- from src/core/brand/brand.ts if not brand then return nil end - -- todo convert logo options from CSS to Typst return brand.logo and brand.logo[name] end diff --git a/src/resources/filters/quarto-post/typst-brand-yaml.lua b/src/resources/filters/quarto-post/typst-brand-yaml.lua index 794358ec6f..52b6176403 100644 --- a/src/resources/filters/quarto-post/typst-brand-yaml.lua +++ b/src/resources/filters/quarto-post/typst-brand-yaml.lua @@ -216,44 +216,42 @@ function render_typst_brand_yaml() -- logo local logo = param('logo') local logoOptions = {} - local foundSrc = null + local foundLogo = null if logo then if type(logo) == 'string' then - foundSrc = _quarto.modules.brand.get_logo(logo) or logo + foundLogo = _quarto.modules.brand.get_logo(logo) or {light={path=logo}} elseif type(logo) == 'table' then for k, v in pairs(logo) do logoOptions[k] = v end - if logo.src then - foundSrc = _quarto.modules.brand.get_logo(logo.src) or logo.src + if logo.path then + foundLogo = _quarto.modules.brand.get_logo(logo.path) or {light={path=logo}} end end end - if not foundSrc and brand.processedData.logo then + if not foundLogo and brand.processedData.logo then local tries = {'large', 'small', 'medium'} -- low to high priority - for _, try in ipairs(tries) do - local src = _quarto.modules.brand.get_logo(try) - if src then - foundSrc = src - end - end + foundLogo = _quarto.modules.brand.get_logo('medium') + or _quarto.modules.brand.get_logo('small') + or _quarto.modules.brand.get_logo('large') end - if foundSrc then - if type(foundSrc) == "string" then - logoOptions.src = foundSrc - elseif foundSrc.light then - logoOptions.src = foundSrc.light - elseif foundSrc.dark then - logoOptions.src = foundSrc.dark + if foundLogo then + if foundLogo.light then + logoOptions.path = foundLogo.light.path + logoOptions.alt = foundLogo.light.alt + elseif foundLogo.dark then + logoOptions.path = foundLogo.dark.path + logoOptions.alt = foundLogo.dark.alt end - -- todo: resolve logoOptions.src path + -- todo: path relative to brand.yaml logoOptions.padding = _quarto.modules.typst.css.translate_length(logoOptions.padding or '0.5in') logoOptions.width = _quarto.modules.typst.css.translate_length(logoOptions.width or '2in') logoOptions.location = logoOptions.location and location_to_typst_align(logoOptions.location) or 'left+top' quarto.log.debug('logo options', logoOptions) + local altProp = logoOptions.alt and (', alt: "' .. logoOptions.alt .. '"') or '' quarto.doc.include_text('in-header', - '#set page(background: align(' .. logoOptions.location .. ', box(inset: ' .. logoOptions.padding .. ', image("' .. logoOptions.src .. '", width: ' .. logoOptions.width .. '))))') + '#set page(background: align(' .. logoOptions.location .. ', box(inset: ' .. logoOptions.padding .. ', image("' .. logoOptions.path .. '", width: ' .. logoOptions.width .. altProp .. '))))') end end end, diff --git a/src/resources/schema/definitions.yml b/src/resources/schema/definitions.yml index a194826135..fa5705b408 100644 --- a/src/resources/schema/definitions.yml +++ b/src/resources/schema/definitions.yml @@ -2515,6 +2515,22 @@ description: > A link or path to the brand's dark-colored logo or icon. +- id: brand-logo-explicit-resource + object: + closed: true + properties: + path: path + alt: + schema: string + description: > + Alternative text for the logo, used for accessibility. + required: [path] + +- id: brand-logo-resource + anyOf: + - string + - ref: brand-logo-explicit-resource + - id: brand-logo description: > Provide definitions and defaults for brand's logo in various formats and sizes. @@ -2525,8 +2541,7 @@ schema: object: additionalProperties: - schema: - ref: brand-string-light-dark + schema: { ref: brand-logo-resource } small: description: > A link or path to the brand's small-sized logo or icon, or a link or path @@ -2646,11 +2661,6 @@ or high-contrast background color on light elements. schema: ref: brand-color-value - emphasis: - description: > - A color used to emphasize or highlight text or elements. - schema: - ref: brand-color-value link: description: > The color used for hyperlinks. If not defined, the `primary` color is used. @@ -2680,7 +2690,6 @@ danger, light, dark, - emphasis, link, ] @@ -2718,60 +2727,68 @@ - id: brand-typography-options-base description: Typographic options. - object: - closed: true - properties: - family: string - size: string - weight: - ref: brand-font-weight - color: - ref: brand-maybe-named-color - line-height: - ref: line-height-number-string + anyOf: + - string + - object: + closed: true + properties: + family: string + size: string + weight: + ref: brand-font-weight + color: + ref: brand-maybe-named-color + line-height: + ref: line-height-number-string - id: brand-typography-options-headings description: Typographic options without a font size. - object: - closed: true - properties: - family: string - weight: - ref: brand-font-weight - style: - ref: brand-font-style - color: - ref: brand-maybe-named-color - line-height: - ref: line-height-number-string + anyOf: + - string + - object: + closed: true + properties: + family: string + weight: + ref: brand-font-weight + style: + ref: brand-font-style + color: + ref: brand-maybe-named-color + line-height: + ref: line-height-number-string - id: brand-typography-options-monospace description: Typographic options for monospace elements. - object: - closed: true - properties: - family: string - size: string - weight: - ref: brand-font-weight - color: - ref: brand-maybe-named-color - background-color: - ref: brand-maybe-named-color + anyOf: + - string + - object: + closed: true + properties: + family: string + size: string + weight: + ref: brand-font-weight + color: + ref: brand-maybe-named-color + background-color: + ref: brand-maybe-named-color - id: brand-typography-options-monospace-inline description: Typographic options for inline monospace elements. - object: - closed: true - properties: - family: string - size: string - weight: - ref: brand-font-weight - color: - ref: brand-maybe-named-color - background-color: - ref: brand-maybe-named-color + anyOf: + - string + - object: + closed: true + properties: + family: string + size: string + weight: + ref: brand-font-weight + color: + ref: brand-maybe-named-color + background-color: + ref: brand-maybe-named-color - id: line-height-number-string description: Line height @@ -2779,32 +2796,36 @@ - id: brand-typography-options-monospace-block description: Typographic options for block monospace elements. - object: - closed: true - properties: - family: string - size: string - weight: - ref: brand-font-weight - color: - ref: brand-maybe-named-color - background-color: - ref: brand-maybe-named-color - line-height: - ref: line-height-number-string + anyOf: + - string + - object: + closed: true + properties: + family: string + size: string + weight: + ref: brand-font-weight + color: + ref: brand-maybe-named-color + background-color: + ref: brand-maybe-named-color + line-height: + ref: line-height-number-string - id: brand-typography-options-link description: Typographic options for inline monospace elements. - object: - closed: true - properties: - weight: - ref: brand-font-weight - color: - ref: brand-maybe-named-color - background-color: - ref: brand-maybe-named-color - decoration: string + anyOf: + - string + - object: + closed: true + properties: + weight: + ref: brand-font-weight + color: + ref: brand-maybe-named-color + background-color: + ref: brand-maybe-named-color + decoration: string - id: brand-named-font description: Names of customizeable fonts @@ -2816,7 +2837,7 @@ - ref: brand-font-google - ref: brand-font-bunny - ref: brand-font-file - # - ref: brand-font-family + - ref: brand-font-system - id: brand-font-weight description: A font weight. @@ -2877,6 +2898,16 @@ enum: [auto, block, swap, fallback, optional] default: swap +- id: brand-font-system + description: A system font definition. + object: + super: + resolveRef: brand-font-common + closed: true + properties: + source: + enum: [system] + - id: brand-font-google description: A font definition from Google Fonts. object: diff --git a/src/resources/schema/json-schemas.json b/src/resources/schema/json-schemas.json index 735f56ae50..7c895d22d8 100644 --- a/src/resources/schema/json-schemas.json +++ b/src/resources/schema/json-schemas.json @@ -3243,6 +3243,28 @@ } ] }, + "BrandLogoExplicitResource": { + "object": { + "properties": { + "path": { + "type": "string" + }, + "alt": { + "type": "string" + } + } + } + }, + "BrandLogoResource": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/$defs/BrandLogoExplicitResource" + } + ] + }, "BrandLogo": { "object": { "properties": { @@ -3339,9 +3361,6 @@ "dark": { "$ref": "#/$defs/BrandColorValue" }, - "emphasis": { - "$ref": "#/$defs/BrandColorValue" - }, "link": { "$ref": "#/$defs/BrandColorValue" } @@ -3371,7 +3390,6 @@ "danger", "light", "dark", - "emphasis", "link" ] }, @@ -3406,88 +3424,116 @@ } }, "BrandTypographyOptionsBase": { - "object": { - "properties": { - "family": { - "type": "string" - }, - "size": { - "type": "string" - }, - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "line-height": { - "$ref": "#/$defs/LineHeightNumberString" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "family": { + "type": "string" + }, + "size": { + "type": "string" + }, + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "line-height": { + "$ref": "#/$defs/LineHeightNumberString" + } + } } } - } + ] }, "BrandTypographyOptionsHeadings": { - "object": { - "properties": { - "family": { - "type": "string" - }, - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "style": { - "$ref": "#/$defs/BrandFontStyle" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "line-height": { - "$ref": "#/$defs/LineHeightNumberString" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "family": { + "type": "string" + }, + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "style": { + "$ref": "#/$defs/BrandFontStyle" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "line-height": { + "$ref": "#/$defs/LineHeightNumberString" + } + } } } - } + ] }, "BrandTypographyOptionsMonospace": { - "object": { - "properties": { - "family": { - "type": "string" - }, - "size": { - "type": "string" - }, - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "background-color": { - "$ref": "#/$defs/BrandMaybeNamedColor" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "family": { + "type": "string" + }, + "size": { + "type": "string" + }, + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "background-color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + } + } } } - } + ] }, "BrandTypographyOptionsMonospaceInline": { - "object": { - "properties": { - "family": { - "type": "string" - }, - "size": { - "type": "string" - }, - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "background-color": { - "$ref": "#/$defs/BrandMaybeNamedColor" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "family": { + "type": "string" + }, + "size": { + "type": "string" + }, + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "background-color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + } + } } } - } + ] }, "LineHeightNumberString": { "anyOf": [ @@ -3500,46 +3546,60 @@ ] }, "BrandTypographyOptionsMonospaceBlock": { - "object": { - "properties": { - "family": { - "type": "string" - }, - "size": { - "type": "string" - }, - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "background-color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "line-height": { - "$ref": "#/$defs/LineHeightNumberString" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "family": { + "type": "string" + }, + "size": { + "type": "string" + }, + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "background-color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "line-height": { + "$ref": "#/$defs/LineHeightNumberString" + } + } } } - } + ] }, "BrandTypographyOptionsLink": { - "object": { - "properties": { - "weight": { - "$ref": "#/$defs/BrandFontWeight" - }, - "color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "background-color": { - "$ref": "#/$defs/BrandMaybeNamedColor" - }, - "decoration": { - "type": "string" + "anyOf": [ + { + "type": "string" + }, + { + "object": { + "properties": { + "weight": { + "$ref": "#/$defs/BrandFontWeight" + }, + "color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "background-color": { + "$ref": "#/$defs/BrandMaybeNamedColor" + }, + "decoration": { + "type": "string" + } + } } } - } + ] }, "BrandNamedFont": { "enum": [ @@ -3558,6 +3618,9 @@ }, { "$ref": "#/$defs/BrandFontFile" + }, + { + "$ref": "#/$defs/BrandFontSystem" } ] }, @@ -3638,6 +3701,17 @@ } } }, + "BrandFontSystem": { + "object": { + "properties": { + "source": { + "enum": [ + "system" + ] + } + } + } + }, "BrandFontGoogle": { "object": { "properties": { diff --git a/src/resources/types/schema-types.ts b/src/resources/types/schema-types.ts index a89436c87d..4c215554df 100644 --- a/src/resources/types/schema-types.ts +++ b/src/resources/types/schema-types.ts @@ -1283,8 +1283,12 @@ export type BrandMeta = { export type BrandStringLightDark = string | { dark?: string; light?: string }; +export type BrandLogoExplicitResource = { alt?: string; path: string }; + +export type BrandLogoResource = string | BrandLogoExplicitResource; + export type BrandLogo = { - images?: { [key: string]: BrandStringLightDark }; + images?: { [key: string]: BrandLogoResource }; large?: BrandStringLightDark; medium?: BrandStringLightDark; small?: BrandStringLightDark; @@ -1308,7 +1312,6 @@ export type BrandColor = { background?: BrandColorValue; danger?: BrandColorValue; dark?: BrandColorValue; - emphasis?: BrandColorValue; foreground?: BrandColorValue; info?: BrandColorValue; light?: BrandColorValue; @@ -1339,7 +1342,6 @@ export type BrandNamedThemeColor = | "danger" | "light" | "dark" - | "emphasis" | "link"; /* A named brand color, taken either from `color.theme` or `color.palette` (in that order). */ export type BrandTypography = { @@ -1352,7 +1354,7 @@ export type BrandTypography = { monospace?: BrandTypographyOptionsMonospace; }; /* Typography definitions for the brand. */ -export type BrandTypographyOptionsBase = { +export type BrandTypographyOptionsBase = string | { "line-height"?: LineHeightNumberString; color?: BrandMaybeNamedColor; family?: string; @@ -1360,7 +1362,7 @@ export type BrandTypographyOptionsBase = { weight?: BrandFontWeight; }; /* Typographic options. */ -export type BrandTypographyOptionsHeadings = { +export type BrandTypographyOptionsHeadings = string | { "line-height"?: LineHeightNumberString; color?: BrandMaybeNamedColor; family?: string; @@ -1368,7 +1370,7 @@ export type BrandTypographyOptionsHeadings = { weight?: BrandFontWeight; }; /* Typographic options without a font size. */ -export type BrandTypographyOptionsMonospace = { +export type BrandTypographyOptionsMonospace = string | { "background-color"?: BrandMaybeNamedColor; color?: BrandMaybeNamedColor; family?: string; @@ -1376,7 +1378,7 @@ export type BrandTypographyOptionsMonospace = { weight?: BrandFontWeight; }; /* Typographic options for monospace elements. */ -export type BrandTypographyOptionsMonospaceInline = { +export type BrandTypographyOptionsMonospaceInline = string | { "background-color"?: BrandMaybeNamedColor; color?: BrandMaybeNamedColor; family?: string; @@ -1386,7 +1388,7 @@ export type BrandTypographyOptionsMonospaceInline = { export type LineHeightNumberString = number | string; /* Line height */ -export type BrandTypographyOptionsMonospaceBlock = { +export type BrandTypographyOptionsMonospaceBlock = string | { "background-color"?: BrandMaybeNamedColor; "line-height"?: LineHeightNumberString; color?: BrandMaybeNamedColor; @@ -1395,7 +1397,7 @@ export type BrandTypographyOptionsMonospaceBlock = { weight?: BrandFontWeight; }; /* Typographic options for block monospace elements. */ -export type BrandTypographyOptionsLink = { +export type BrandTypographyOptionsLink = string | { "background-color"?: BrandMaybeNamedColor; color?: BrandMaybeNamedColor; decoration?: string; @@ -1410,7 +1412,8 @@ export type BrandNamedFont = export type BrandFont = | BrandFontGoogle | BrandFontBunny - | BrandFontFile; /* Font files and definitions for the brand. */ + | BrandFontFile + | BrandFontSystem; /* Font files and definitions for the brand. */ export type BrandFontWeight = | 100 @@ -1453,6 +1456,10 @@ export type BrandFontCommon = { weight?: MaybeArrayOf; /* The font weights to include. */ }; +export type BrandFontSystem = + & { source?: "system" } + & BrandFontCommon; /* A system font definition. */ + export type BrandFontGoogle = & { source?: "google" } & BrandFontCommon; /* A font definition from Google Fonts. */ diff --git a/tests/docs/smoke-all/typst/brand-yaml/logo/posit/_brand.yml b/tests/docs/smoke-all/typst/brand-yaml/logo/posit/_brand.yml index 2f88d5e56d..f7b1ca8516 100644 --- a/tests/docs/smoke-all/typst/brand-yaml/logo/posit/_brand.yml +++ b/tests/docs/smoke-all/typst/brand-yaml/logo/posit/_brand.yml @@ -1,12 +1,10 @@ logo: images: + posit-logo-light-medium: + path: posit-logo-2024.svg + alt: Posit Logo brand-typst-with-good-padding: good-padding.png - - small: posit-icon.png - medium: - light: posit-logo-2024.svg - dark: posit-reverse.png - large: posit-logo-2024.svg + medium: posit-logo-light-medium defaults: quarto: format: diff --git a/tests/docs/smoke-all/typst/brand-yaml/logo/posit/brand-logo.qmd b/tests/docs/smoke-all/typst/brand-yaml/logo/posit/brand-logo.qmd index 481853c914..01ee6823db 100644 --- a/tests/docs/smoke-all/typst/brand-yaml/logo/posit/brand-logo.qmd +++ b/tests/docs/smoke-all/typst/brand-yaml/logo/posit/brand-logo.qmd @@ -9,7 +9,7 @@ _quarto: typst: ensureTypstFileRegexMatches: - - - '#set page\(background: align\(left\+top, box\(inset: 0.5in, image\("posit-logo-2024.svg", width: 2in\)\)\)\)' + - '#set page\(background: align\(left\+top, box\(inset: 0.5in, image\("posit-logo-2024.svg", width: 2in, alt: "Posit Logo"\)\)\)\)' - [] --- diff --git a/tests/docs/smoke-all/typst/brand-yaml/logo/quarto/_brand.yml b/tests/docs/smoke-all/typst/brand-yaml/logo/quarto/_brand.yml index 09258765f9..20a0a3456e 100644 --- a/tests/docs/smoke-all/typst/brand-yaml/logo/quarto/_brand.yml +++ b/tests/docs/smoke-all/typst/brand-yaml/logo/quarto/_brand.yml @@ -1,5 +1,7 @@ logo: - large: quarto.png + images: + large-light: quarto.png + large: large-light defaults: quarto: format: