aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/scrapbook/ScrapbookPreset.tsx
blob: a3405083b178924c66b75a0a35e6d8a3d376c019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { DocumentType } from '../../../documents/DocumentTypes';

export enum ScrapbookPresetType {
    None = 'None',
    Collage = 'Collage',
    Spotlight = 'Spotlight',
    Gallery = 'Gallery',
    Default = 'Default',
    Classic = 'Classic',
}

export interface ScrapbookItemConfig {
    x: number;
    y: number;

    message?: string; // optional text to display instead of [placeholder] + acceptTags[0]
    type?: DocumentType;
    /** what this slot actually accepts (defaults to `tag`) */
    acceptTags?: string[];
    /** the frame this placeholder occupies */
    width?: number;
    height?: number;
    /** if this is a container with children, use these for the proto’s own size */
    containerWidth?: number;
    containerHeight?: number;
    children?: ScrapbookItemConfig[];
}

export class ScrapbookPreset {
    static createPreset(presetType: ScrapbookPresetType): ScrapbookItemConfig[] {
        switch (presetType) {
            case ScrapbookPresetType.None:      return ScrapbookPreset.createNonePreset();     
            case ScrapbookPresetType.Classic:   return ScrapbookPreset.createClassicPreset();
            case ScrapbookPresetType.Collage:   return ScrapbookPreset.createCollagePreset();
            case ScrapbookPresetType.Spotlight: return ScrapbookPreset.createSpotlightPreset();
            case ScrapbookPresetType.Default:   return ScrapbookPreset.createDefaultPreset();   
            case ScrapbookPresetType.Gallery:   return ScrapbookPreset.createGalleryPreset();     
            default:
                throw new Error(`Unknown preset type: ${presetType}`);
        } // prettier-ignore
    }

    private static createNonePreset(): ScrapbookItemConfig[] {
        return [{ message: 'To create a scrapbook from existing documents, marquee select. For existing scrapbook arrangements, select a preset from the dropdown.', type: DocumentType.RTF, acceptTags: [], x: 0, y: 0, width: 250, height: 200 }];
    }

    private static createClassicPreset(): ScrapbookItemConfig[] {
        return [
            { type: DocumentType.IMG, message: '[placeholder] landscape', acceptTags: ['LANDSCAPE'], x: 0, y: -100, width: 250, height: 200 },
            { type: DocumentType.RTF, message: '[placeholder] lengthy caption', acceptTags: ['paragraphs'], x: 0, y: 138, width: 250, height: 172 },
            { type: DocumentType.RTF, message: '[placeholder] brief description', acceptTags: ['sentence'], x: 280, y: -50, width: 50, height: 200 },
            { type: DocumentType.IMG, message: '[placeholder] person', acceptTags: ['PERSON'], x: -200, y: -100, width: 167, height: 200 },
        ];
    }

    private static createGalleryPreset(): ScrapbookItemConfig[] {
        return [
            { type: DocumentType.IMG, message: 'Gallery 1 <drop person images into the gallery!>', acceptTags: ['PERSON'], x: -150, y: -150, width: 150, height: 150 },
            { type: DocumentType.IMG, message: 'Gallery 2', acceptTags: ['PERSON'], x: 0, y: -150, width: 150, height: 150 },
            { type: DocumentType.IMG, message: 'Gallery 3', acceptTags: ['PERSON'], x: 150, y: -150, width: 150, height: 150 },
            { type: DocumentType.IMG, message: 'Gallery 4', acceptTags: ['PERSON'], x: -150, y: 0, width: 150, height: 150 },
            { type: DocumentType.IMG, message: 'Gallery 5', acceptTags: ['PERSON'], x: 0, y: 0, width: 150, height: 150 },
            { type: DocumentType.IMG, message: 'Gallery 6', acceptTags: ['PERSON'], x: 150, y: 0, width: 150, height: 150 },
        ];
    }

    private static createDefaultPreset(): ScrapbookItemConfig[] {
        return [
            { type: DocumentType.IMG, message: 'drop a landscape image',   acceptTags: ['LANDSCAPE'],  x:    44, y: -50, width: 200, height: 120 },
            { type: DocumentType.PDF, message: 'summary pdf', acceptTags: ['word', 'sentence', 'paragraphs'],   x:    45, y: 93,  width: 184, height: 273 },
            { type: DocumentType.RTF, message: 'sidebar text', acceptTags: ['paragraphs'], x:  250, y: -50,  width:  100, height: 200 },
            { containerWidth: 200, containerHeight: 425,                              x: -171, y: -54, width: 200, height: 425,
              children: [{ type: DocumentType.IMG, message: 'drop a person image', acceptTags: ['PERSON'], x: -350, y: 200, width: 162, height: 137 }], },
        ]; // prettier-ignore
    }

    private static createCollagePreset(): ScrapbookItemConfig[] {
        return [
            { type: DocumentType.IMG, message: 'landscape image',           acceptTags: ['LANDSCAPE'],  x: -174, y: 100, width: 160, height: 150 },
            { type: DocumentType.IMG, message: 'person image',              acceptTags: ['PERSON'],     x:    0, y: 100, width: 150, height: 150 },
            { type: DocumentType.RTF, message: 'caption',             acceptTags: ['sentence'],   x: -174, y:    50, width: 150, height: 40 },
            { type: DocumentType.RTF, message: 'caption', acceptTags: ['sentence'],   x: 0, y:    50, width: 150, height: 40 },
            { type: DocumentType.RTF, message: 'lengthy description', acceptTags: ['paragraphs'], x:   -180,  y:  -60, width: 350, height: 100 },
        ]; // prettier-ignore
    }

    private static createSpotlightPreset(): ScrapbookItemConfig[] {
        return [
            { type: DocumentType.RTF, message: 'title text', acceptTags: ['word'], x: 0, y: -30, width: 300, height: 40 },
            { type: DocumentType.IMG, message: 'drop a landscape image', acceptTags: ['LANDSCAPE'], x: 0, y: 20, width: 300, height: 200 },
            { type: DocumentType.RTF, message: 'caption text', acceptTags: ['sentence'], x: 0, y: 230, width: 300, height: 50 },
        ];
    }
}