@ggraphic/editor 0.0.0 → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brand/brandRegistry.d.ts +11 -3
- package/dist/brand/brandRegistry.js +18 -3
- package/dist/brand/documentBrand.d.ts +16 -0
- package/dist/brand/documentBrand.js +6 -0
- package/dist/components/CanvasEditor/CanvasEditorShell.js +39 -33
- package/dist/components/CanvasTextOverlay.js +4 -2
- package/dist/components/CustomColorSwatch.js +3 -2
- package/dist/components/GenericCanvas.js +9 -2
- package/dist/components/RichTextField.js +5 -1
- package/dist/components/TextFormatButtons.js +6 -22
- package/dist/components/TopBar/ContextControls.js +4 -2
- package/dist/components/TopBar/modules/FloatingColorPicker.js +3 -1
- package/dist/components/TopBar/modules/FloatingFontRoleControl.js +2 -2
- package/dist/components/kindRenderers.d.ts +1 -1
- package/dist/components/markerMark.d.ts +6 -1
- package/dist/components/markerMark.js +7 -11
- package/dist/configs/factory/actionFactories.d.ts +38 -9
- package/dist/configs/factory/actionFactories.js +53 -36
- package/dist/configs/types.d.ts +13 -2
- package/dist/export/pptx/buildPptxModel.d.ts +3 -0
- package/dist/export/pptx/buildPptxModel.js +5 -5
- package/dist/export/pptx/exportPptxDeck.d.ts +4 -1
- package/dist/export/pptx/exportPptxDeck.js +5 -2
- package/dist/export/pptx/textModel.d.ts +6 -2
- package/dist/export/pptx/textModel.js +14 -11
- package/dist/hooks/useFloatingModuleHandlers.js +2 -2
- package/dist/hooks/useMultiPageExport.js +1 -1
- package/dist/i18n/de.d.ts +2 -0
- package/dist/i18n/de.js +2 -0
- package/dist/i18n/en.js +1 -0
- package/dist/primitives/CanvasRichText.js +7 -4
- package/dist/primitives/CanvasStage.js +3 -2
- package/dist/primitives/UserImagePrimitive.js +3 -1
- package/dist/sidebar/sections/ChartSettingsSection.d.ts +1 -1
- package/dist/sidebar/sections/ChartSettingsSection.js +5 -2
- package/dist/sidebar/sections/CombinedTextSection.js +3 -2
- package/dist/sidebar/sections/DiagrammeSection.js +10 -11
- package/dist/sidebar/sections/FormenSection.d.ts +3 -1
- package/dist/sidebar/sections/FormenSection.js +25 -13
- package/dist/sidebar/sections/IllustrationSettings.js +4 -3
- package/dist/sidebar/sections/ImageAdjustSection.js +6 -5
- package/dist/sidebar/sections/assets/ElementThumb.js +3 -1
- package/dist/sidebar/sections/assets/useElementCatalog.d.ts +2 -1
- package/dist/sidebar/sections/assets/useElementCatalog.js +30 -15
- package/dist/sidebar/sections/effects/GradientSettings.js +4 -2
- package/dist/sidebar/sections/effects/OutlineSettings.js +4 -3
- package/dist/sidebar/sections/effects/ShadowSettings.js +4 -3
- package/dist/sidebar/sections/tools/BlobCreatorTool.js +11 -6
- package/dist/sidebar/sections/tools/GradientTextTool.js +14 -12
- package/dist/sidebar/sections/tools/TextPathCreatorTool.js +15 -13
- package/dist/sidebar/sections/tools/ToolsSection.js +5 -3
- package/dist/testing/documentBrandConfig.d.ts +14 -0
- package/dist/testing/documentBrandConfig.js +60 -0
- package/dist/testing/documentBrandPacks.d.ts +10 -0
- package/dist/testing/documentBrandPacks.js +45 -0
- package/dist/ui/button.d.ts +2 -2
- package/dist/utils/canvasAssets.d.ts +7 -1
- package/dist/utils/circleBadgeUtils.d.ts +3 -1
- package/dist/utils/circleBadgeUtils.js +5 -5
- package/dist/utils/colorNames.d.ts +7 -2
- package/dist/utils/colorNames.js +14 -5
- package/dist/utils/fontMarkSupport.d.ts +1 -0
- package/dist/utils/fontMarkSupport.js +7 -1
- package/dist/utils/frameUtils.d.ts +3 -2
- package/dist/utils/frameUtils.js +3 -2
- package/dist/utils/illustrations/registry.d.ts +4 -1
- package/dist/utils/illustrations/registry.js +5 -3
- package/dist/utils/illustrations/svgCache.js +13 -6
- package/dist/utils/illustrations/types.d.ts +1 -1
- package/dist/utils/imageFilters.d.ts +4 -2
- package/dist/utils/imageFilters.js +3 -2
- package/dist/utils/imageLook.d.ts +4 -2
- package/dist/utils/imageLook.js +4 -2
- package/dist/utils/markerBoxes.d.ts +16 -1
- package/dist/utils/markerBoxes.js +2 -15
- package/dist/utils/markerColors.d.ts +12 -5
- package/dist/utils/markerColors.js +8 -15
- package/dist/utils/photoPlaceholder.d.ts +4 -1
- package/dist/utils/photoPlaceholder.js +5 -3
- package/dist/utils/pillBadgeUtils.d.ts +3 -2
- package/dist/utils/pillBadgeUtils.js +5 -5
- package/dist/utils/shapes.d.ts +4 -2
- package/dist/utils/shapes.js +4 -2
- package/dist/utils/textUtils.js +6 -2
- package/dist/utils/zipPageImages.d.ts +2 -1
- package/dist/utils/zipPageImages.js +3 -2
- package/package.json +3 -3
- package/dist/components/MobileSelectionPill.d.ts +0 -40
- package/dist/components/MobileSelectionPill.js +0 -85
- package/dist/components/TopBar/modules/FloatingGradientControl.d.ts +0 -9
- package/dist/components/TopBar/modules/FloatingGradientControl.js +0 -35
- package/dist/components/TopBar/modules/FloatingOutlineControl.d.ts +0 -11
- package/dist/components/TopBar/modules/FloatingOutlineControl.js +0 -31
- package/dist/components/TopBar/modules/FloatingShadowControl.d.ts +0 -12
- package/dist/components/TopBar/modules/FloatingShadowControl.js +0 -40
- package/dist/utils/balkenUtils.d.ts +0 -22
- package/dist/utils/balkenUtils.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
3
3
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
4
4
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
5
5
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
@@ -14,8 +14,11 @@ const BASE_RADIUS = STAGE_SIZE * 0.38;
|
|
|
14
14
|
const EXPORT_PIXEL_RATIO = 4; // 220 * 4 = 880px PNG
|
|
15
15
|
const MAX_POINTS = 12;
|
|
16
16
|
const TENSION = 0.6;
|
|
17
|
-
/** The brand's fourth colour, read when the tool opens. */
|
|
18
|
-
const defaultColor = () =>
|
|
17
|
+
/** The document brand's fourth colour, read when the tool opens. */
|
|
18
|
+
const defaultColor = (brand) => () => {
|
|
19
|
+
const palette = brandColors(brand);
|
|
20
|
+
return palette[3]?.value ?? palette[0]?.value ?? '#000000';
|
|
21
|
+
};
|
|
19
22
|
function randomSeed() {
|
|
20
23
|
return Array.from({ length: MAX_POINTS }, () => Math.random());
|
|
21
24
|
}
|
|
@@ -36,23 +39,25 @@ function computeBlobPoints(seed, numPoints, irregularity) {
|
|
|
36
39
|
}
|
|
37
40
|
function ColorRow({ selected, onSelect, disabled, }) {
|
|
38
41
|
const t = useMessages();
|
|
39
|
-
|
|
42
|
+
const brand = useDocumentBrand();
|
|
43
|
+
return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
|
|
40
44
|
backgroundColor: c.value,
|
|
41
45
|
outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
|
|
42
46
|
outlineOffset: '2px',
|
|
43
|
-
} }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
|
|
47
|
+
} }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors(brand).map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
|
|
44
48
|
}
|
|
45
49
|
function LabeledRange({ label, value, min, max, step, onChange, disabled, }) {
|
|
46
50
|
return (_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: label }), _jsx("input", { type: "range", min: min, max: max, step: step, value: value, onChange: (e) => onChange(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] }));
|
|
47
51
|
}
|
|
48
52
|
export function BlobCreatorTool({ onJumpToUploads, onPlaceImageUrl }) {
|
|
49
53
|
const t = useMessages();
|
|
54
|
+
const brand = useDocumentBrand();
|
|
50
55
|
const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
|
|
51
56
|
const stageRef = useRef(null);
|
|
52
57
|
const [seed, setSeed] = useState(randomSeed);
|
|
53
58
|
const [numPoints, setNumPoints] = useState(7);
|
|
54
59
|
const [irregularity, setIrregularity] = useState(0.35);
|
|
55
|
-
const [color, setColor] = useState(defaultColor);
|
|
60
|
+
const [color, setColor] = useState(defaultColor(brand));
|
|
56
61
|
const [isBusy, setIsBusy] = useState(false);
|
|
57
62
|
const [error, setError] = useState(null);
|
|
58
63
|
const [success, setSuccess] = useState(null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
2
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
4
3
|
import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
6
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
7
7
|
import { useCallback, useState } from 'react';
|
|
@@ -12,21 +12,22 @@ import { useToolImagePlacement } from '@ggraphic/editor/sidebar/sections/tools/u
|
|
|
12
12
|
// High-res render so the placed image stays crisp when scaled on the canvas.
|
|
13
13
|
const RENDER_FONT_PX = 240;
|
|
14
14
|
const RENDER_PADDING = 24;
|
|
15
|
-
/** The brand's nth colour, read when the tool opens. */
|
|
16
|
-
const paletteColor = (index) => () => brandColors()[index]?.value ?? '#000000';
|
|
15
|
+
/** The document brand's nth colour, read when the tool opens. */
|
|
16
|
+
const paletteColor = (brand, index) => () => brandColors(brand)[index]?.value ?? '#000000';
|
|
17
17
|
function ColorRow({ label, selected, onSelect, disabled, }) {
|
|
18
|
-
|
|
18
|
+
const brand = useDocumentBrand();
|
|
19
|
+
return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: label }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => onSelect(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
|
|
19
20
|
backgroundColor: c.value,
|
|
20
21
|
outline: selected === c.value ? '2px solid var(--editor-accent)' : 'none',
|
|
21
22
|
outlineOffset: '2px',
|
|
22
|
-
} }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors().map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
|
|
23
|
+
} }, c.id))), _jsx(CustomColorSwatch, { value: selected, presets: brandColors(brand).map((c) => c.value), onPick: onSelect, className: "size-6", disabled: disabled })] })] }));
|
|
23
24
|
}
|
|
24
|
-
async function renderGradientTextPng(text, color1, color2, angle) {
|
|
25
|
+
async function renderGradientTextPng(text, color1, color2, angle, fontStack) {
|
|
25
26
|
const canvas = document.createElement('canvas');
|
|
26
27
|
const ctx = canvas.getContext('2d');
|
|
27
28
|
if (!ctx)
|
|
28
29
|
return null;
|
|
29
|
-
const font = `700 ${RENDER_FONT_PX}px ${
|
|
30
|
+
const font = `700 ${RENDER_FONT_PX}px ${fontStack}`;
|
|
30
31
|
// Best-effort: make sure the brand font is ready before measuring/drawing.
|
|
31
32
|
try {
|
|
32
33
|
await document.fonts.load(font, text);
|
|
@@ -59,10 +60,11 @@ async function renderGradientTextPng(text, color1, color2, angle) {
|
|
|
59
60
|
}
|
|
60
61
|
export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
|
|
61
62
|
const t = useMessages();
|
|
63
|
+
const brand = useDocumentBrand();
|
|
62
64
|
const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
|
|
63
65
|
const [value, setValue] = useState('');
|
|
64
|
-
const [color1, setColor1] = useState(paletteColor(0));
|
|
65
|
-
const [color2, setColor2] = useState(paletteColor(1));
|
|
66
|
+
const [color1, setColor1] = useState(paletteColor(brand, 0));
|
|
67
|
+
const [color2, setColor2] = useState(paletteColor(brand, 1));
|
|
66
68
|
const [angle, setAngle] = useState(90);
|
|
67
69
|
const [isBusy, setIsBusy] = useState(false);
|
|
68
70
|
const [error, setError] = useState(null);
|
|
@@ -75,7 +77,7 @@ export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
|
|
|
75
77
|
setSuccess(null);
|
|
76
78
|
setIsBusy(true);
|
|
77
79
|
try {
|
|
78
|
-
const blob = await renderGradientTextPng(trimmed, color1, color2, angle);
|
|
80
|
+
const blob = await renderGradientTextPng(trimmed, color1, color2, angle, headlineFontStack(brand));
|
|
79
81
|
if (!blob)
|
|
80
82
|
throw new Error(t.sidebar.tools.pngFailed);
|
|
81
83
|
const file = new File([blob], `verlaufstext_${Date.now()}.png`, { type: 'image/png' });
|
|
@@ -89,11 +91,11 @@ export function GradientTextTool({ onJumpToUploads, onPlaceImageUrl }) {
|
|
|
89
91
|
finally {
|
|
90
92
|
setIsBusy(false);
|
|
91
93
|
}
|
|
92
|
-
}, [t, trimmed, color1, color2, angle, finish]);
|
|
94
|
+
}, [t, trimmed, color1, color2, angle, finish, brand]);
|
|
93
95
|
const disabled = isBusy || isUploading;
|
|
94
96
|
const previewText = trimmed || t.sidebar.tools.gradientPreview;
|
|
95
97
|
return (_jsx(ToolPanel, { body: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: "Text" }), _jsx("input", { type: "text", value: value, onChange: (e) => setValue(e.target.value), placeholder: t.sidebar.tools.yourText, disabled: disabled, className: `rounded-md border border-editor-border-strong bg-background px-sm py-xs text-sm ${MOBILE_INPUT_TEXT} text-foreground outline-none focus:border-primary-500 disabled:opacity-50` })] }), _jsx("div", { className: "flex items-center justify-center rounded-lg bg-editor-inset p-4 overflow-hidden", children: _jsx("span", { className: "text-3xl font-bold leading-tight text-center break-words", style: {
|
|
96
|
-
fontFamily: headlineFontStack(),
|
|
98
|
+
fontFamily: headlineFontStack(brand),
|
|
97
99
|
backgroundImage: `linear-gradient(${angle}deg, ${color1}, ${color2})`,
|
|
98
100
|
WebkitBackgroundClip: 'text',
|
|
99
101
|
backgroundClip: 'text',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
3
2
|
import { CustomColorSwatch } from '@ggraphic/editor/components/CustomColorSwatch';
|
|
4
3
|
import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
|
|
4
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
5
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
6
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
7
7
|
import Konva from 'konva';
|
|
@@ -10,8 +10,8 @@ import { PiPath } from 'react-icons/pi';
|
|
|
10
10
|
import { MOBILE_INPUT_TEXT } from '@ggraphic/editor/sidebar/sidebarStyles';
|
|
11
11
|
import { ToolPanel, } from '@ggraphic/editor/sidebar/sections/tools/ToolPanel';
|
|
12
12
|
import { useToolImagePlacement } from '@ggraphic/editor/sidebar/sections/tools/useToolImagePlacement';
|
|
13
|
-
/** The brand's first colour, read when the tool opens. */
|
|
14
|
-
const defaultColor = () => brandColors()[0]?.value ?? '#000000';
|
|
13
|
+
/** The document brand's first colour, read when the tool opens. */
|
|
14
|
+
const defaultColor = (brand) => () => brandColors(brand)[0]?.value ?? '#000000';
|
|
15
15
|
// Path presets in a ~360-wide coordinate space. The exact coords don't affect
|
|
16
16
|
// framing — the export measures getClientRect() and crops to the drawn glyphs.
|
|
17
17
|
const VARIANTS = [
|
|
@@ -28,12 +28,12 @@ const VARIANTS = [
|
|
|
28
28
|
* Renders text along an SVG path (Konva.TextPath) into a tightly-cropped PNG.
|
|
29
29
|
* See https://konvajs.org/docs/shapes/TextPath.html
|
|
30
30
|
*/
|
|
31
|
-
async function renderTextPath(text, data, fontSize, color, pixelRatio) {
|
|
31
|
+
async function renderTextPath(text, data, fontSize, color, pixelRatio, fontStack) {
|
|
32
32
|
const container = document.createElement('div');
|
|
33
33
|
const stage = new Konva.Stage({ container, width: 10, height: 10 });
|
|
34
34
|
const layer = new Konva.Layer();
|
|
35
35
|
stage.add(layer);
|
|
36
|
-
const font = `bold ${fontSize}px ${
|
|
36
|
+
const font = `bold ${fontSize}px ${fontStack}`;
|
|
37
37
|
try {
|
|
38
38
|
await document.fonts.load(font, text);
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ async function renderTextPath(text, data, fontSize, color, pixelRatio) {
|
|
|
44
44
|
text,
|
|
45
45
|
data,
|
|
46
46
|
fontSize,
|
|
47
|
-
fontFamily:
|
|
47
|
+
fontFamily: fontStack,
|
|
48
48
|
fontStyle: 'bold',
|
|
49
49
|
fill: color,
|
|
50
50
|
});
|
|
@@ -67,11 +67,13 @@ async function renderTextPath(text, data, fontSize, color, pixelRatio) {
|
|
|
67
67
|
}
|
|
68
68
|
export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
|
|
69
69
|
const t = useMessages();
|
|
70
|
+
const brand = useDocumentBrand();
|
|
71
|
+
const fontStack = headlineFontStack(brand);
|
|
70
72
|
const { finish, isUploading } = useToolImagePlacement({ onPlaceImageUrl, onJumpToUploads });
|
|
71
73
|
const [value, setValue] = useState('');
|
|
72
74
|
const [variant, setVariant] = useState(VARIANTS[0]);
|
|
73
75
|
const [fontSize, setFontSize] = useState(48);
|
|
74
|
-
const [color, setColor] = useState(defaultColor);
|
|
76
|
+
const [color, setColor] = useState(defaultColor(brand));
|
|
75
77
|
const [previewUrl, setPreviewUrl] = useState(null);
|
|
76
78
|
const [isBusy, setIsBusy] = useState(false);
|
|
77
79
|
const [error, setError] = useState(null);
|
|
@@ -81,14 +83,14 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
|
|
|
81
83
|
// Preview mirrors the exact export pipeline (lower resolution).
|
|
82
84
|
useEffect(() => {
|
|
83
85
|
let cancelled = false;
|
|
84
|
-
void renderTextPath(previewText, variant.data, fontSize, color, 1).then((url) => {
|
|
86
|
+
void renderTextPath(previewText, variant.data, fontSize, color, 1, fontStack).then((url) => {
|
|
85
87
|
if (!cancelled)
|
|
86
88
|
setPreviewUrl(url);
|
|
87
89
|
});
|
|
88
90
|
return () => {
|
|
89
91
|
cancelled = true;
|
|
90
92
|
};
|
|
91
|
-
}, [previewText, variant.data, fontSize, color]);
|
|
93
|
+
}, [previewText, variant.data, fontSize, color, fontStack]);
|
|
92
94
|
const disabled = isBusy || isUploading;
|
|
93
95
|
const handleAction = useCallback(async () => {
|
|
94
96
|
if (!trimmed)
|
|
@@ -97,7 +99,7 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
|
|
|
97
99
|
setSuccess(null);
|
|
98
100
|
setIsBusy(true);
|
|
99
101
|
try {
|
|
100
|
-
const dataUrl = await renderTextPath(trimmed, variant.data, fontSize, color, 3);
|
|
102
|
+
const dataUrl = await renderTextPath(trimmed, variant.data, fontSize, color, 3, fontStack);
|
|
101
103
|
if (!dataUrl)
|
|
102
104
|
throw new Error(t.sidebar.tools.previewFailed);
|
|
103
105
|
const blob = await (await fetch(dataUrl)).blob();
|
|
@@ -112,12 +114,12 @@ export function TextPathCreatorTool({ onJumpToUploads, onPlaceImageUrl, }) {
|
|
|
112
114
|
finally {
|
|
113
115
|
setIsBusy(false);
|
|
114
116
|
}
|
|
115
|
-
}, [t, trimmed, variant.data, fontSize, color, finish]);
|
|
117
|
+
}, [t, trimmed, variant.data, fontSize, color, finish, fontStack]);
|
|
116
118
|
return (_jsx(ToolPanel, { body: _jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsx("span", { className: "text-foreground-muted", children: "Text" }), _jsx("input", { type: "text", value: value, onChange: (e) => setValue(e.target.value), placeholder: t.sidebar.tools.yourText, disabled: disabled, className: `rounded-md border border-editor-border-strong bg-background px-sm py-xs text-sm ${MOBILE_INPUT_TEXT} text-foreground outline-none focus:border-primary-500 disabled:opacity-50` })] }), _jsx("div", { className: "flex items-center justify-center rounded-lg bg-editor-inset p-3 min-h-[120px] overflow-hidden", children: previewUrl ? (_jsx("img", { src: previewUrl, alt: t.ui.preview, className: "max-h-[140px] max-w-full" })) : (_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.tools.preview })) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.topBar.shape }), _jsx("div", { className: "grid grid-cols-3 gap-1.5", children: VARIANTS.map((v) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setVariant(v), className: `rounded-md border px-2 py-1.5 text-xs transition-colors disabled:opacity-50 ${variant.id === v.id
|
|
117
119
|
? 'border-primary-500 bg-primary-500/10 text-foreground'
|
|
118
|
-
: 'border-editor-border-strong text-foreground-muted hover:border-primary-500'}`, children: t.sidebar.tools.pathNames[v.id] }, v.id))) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors().map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setColor(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
|
|
120
|
+
: 'border-editor-border-strong text-foreground-muted hover:border-primary-500'}`, children: t.sidebar.tools.pathNames[v.id] }, v.id))) })] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("span", { className: "text-xs text-foreground-muted", children: t.sidebar.chart.color }), _jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [brandColors(brand).map((c) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => setColor(c.value), title: c.name, className: "size-6 rounded-full border border-black/10 transition-transform hover:scale-110 disabled:opacity-50", style: {
|
|
119
121
|
backgroundColor: c.value,
|
|
120
122
|
outline: color === c.value ? '2px solid var(--editor-accent)' : 'none',
|
|
121
123
|
outlineOffset: '2px',
|
|
122
|
-
} }, c.id))), _jsx(CustomColorSwatch, { value: color, presets: brandColors().map((c) => c.value), onPick: setColor, className: "size-6", disabled: disabled })] })] }), _jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsxs("span", { className: "text-foreground-muted", children: [t.sidebar.fontSize, ": ", fontSize, "px"] }), _jsx("input", { type: "range", min: 24, max: 80, step: 2, value: fontSize, onChange: (e) => setFontSize(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] })] }), actionLabel: onPlaceImageUrl ? t.sidebar.tools.pathTextPlace : t.sidebar.tools.pathTextAdd, actionIcon: PiPath, canSubmit: !!trimmed, isBusy: disabled, progressMessage: isBusy ? t.sidebar.tools.pathTextSaving : null, error: error, success: success, onAction: () => void handleAction() }));
|
|
124
|
+
} }, c.id))), _jsx(CustomColorSwatch, { value: color, presets: brandColors(brand).map((c) => c.value), onPick: setColor, className: "size-6", disabled: disabled })] })] }), _jsxs("label", { className: "flex flex-col gap-1.5 text-xs", children: [_jsxs("span", { className: "text-foreground-muted", children: [t.sidebar.fontSize, ": ", fontSize, "px"] }), _jsx("input", { type: "range", min: 24, max: 80, step: 2, value: fontSize, onChange: (e) => setFontSize(Number(e.target.value)), disabled: disabled, className: "w-full max-canvas-mobile:h-11 accent-primary-600 disabled:opacity-50" })] })] }), actionLabel: onPlaceImageUrl ? t.sidebar.tools.pathTextPlace : t.sidebar.tools.pathTextAdd, actionIcon: PiPath, canSubmit: !!trimmed, isBusy: disabled, progressMessage: isBusy ? t.sidebar.tools.pathTextSaving : null, error: error, success: success, onAction: () => void handleAction() }));
|
|
123
125
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: MPL-2.0
|
|
3
3
|
import { useCanvasEditorServices } from '@ggraphic/editor/CanvasEditorProvider';
|
|
4
|
-
import {
|
|
4
|
+
import { headlineFontStack } from '@ggraphic/editor/brand/brandRegistry';
|
|
5
|
+
import { useDocumentBrand } from '@ggraphic/editor/brand/documentBrand';
|
|
5
6
|
import { useMessages } from '@ggraphic/editor/i18n/messages';
|
|
6
7
|
import { cn } from '@ggraphic/editor/utils/cn';
|
|
7
8
|
import { Suspense, useEffect, useId, useState } from 'react';
|
|
@@ -32,8 +33,9 @@ const warmPanel = (id) => void PANELS[id].preload().catch(() => { });
|
|
|
32
33
|
// The letters carry the gradient themselves, so the tile shows what the tool makes.
|
|
33
34
|
export function GradientTextIcon({ size = 24, className }) {
|
|
34
35
|
const gradientId = useId();
|
|
35
|
-
const
|
|
36
|
-
|
|
36
|
+
const brand = useDocumentBrand();
|
|
37
|
+
const { secondary, accent } = brand.colors;
|
|
38
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", className: className, "aria-hidden": "true", children: [_jsx("defs", { children: _jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "1", y2: "0", children: [_jsx("stop", { offset: "0", stopColor: secondary }), _jsx("stop", { offset: "1", stopColor: accent })] }) }), _jsx("text", { x: "12", y: "18", textAnchor: "middle", fontSize: "17", fontWeight: "900", fontFamily: headlineFontStack(brand), fill: `url(#${gradientId})`, children: "Aa" })] }));
|
|
37
39
|
}
|
|
38
40
|
function ToolCardButton({ card, onClick, }) {
|
|
39
41
|
return (_jsxs("button", { type: "button", onClick: onClick, onPointerEnter: () => warmPanel(card.id), onFocus: () => warmPanel(card.id), className: cn('tool-tile-trigger flex w-full flex-col items-center gap-2.5 p-2 cursor-pointer bg-transparent border-none rounded-[14px]', 'transition-colors duration-150 hover:bg-[var(--editor-active-soft)]', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600'), children: [_jsx(ToolTile, { id: card.id }), _jsx("span", { className: "text-sm leading-tight text-foreground text-center", children: card.label })] }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A one-tab page config for the tests of the document brand: a colour ground, one text with a
|
|
3
|
+
* marker run (no marker style of its own) and the Text tab. The actions are the editor's element
|
|
4
|
+
* factories, given the config's `brand` exactly as a host does.
|
|
5
|
+
*/
|
|
6
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
7
|
+
import { createElementActions } from '../configs/factory/actionFactories.js';
|
|
8
|
+
import { type BaseCanvasState } from '../configs/factory/baseTypes.js';
|
|
9
|
+
import { type FullCanvasConfig } from '../configs/types.js';
|
|
10
|
+
export interface BrandTestState extends BaseCanvasState {
|
|
11
|
+
backgroundColor: string;
|
|
12
|
+
}
|
|
13
|
+
export type BrandTestActions = ReturnType<typeof createElementActions<BrandTestState>>;
|
|
14
|
+
export declare function brandTestConfig(id: string, brand?: BrandPack): FullCanvasConfig<BrandTestState, BrandTestActions>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createElementActions } from '../configs/factory/actionFactories.js';
|
|
2
|
+
import { carryInstanceState } from '../configs/factory/carryInstanceState.js';
|
|
3
|
+
import { makeSectionDefiner } from '../configs/factory/defineSection.js';
|
|
4
|
+
import { CombinedTextSection } from '../sidebar/sections/CombinedTextSection.js';
|
|
5
|
+
const section = makeSectionDefiner();
|
|
6
|
+
export function brandTestConfig(id, brand) {
|
|
7
|
+
const width = 1080;
|
|
8
|
+
const height = 1080;
|
|
9
|
+
return {
|
|
10
|
+
id,
|
|
11
|
+
canvas: { width, height },
|
|
12
|
+
...(brand ? { brand } : {}),
|
|
13
|
+
tabs: [{ id: 'text', icon: () => null, label: 'Text', ariaLabel: 'Text' }],
|
|
14
|
+
sections: {
|
|
15
|
+
text: section({
|
|
16
|
+
component: CombinedTextSection,
|
|
17
|
+
propsFactory: (state, actions) => ({
|
|
18
|
+
additionalTexts: state.additionalTexts,
|
|
19
|
+
onAddHeader: actions.addHeader,
|
|
20
|
+
onAddSubheader: actions.addSubheader,
|
|
21
|
+
onAddText: actions.addText,
|
|
22
|
+
onUpdateText: actions.updateAdditionalText,
|
|
23
|
+
onRemoveText: actions.removeAdditionalText,
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
elements: [
|
|
28
|
+
{
|
|
29
|
+
id: 'background',
|
|
30
|
+
type: 'background',
|
|
31
|
+
x: 0,
|
|
32
|
+
y: 0,
|
|
33
|
+
order: -1,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
fillStateKey: 'backgroundColor',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
calculateLayout: () => ({}),
|
|
40
|
+
createInitialState: (props) => ({
|
|
41
|
+
isDesktop: true,
|
|
42
|
+
...carryInstanceState(props),
|
|
43
|
+
backgroundColor: '#ffffff',
|
|
44
|
+
additionalTexts: [
|
|
45
|
+
{
|
|
46
|
+
id: 'text-1',
|
|
47
|
+
type: 'body',
|
|
48
|
+
text: 'Ich will ++frei++ sein',
|
|
49
|
+
x: 40,
|
|
50
|
+
y: 40,
|
|
51
|
+
width: 900,
|
|
52
|
+
fontSize: 60,
|
|
53
|
+
fontFamily: 'Arial, sans-serif',
|
|
54
|
+
fill: '#000000',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
}),
|
|
58
|
+
createActions: (getState, setState, saveToHistory, debouncedSaveToHistory) => createElementActions(getState, setState, saveToHistory, debouncedSaveToHistory, width, height, '#000000', undefined, 1, brand),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two neutral packs for the tests of the document brand: `PACK_A` is the
|
|
3
|
+
* editor's default, `PACK_B` shares nothing with it a test could mistake for it
|
|
4
|
+
* (colours, palette ids, marker, headline family). The registry is set to
|
|
5
|
+
* `[PACK_A, PACK_B]`, so a document of `PACK_B` is "the other one" exactly as an
|
|
6
|
+
* Austrian document is next to a German first pack in a host.
|
|
7
|
+
*/
|
|
8
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
9
|
+
export declare const PACK_A: BrandPack;
|
|
10
|
+
export declare const PACK_B: BrandPack;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Two neutral packs for the tests of the document brand: `PACK_A` is the
|
|
4
|
+
* editor's default, `PACK_B` shares nothing with it a test could mistake for it
|
|
5
|
+
* (colours, palette ids, marker, headline family). The registry is set to
|
|
6
|
+
* `[PACK_A, PACK_B]`, so a document of `PACK_B` is "the other one" exactly as an
|
|
7
|
+
* Austrian document is next to a German first pack in a host.
|
|
8
|
+
*/
|
|
9
|
+
import { brandDefault } from '@ggraphic/core';
|
|
10
|
+
export const PACK_A = brandDefault;
|
|
11
|
+
export const PACK_B = {
|
|
12
|
+
...brandDefault,
|
|
13
|
+
id: 'fixture-b',
|
|
14
|
+
name: 'Fixture B',
|
|
15
|
+
colors: {
|
|
16
|
+
...brandDefault.colors,
|
|
17
|
+
primary: '#0B6E4F',
|
|
18
|
+
secondary: '#C1121F',
|
|
19
|
+
accent: '#F9A03F',
|
|
20
|
+
accentOnLight: '#6A040F',
|
|
21
|
+
attention: '#E01E37',
|
|
22
|
+
surface: '#FEFAE0',
|
|
23
|
+
},
|
|
24
|
+
palette: [
|
|
25
|
+
{ id: 'moss', label: 'Moss', color: '#0B6E4F' },
|
|
26
|
+
{ id: 'berry', label: 'Berry', color: '#C1121F' },
|
|
27
|
+
{ id: 'amber', label: 'Amber', color: '#F9A03F' },
|
|
28
|
+
{ id: 'plum', label: 'Plum', color: '#6A040F' },
|
|
29
|
+
{ id: 'white', label: 'White', color: '#FFFFFF' },
|
|
30
|
+
],
|
|
31
|
+
markers: {
|
|
32
|
+
swatches: [
|
|
33
|
+
{ id: 'lemon', label: 'Lemon', color: '#FFE45E' },
|
|
34
|
+
{ id: 'white', label: 'White', color: '#FFFFFF' },
|
|
35
|
+
],
|
|
36
|
+
ink: '#1A3D5C',
|
|
37
|
+
},
|
|
38
|
+
chart: ['#0B6E4F', '#C1121F', '#F9A03F', '#6A040F'],
|
|
39
|
+
effects: {
|
|
40
|
+
tints: ['#0B6E4F', '#C1121F'],
|
|
41
|
+
shadows: ['#101010', '#0B6E4F'],
|
|
42
|
+
outlines: ['#FFFFFF', '#101010'],
|
|
43
|
+
},
|
|
44
|
+
fonts: { ...brandDefault.fonts, headline: 'Fixture Display' },
|
|
45
|
+
};
|
package/dist/ui/button.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
5
|
-
size?: "
|
|
4
|
+
variant?: "brand" | "default" | "outline" | null | undefined;
|
|
5
|
+
size?: "brand" | "default" | "sm" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
8
8
|
asChild?: boolean;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { type AssetInstance } from '@ggraphic/core';
|
|
7
7
|
import type { CanvasAiNamedOption } from '@ggraphic/editor/ai/types';
|
|
8
8
|
import type { ElementPanelHost } from '@ggraphic/editor/sidebar/sections/assets/elementPanelHost';
|
|
9
|
-
import type { KawaiiDef, SvgDef } from '@ggraphic/editor/utils/illustrations/types';
|
|
9
|
+
import type { KawaiiDef, SvgDef, SvgSource } from '@ggraphic/editor/utils/illustrations/types';
|
|
10
10
|
import type { StickerRef } from '@ggraphic/schema';
|
|
11
11
|
export { ASSET_TARGET_SIZE, type AssetInstance } from '@ggraphic/core';
|
|
12
12
|
export type AssetAudience = 'de-DE' | 'de-AT' | 'all';
|
|
@@ -103,6 +103,12 @@ export interface IllustrationSources {
|
|
|
103
103
|
featured?: readonly SvgDef[];
|
|
104
104
|
/** Colour the Kawaii characters are drawn in on their tiles. */
|
|
105
105
|
kawaiiColor?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Per SVG set, the colour its files draw their main shapes in; a tinted
|
|
108
|
+
* illustration swaps it for the chosen colour. A set without an entry keeps
|
|
109
|
+
* its colours. Open Doodles' `#ff5678` is known without a host entry.
|
|
110
|
+
*/
|
|
111
|
+
recolor?: Readonly<Partial<Record<SvgSource, string>>>;
|
|
106
112
|
}
|
|
107
113
|
/** The host's catalogue, installed once at startup; replaces the one before. */
|
|
108
114
|
export declare function registerAssetCatalog(catalog: CanvasAssetCatalog): void;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* A circle badge is a colored circle with multiple centered text lines,
|
|
6
6
|
* commonly used for date displays in event templates.
|
|
7
7
|
*/
|
|
8
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
8
9
|
import type { CircleBadgeInstance, CircleBadgeTextLine } from '../primitives/CircleBadge.js';
|
|
9
10
|
export type { CircleBadgeInstance, CircleBadgeTextLine };
|
|
10
11
|
export interface CircleBadgePreset {
|
|
@@ -24,5 +25,6 @@ export declare function generateCircleBadgeId(): string;
|
|
|
24
25
|
*
|
|
25
26
|
* @param presetId - The preset to use (e.g., 'default', 'default-inverted')
|
|
26
27
|
* @param overrides - Optional overrides for specific properties
|
|
28
|
+
* @param brand - The pack the preset takes its colours and font from; the active brand by default
|
|
27
29
|
*/
|
|
28
|
-
export declare function createCircleBadgeInstance(presetId?: string, overrides?: Partial<CircleBadgeInstance
|
|
30
|
+
export declare function createCircleBadgeInstance(presetId?: string, overrides?: Partial<CircleBadgeInstance>, brand?: BrandPack): CircleBadgeInstance;
|
|
@@ -11,9 +11,8 @@ import { messages } from '@ggraphic/editor/i18n/messages';
|
|
|
11
11
|
// ============================================================================
|
|
12
12
|
// PRESETS
|
|
13
13
|
// ============================================================================
|
|
14
|
-
/** The presets in
|
|
15
|
-
function circleBadgePresets() {
|
|
16
|
-
const { colors, fonts } = activeBrand();
|
|
14
|
+
/** The presets in a brand's colours and headline font. */
|
|
15
|
+
function circleBadgePresets({ colors, fonts }) {
|
|
17
16
|
return {
|
|
18
17
|
default: {
|
|
19
18
|
radius: 80,
|
|
@@ -65,9 +64,10 @@ export function generateCircleBadgeId() {
|
|
|
65
64
|
*
|
|
66
65
|
* @param presetId - The preset to use (e.g., 'default', 'default-inverted')
|
|
67
66
|
* @param overrides - Optional overrides for specific properties
|
|
67
|
+
* @param brand - The pack the preset takes its colours and font from; the active brand by default
|
|
68
68
|
*/
|
|
69
|
-
export function createCircleBadgeInstance(presetId = 'default', overrides = {}) {
|
|
70
|
-
const presets = circleBadgePresets();
|
|
69
|
+
export function createCircleBadgeInstance(presetId = 'default', overrides = {}, brand = activeBrand()) {
|
|
70
|
+
const presets = circleBadgePresets(brand);
|
|
71
71
|
const preset = presets[presetId] ?? presets.default;
|
|
72
72
|
return {
|
|
73
73
|
id: generateCircleBadgeId(),
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
2
|
+
/**
|
|
3
|
+
* Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s.
|
|
4
|
+
* The document's pack names it first; a colour it lacks (the effect swatches
|
|
5
|
+
* are shared) keeps the name another registered pack gives it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function colorName(hex: string, brand: BrandPack): string;
|
package/dist/utils/colorNames.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { registeredBrands } from '@ggraphic/editor/brand/brandRegistry';
|
|
2
2
|
import { messages } from '@ggraphic/editor/i18n/messages';
|
|
3
3
|
import { brandColors } from '@ggraphic/editor/utils/colorOptions';
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Name of a brand colour, otherwise "Farbe #RRGGBB" (catalogue) — for swatch `aria-label`s.
|
|
6
|
+
* The document's pack names it first; a colour it lacks (the effect swatches
|
|
7
|
+
* are shared) keeps the name another registered pack gives it.
|
|
8
|
+
*/
|
|
9
|
+
export function colorName(hex, brand) {
|
|
10
|
+
const value = hex.toLowerCase();
|
|
11
|
+
for (const pack of [brand, ...registeredBrands()]) {
|
|
12
|
+
const match = brandColors(pack).find((c) => c.value.toLowerCase() === value);
|
|
13
|
+
if (match)
|
|
14
|
+
return match.name;
|
|
15
|
+
}
|
|
16
|
+
return messages().common.colorHex(hex.toUpperCase());
|
|
8
17
|
}
|
|
@@ -22,4 +22,5 @@ export interface FontMarkSupport {
|
|
|
22
22
|
}
|
|
23
23
|
/** Erste Familie aus einem CSS-Stapel, ohne Anführungszeichen. */
|
|
24
24
|
export declare function primaryFontFamily(fontFamily: string): string;
|
|
25
|
+
/** A registered brand's `cuts` win over the built-in table: the host loads that family. */
|
|
25
26
|
export declare function fontMarkSupport(fontFamily: string): FontMarkSupport;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
import { brandCuts } from '@ggraphic/editor/brand/brandRegistry';
|
|
2
3
|
import { aliasFontFamily } from './fontAliases.js';
|
|
3
4
|
/**
|
|
4
5
|
* Familien mit echten Schnitten. Alles, was hier fehlt, bekommt weder Fett
|
|
@@ -21,6 +22,11 @@ const NONE = { bold: false, italic: false };
|
|
|
21
22
|
export function primaryFontFamily(fontFamily) {
|
|
22
23
|
return aliasFontFamily((fontFamily.split(',')[0] ?? '').trim().replace(/^['"]|['"]$/g, ''));
|
|
23
24
|
}
|
|
25
|
+
/** A registered brand's `cuts` win over the built-in table: the host loads that family. */
|
|
24
26
|
export function fontMarkSupport(fontFamily) {
|
|
25
|
-
|
|
27
|
+
const family = primaryFontFamily(fontFamily);
|
|
28
|
+
const cuts = brandCuts(family);
|
|
29
|
+
if (cuts)
|
|
30
|
+
return { bold: cuts.bold === true, italic: cuts.italic === true };
|
|
31
|
+
return FACES[family] ?? NONE;
|
|
26
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
|
|
1
|
+
import { type BrandPack, type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
|
|
2
2
|
import type { IconType } from 'react-icons';
|
|
3
3
|
export { type FrameCategory, type FrameClipType, type FrameInstance } from '@ggraphic/core';
|
|
4
4
|
export interface FramePreset<T extends FrameClipType = FrameClipType> {
|
|
@@ -16,4 +16,5 @@ export declare const FRAME_CATEGORY_ORDER: readonly FrameCategory[];
|
|
|
16
16
|
export declare const FRAME_ICON_MAP: Record<FrameClipType, IconType>;
|
|
17
17
|
export declare const FRAME_PRESET_PATHS: Record<FrameClipType, string>;
|
|
18
18
|
export declare const DEFAULT_FRAME_SIZE = 300;
|
|
19
|
-
|
|
19
|
+
/** A new frame; its border takes the colour of `brand`, the active brand by default. */
|
|
20
|
+
export declare function createFrameInstance(clipType: FrameClipType, x: number, y: number, brand?: BrandPack): FrameInstance;
|
package/dist/utils/frameUtils.js
CHANGED
|
@@ -254,7 +254,8 @@ const DEFAULT_FRAME_DIMENSIONS = {
|
|
|
254
254
|
oval: { width: 300, height: 220 },
|
|
255
255
|
};
|
|
256
256
|
let instanceCounter = 0;
|
|
257
|
-
|
|
257
|
+
/** A new frame; its border takes the colour of `brand`, the active brand by default. */
|
|
258
|
+
export function createFrameInstance(clipType, x, y, brand = activeBrand()) {
|
|
258
259
|
instanceCounter += 1;
|
|
259
260
|
const dims = DEFAULT_FRAME_DIMENSIONS[clipType] ?? {
|
|
260
261
|
width: DEFAULT_FRAME_SIZE,
|
|
@@ -275,7 +276,7 @@ export function createFrameInstance(clipType, x, y) {
|
|
|
275
276
|
imageOffsetX: 0,
|
|
276
277
|
imageOffsetY: 0,
|
|
277
278
|
imageScale: 1,
|
|
278
|
-
borderColor:
|
|
279
|
+
borderColor: brand.colors.primary,
|
|
279
280
|
borderWidth: 3,
|
|
280
281
|
cornerRadius: clipType === 'rounded-rect' ? 24 : 0,
|
|
281
282
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* the metadata lands in the editor-core chunk (this module is reached eagerly
|
|
8
8
|
* through the render layer and action factories).
|
|
9
9
|
*/
|
|
10
|
+
import { type BrandPack } from '@ggraphic/core';
|
|
10
11
|
import type { KawaiiDef, SvgDef, IllustrationDef, IllustrationInstance } from '@ggraphic/editor/utils/illustrations/types';
|
|
11
12
|
export type { KawaiiDef, SvgDef, IllustrationDef, IllustrationInstance, KawaiiInstance, SvgInstance, KawaiiMood, KawaiiIllustrationType, } from '@ggraphic/editor/utils/illustrations/types';
|
|
12
13
|
export { KAWAII_MOODS } from '@ggraphic/editor/utils/illustrations/types';
|
|
@@ -15,7 +16,9 @@ export declare function getAllIllustrations(): Promise<IllustrationDef[]>;
|
|
|
15
16
|
export declare function getAllSvgIllustrations(): Promise<SvgDef[]>;
|
|
16
17
|
export declare function getIllustrationPath(illustration: SvgDef, baseUrl?: string): string;
|
|
17
18
|
export declare function getIllustrationThumbPath(illustration: SvgDef, baseUrl?: string): string;
|
|
18
|
-
export declare function createIllustration(illustrationId: string, canvasWidth: number, canvasHeight: number
|
|
19
|
+
export declare function createIllustration(illustrationId: string, canvasWidth: number, canvasHeight: number,
|
|
20
|
+
/** The pack a new illustration takes its colour from; the active brand by default. */
|
|
21
|
+
brand?: BrandPack): Promise<IllustrationInstance>;
|
|
19
22
|
export declare function findIllustrationById(id: string): Promise<IllustrationDef | undefined>;
|
|
20
23
|
export declare function searchIllustrations(query: string): Promise<IllustrationDef[]>;
|
|
21
24
|
export declare function getIllustrationsByCategory(category: string): Promise<SvgDef[]>;
|
|
@@ -37,7 +37,9 @@ export function getIllustrationThumbPath(illustration, baseUrl = '') {
|
|
|
37
37
|
const pngFilename = illustration.filename.replace(/\.svg$/, '.png');
|
|
38
38
|
return `${illustrationBase(baseUrl)}/thumbs/${illustration.source}/${pngFilename}`;
|
|
39
39
|
}
|
|
40
|
-
export async function createIllustration(illustrationId, canvasWidth, canvasHeight
|
|
40
|
+
export async function createIllustration(illustrationId, canvasWidth, canvasHeight,
|
|
41
|
+
/** The pack a new illustration takes its colour from; the active brand by default. */
|
|
42
|
+
brand = activeBrand()) {
|
|
41
43
|
const kawaiiIllustrations = await loadKawaiiIllustrations();
|
|
42
44
|
const kawaiiDef = kawaiiIllustrations.find((k) => k.id === illustrationId);
|
|
43
45
|
if (kawaiiDef) {
|
|
@@ -49,7 +51,7 @@ export async function createIllustration(illustrationId, canvasWidth, canvasHeig
|
|
|
49
51
|
y: canvasHeight / 2 - 50,
|
|
50
52
|
scale: 1,
|
|
51
53
|
rotation: 0,
|
|
52
|
-
color:
|
|
54
|
+
color: brand.colors.secondary,
|
|
53
55
|
opacity: 1,
|
|
54
56
|
mood: 'happy',
|
|
55
57
|
};
|
|
@@ -67,7 +69,7 @@ export async function createIllustration(illustrationId, canvasWidth, canvasHeig
|
|
|
67
69
|
scale: 1.0,
|
|
68
70
|
rotation: 0,
|
|
69
71
|
opacity: 1,
|
|
70
|
-
color:
|
|
72
|
+
color: brand.colors.primary,
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
throw new Error(`Unknown illustration ID: ${illustrationId}`);
|