feat: set logo via constant

This commit is contained in:
Arnošt Pleskot 2023-09-05 15:29:02 +02:00
parent 0189120f79
commit 33e031c9fa
No known key found for this signature in database
2 changed files with 6 additions and 9 deletions

View File

@ -237,6 +237,7 @@ export const FANCY_BG_PADDING = 24; // px
export const FANCY_BG_BORDER_RADIUS = 12; // px export const FANCY_BG_BORDER_RADIUS = 12; // px
export const FANCY_BG_LOGO_PADDING = 20; // px export const FANCY_BG_LOGO_PADDING = 20; // px
export const FANCY_BG_LOGO_BOTTOM_PADDING = 12; // px export const FANCY_BG_LOGO_BOTTOM_PADDING = 12; // px
export const FANCY_BG_INCLUDE_LOGO = true;
export const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440; export const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;

View File

@ -12,6 +12,7 @@ import { AppState, BinaryFiles, Dimensions, ExportPadding } from "../types";
import { import {
DEFAULT_EXPORT_PADDING, DEFAULT_EXPORT_PADDING,
FANCY_BACKGROUND_IMAGES, FANCY_BACKGROUND_IMAGES,
FANCY_BG_INCLUDE_LOGO,
SVG_NS, SVG_NS,
THEME, THEME,
THEME_FILTER, THEME_FILTER,
@ -38,12 +39,10 @@ export const exportToCanvas = async (
{ {
exportBackground, exportBackground,
exportPadding = DEFAULT_EXPORT_PADDING, exportPadding = DEFAULT_EXPORT_PADDING,
exportLogo = true,
viewBackgroundColor, viewBackgroundColor,
}: { }: {
exportBackground: boolean; exportBackground: boolean;
exportPadding?: number | ExportPadding; exportPadding?: number | ExportPadding;
exportLogo?: boolean;
viewBackgroundColor: string; viewBackgroundColor: string;
}, },
createCanvas: ( createCanvas: (
@ -66,7 +65,7 @@ export const exportToCanvas = async (
? convertToExportPadding(exportPadding) ? convertToExportPadding(exportPadding)
: getFancyBackgroundPadding( : getFancyBackgroundPadding(
convertToExportPadding(exportPadding), convertToExportPadding(exportPadding),
exportLogo, FANCY_BG_INCLUDE_LOGO,
); );
const [minX, minY, width, height] = !exportWithFancyBackground const [minX, minY, width, height] = !exportWithFancyBackground
@ -109,7 +108,7 @@ export const exportToCanvas = async (
exportScale: scale, exportScale: scale,
theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT, theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT,
contentSize, contentSize,
includeLogo: exportLogo, includeLogo: FANCY_BG_INCLUDE_LOGO,
}); });
scrollXAdjustment = scrollXAdjustment =
@ -166,7 +165,6 @@ export const exportToSvg = async (
opts?: { opts?: {
serializeAsJSON?: () => string; serializeAsJSON?: () => string;
renderEmbeddables?: boolean; renderEmbeddables?: boolean;
includeLogo?: boolean;
}, },
): Promise<SVGSVGElement> => { ): Promise<SVGSVGElement> => {
const { const {
@ -183,13 +181,11 @@ export const exportToSvg = async (
appState.fancyBackgroundImageKey && appState.fancyBackgroundImageKey &&
appState.fancyBackgroundImageKey !== "solid"; appState.fancyBackgroundImageKey !== "solid";
const includeLogo = (exportWithFancyBackground && opts?.includeLogo) ?? true;
const padding = !exportWithFancyBackground const padding = !exportWithFancyBackground
? convertToExportPadding(exportPadding) ? convertToExportPadding(exportPadding)
: getFancyBackgroundPadding( : getFancyBackgroundPadding(
convertToExportPadding(exportPadding), convertToExportPadding(exportPadding),
includeLogo, FANCY_BG_INCLUDE_LOGO,
); );
let metadata = ""; let metadata = "";
@ -312,7 +308,7 @@ export const exportToSvg = async (
}, },
theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT, theme: appState.exportWithDarkMode ? THEME.DARK : THEME.LIGHT,
contentSize, contentSize,
includeLogo, includeLogo: FANCY_BG_INCLUDE_LOGO,
}); });
offsetXAdjustment = offsetXAdjustment =