summaryrefslogtreecommitdiff
path: root/frontend/app/views/tile/forms/tile.constructors.js
blob: 24072748e1870aa580f94285f47232bff8161b72 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const newImage = (data) => ({
  settings: {
    ...newPosition(),
    is_tiled: false,
    tile_style: 'tile',
    url: "",
    external_link_url: "",
    cursor: 'hand_up',
  },
  type: 'image',
  target_page_id: 0,
  ...data,
})

const newVideo = (data) => ({
  settings: {
    ...newPosition(),
    video_style: 'cover',
    url: "",
    external_link_url: "",
    cursor: 'none',
    muted: false,
    loop_style: false,
    autoadvance: false,
    loop_section: false,
    loop_start: 0,
    loop_end: 0,
  },
  type: 'video',
  target_page_id: 0,
  ...data,
})

const newText = (data) => ({
  settings: {
    ...newPosition(),
    content: "",
    font_family: 'sans-serif',
    font_size: 16,
    font_style: 'normal',
    font_color: '#dddddd',
    background_color: 'transparent',
    width: 0,
    height: 0,
    units: 'px',
    external_link_url: "",
    cursor: 'hand_up',
  },
  type: 'text',
  target_page_id: 0,
  ...data,
})

const newGradient = (data) => ({
  settings: {
    ...newPosition({ width: 100, height: 100 }),
    from_color: '#ffffff',
    from_opacity: 1.0,
    to_color: '#000000',
    to_opacity: 1.0,
    angle: 0,
    stop: 50,
    units: '%',
    external_link_url: "",
    cursor: 'hand_up',
  },
  type: 'gradient',
  target_page_id: 0,
  ...data,
})

const newLink = (data) => ({
  settings: {
    ...newPosition({ width: 100, height: 100, }),
    external_link_url: "",
    cursor: 'hand_up',
    units: 'px',
  },
  type: 'link',
  target_page_id: 0,
  ...data,
})

const newScript = (data) => ({
  settings: {
    ...newPosition({ width: 100, height: 100, }),
  },
  type: 'script',
  ...data,
})

const newPosition = (data) => ({
  x: 0, y: 0,
  width: 0, height: 0,
  rotation: 0, scale: 1,
  opacity: 1,
  units: false,
  align: "center_center",
  has_audio: false,
  audio_on_click_id: 0,
  audio_on_hover_id: 0,
  navigate_when_audio_finishes: false,
  ...data,
})

export const TILE_CONSTRUCTORS = {
  image: newImage,
  video: newVideo,
  text: newText,
  link: newLink,
  gradient: newGradient,
  script: newScript,
}