Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
Merge pull request #96 from SufGitHB/fix/star-graphic
Soufiane EL AZZOUZI22887a14e158
diff --git a/src/components/editor/panels/ElementsPanel.tsx b/src/components/editor/panels/ElementsPanel.tsxindex 9d1c239..146b80b 100644--- a/src/components/editor/panels/ElementsPanel.tsx+++ b/src/components/editor/panels/ElementsPanel.tsx@@ -72,7 +72,7 @@ const STAR_TILES: { label: string; points: number; ratio?: number }[] = []const GRAPHIC_GROUPS: { name: string; ids: string[] }[] = [- { name: 'Decorative', ids: ['heart', 'blob', 'cloud', 'moon', 'sparkle', 'wave'] },+ { name: 'Decorative', ids: ['star', 'heart', 'blob', 'cloud', 'moon', 'sparkle', 'wave'] },{ name: 'Badges & labels', ids: ['badge', 'banner', 'ribbon', 'frame', 'speech'] },{ name: 'Icons', ids: ['bolt', 'check-circle', 'arrow'] },]diff --git a/src/lib/editor-utils.ts b/src/lib/editor-utils.tsindex fe7853d..a243287 100644--- a/src/lib/editor-utils.ts+++ b/src/lib/editor-utils.ts@@ -106,6 +106,11 @@ export const GRAPHICS: GraphicDef[] = [name: 'Heart',path: 'M50 88 C22 66 4 48 4 28 C4 12 17 2 31 2 C40 2 47 7 50 13 C53 7 60 2 69 2 C83 2 96 12 96 28 C96 48 78 66 50 88 Z',},+ {+ id: 'star',+ name: 'Star',+ path: 'M50 2 L62 34 L96 35 L69 56 L78 90 L50 70 L22 90 L31 56 L4 35 L38 34 Z',+ },{id: 'burst',name: 'Starburst',diff --git a/src/lib/templates/helpers.test.ts b/src/lib/templates/helpers.test.tsnew file mode 100644index 0000000..c866afc--- /dev/null+++ b/src/lib/templates/helpers.test.ts@@ -0,0 +1,37 @@+import { describe, expect, it } from 'vitest'+import { GRAPHICS } from '../editor-utils'+import { BASE_TEMPLATES } from './index'+import { gr } from './helpers'++/**+ * Two shipped templates call `gr('star')`, but the GRAPHICS catalogue+ * had no `star` entry. `gr()` silently fell back to GRAPHICS[0] (the+ * heart), so those templates rendered a heart where a star was meant.+ * Pin the catalogue entry and guard every template against unresolved+ * graphic ids so the silent fallback cannot hide another gap.+ */+describe('template graphics', () => {+ it("gr('star') resolves to the star graphic, not the heart fallback", () => {+ const star = GRAPHICS.find((g) => g.id === 'star')+ expect(star, 'GRAPHICS must contain a star entry').toBeDefined()+ expect(gr('star', {}).pathData).toBe(star?.path)+ expect(star?.path).not.toBe(GRAPHICS[0].path)+ })++ it('every path element in the built-in templates uses a known graphic', () => {+ const knownPaths = new Set(GRAPHICS.map((g) => g.path))+ const unknown = new Set<string>()++ for (const template of BASE_TEMPLATES) {+ for (const page of template.pages) {+ for (const el of page.elements) {+ if (el.type === 'path' && el.pathData && !knownPaths.has(el.pathData)) {+ unknown.add(`${template.slug}: ${el.pathData}`)+ }+ }+ }+ }++ expect([...unknown]).toEqual([])+ })+})