-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPage.fusion
223 lines (201 loc) · 9.91 KB
/
Page.fusion
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
prototype(Garagist.Mjml:Presentation.Page) < prototype(Neos.Fusion:Component) {
@propTypes {
compile = ${PropTypes.boolean}
owa = ${PropTypes.oneOf(['desktop'])}
dir = ${PropTypes.string}
lang = ${PropTypes.string}
backgroundColor = ${PropTypes.string}
cssClass = ${${PropTypes.anyOf( PropTypes.string, PropTypes.arrayOf( PropTypes.string ) )}}
width = ${PropTypes.integer}
title = ${PropTypes.string}
attributes = ${PropTypes.string}
preview = ${PropTypes.string}
breakpoint = ${PropTypes.string}
head = ${PropTypes.string}
content = ${PropTypes.string.isRequired}
debugUrl = ${PropTypes.string}
trackingPixel = ${PropTypes.string}
}
@styleguide.props {
title = 'Hello World Page'
preview = 'Hello World'
content = afx`
<mj-section>
<mj-column>
<mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>
<mj-divider border-color="#F45E43"></mj-divider>
</mj-column>
</mj-section>
`
}
# Compile the MJML to HTML
compile = ${!!Configuration.Setting('Garagist.Mjml.apiEndpoint')}
# If set to "desktop", switch force desktop version for older (self-hosted) version of Outlook.com that doesn't support media queries
owa = null
# Used as <html lang=""> attribute
lang = null
# Used as <html dir=""> attribute
dir = null
# The general background color (color formats)
backgroundColor = null
# Class name, added to the root HTML element created
cssClass = null
# Email's width in px
width = 600
# Defines the document's title that browsers show in the title bar or a page's tab.
title = null
# This allows you to set the preview that will be displayed in the inbox of the recipient.
# If you use Garagist.Mautic, there is no need to set this, as it will be set automatically
preview = null
# https://documentation.mjml.io/#mj-attributes
attributes = null
# https://documentation.mjml.io/#mj-html-attributes
htmlAttributes = null
# This allows you to control on which breakpoint the layout should go desktop/mobile. Integer value in pixels.
breakpoint = null
# The head section of the email
head = null
# The content section of the email
content = null
# Add the markup for the tracking pixel
# If you use Garagist.Mautic, there is no need to set this, as it will be set automatically
trackingPixel = ${Configuration.Setting('Garagist.Mjml.trackingPixel')}
# Debug url for logging
debugUrl = null
defaults = ${Configuration.Setting('Garagist.Mjml.theme.defaults')}
colors = ${Configuration.Setting('Garagist.Mjml.theme.colors')}
fontSize = ${Configuration.Setting('Garagist.Mjml.theme.fontSize')}
fontWeight = ${Configuration.Setting('Garagist.Mjml.theme.fontWeight')}
renderer = Neos.Fusion:Http.Message {
httpResponseHead.headers.'Content-Type' = 'text/html'
content = afx`
<mjml
owa={props.owa}
lang={props.lang}
dir={props.dir}
@process.compile={props.compile ? Mjml.compile(value, props.debugUrl) : value}
>
<mj-head>
<mj-title @if={props.title} css-class="headline">{props.title}</mj-title>
<mj-preview @if={props.preview}>{props.preview}</mj-preview>
<mj-attributes>
{props.attributes}
<Neos.Fusion:Loop
@if={Carbon.Array.check(props.defaults)}
items={props.defaults}
>
{'<mj-all '}{itemKey}="{item}"{' />'}
</Neos.Fusion:Loop>
<Neos.Fusion:Loop
@if={Carbon.Array.check(props.fontSize)}
items={props.fontSize}
>
<mj-class @if={!Type.isArray(item)} name={"text-" + itemKey} font-size={item + 'px'} />
<mj-class @if={Type.isArray(item)} name={"text-" + itemKey} font-size={item.pixel + 'px'} line-height={item.lineHeight} />
</Neos.Fusion:Loop>
<Neos.Fusion:Loop
@if={Carbon.Array.check(props.fontWeight)}
items={props.fontWeight}
>
<mj-class name={"font-" + itemKey} font-weight={item} />
</Neos.Fusion:Loop>
<Neos.Fusion:Loop
@if={Carbon.Array.check(props.colors)}
items={props.colors}
itemName="main"
itemKey="mainKey"
>
<mj-class
@if={Type.isString(main)}
name={"text-" + mainKey}
color={main}
/>
<mj-class
@if={Type.isString(main)}
name={"bg-" + mainKey}
background-color={main}
/>
<mj-class
@if={Type.isString(main)}
name={"container-bg-" + mainKey}
container-background-color={main}
/>
<mj-class
@if={Type.isString(main)}
name={"inner-bg-" + mainKey}
inner-background-color={main}
/>
<Neos.Fusion:Loop @if={Carbon.Array.check(main)} items={main}>
<mj-class
@if={Type.isString(item) && itemKey != 'DEFAULT'}
name={"text-" + mainKey + "-" + itemKey}
color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey == 'DEFAULT'}
name={"text-" + mainKey}
color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey != 'DEFAULT'}
name={"bg-" + mainKey + "-" + itemKey}
background-color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey == 'DEFAULT'}
name={"bg-" + mainKey}
background-color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey != 'DEFAULT'}
name={"container-bg-" + mainKey + "-" + itemKey}
container-background-color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey == 'DEFAULT'}
name={"container-bg-" + mainKey}
container-background-color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey != 'DEFAULT'}
name={"inner-bg-" + mainKey + "-" + itemKey}
inner-background-color={item}
/>
<mj-class
@if={Type.isString(item) && itemKey == 'DEFAULT'}
name={"inner-bg-" + mainKey}
inner-background-color={item}
/>
</Neos.Fusion:Loop>
</Neos.Fusion:Loop>
</mj-attributes>
<mj-html-attributes @if={props.htmlAttributes && Type.isString(props.htmlAttributes)}>{props.htmlAttributes}</mj-html-attributes>
<mj-html-attributes @if={Carbon.Array.check(props.htmlAttributes)}>
<Neos.Fusion:Loop items={props.htmlAttributes}>
<mj-selector path={itemKey}>
<Neos.Fusion:Loop items={item}>
<mj-html-attribute name={itemKey}>{item}</mj-html-attribute>
</Neos.Fusion:Loop>
</mj-selector>
</Neos.Fusion:Loop>
</mj-html-attributes>
<Neos.Fusion:Loop @if={Carbon.Array.check(props.font)} items={props.font}>
<mj-font name={itemKey} href={item} />
</Neos.Fusion:Loop>
<mj-breakpoint @if={props.breakpoint}>{props.breakpoint}px</mj-breakpoint>
{props.head}
</mj-head>
<mj-body
background-color={props.backgroundColor}
css-class={Carbon.String.merge(props.cssClass)}
width={props.width ? props.width + 'px' : null}
>
{props.content}
<mj-raw @if={props.trackingPixel}>
{props.trackingPixel}
</mj-raw>
</mj-body>
</mjml>
`
}
}