Files
site-builder/craft/src/editor/selection-fixture.ts
T

25 lines
1.6 KiB
TypeScript

/** Test fixture: ROOT > sec (Section, inner `sec-in`) > cols (ColumnLayout) >
* col-0 (b1, b2) / col-1 (empty), plus a second top-level Section `sec2`. */
const base = { custom: {}, hidden: false, nodes: [] as string[], linkedNodes: {} as Record<string, string> };
const container = (id: string, parent: string, nodes: string[] = []) => ({
...base, type: { resolvedName: 'Container' }, isCanvas: true, props: { style: {}, tag: 'div' },
displayName: 'Container', parent, nodes,
});
const button = (parent: string, text: string) => ({
...base, type: { resolvedName: 'ButtonLink' }, isCanvas: false, props: { text, href: '#' },
displayName: 'ButtonLink', parent,
});
export const SELECTION_STATE = JSON.stringify({
ROOT: { ...container('ROOT', 'x', ['sec', 'sec2']), parent: undefined },
sec: { ...base, type: { resolvedName: 'Section' }, isCanvas: false, props: { style: {} }, displayName: 'Section', parent: 'ROOT', linkedNodes: { 'section-inner': 'sec-in' } },
'sec-in': container('sec-in', 'sec', ['cols']),
cols: { ...base, type: { resolvedName: 'ColumnLayout' }, isCanvas: false, props: {}, displayName: 'Columns', parent: 'sec-in', linkedNodes: { 'col-0': 'col-0', 'col-1': 'col-1' } },
'col-0': container('col-0', 'cols', ['b1', 'b2']),
'col-1': container('col-1', 'cols'),
b1: button('col-0', 'One'),
b2: button('col-0', 'Two'),
sec2: { ...base, type: { resolvedName: 'Section' }, isCanvas: false, props: { style: {} }, displayName: 'Section', parent: 'ROOT', linkedNodes: { 'section-inner': 'sec2-in' } },
'sec2-in': container('sec2-in', 'sec2'),
});