Skip to content

Commit a4b2838

Browse files
authored
Merge pull request #7 from rocketbase-io/feat-object-fit
add image object-fit config
2 parents 9407f5c + 06539ce commit a4b2838

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

email-template-builder/src/main/java/io/rocketbase/mail/config/TbConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class TbConfiguration {
1111
static final TbConfiguration DEFAULT = new TbConfiguration(true, TbFontConfig.newInstance(),
1212
TbTextConfig.newInstance(),
1313
TbTextConfig.newInstanceSmall(),
14+
TbSideImageLineConfig.newInstance(),
1415
TbButtonConfig.newInstance(),
1516
TbAttributeConfig.newInstance(),
1617
TbBoxConfig.newInstance(),
@@ -28,6 +29,7 @@ public static final TbConfiguration newInstance() {
2829
private TbFontConfig font;
2930
private TbTextConfig text;
3031
private TbTextConfig imageText;
32+
private TbSideImageLineConfig sideImageLine;
3133
private TbButtonConfig button;
3234
private TbAttributeConfig attribute;
3335
private TbBoxConfig box;
@@ -41,6 +43,7 @@ public TbConfiguration(TbConfiguration other) {
4143
this.font = new TbFontConfig(other.font);
4244
this.text = new TbTextConfig(other.text);
4345
this.imageText = new TbTextConfig(other.imageText);
46+
this.sideImageLine = new TbSideImageLineConfig(other.sideImageLine);
4447
this.button = new TbButtonConfig(other.button);
4548
this.attribute = new TbAttributeConfig(other.attribute);
4649
this.box = new TbBoxConfig(other.box);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.rocketbase.mail.config.config;
2+
3+
import io.rocketbase.mail.styling.ObjectFit;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
7+
@Data
8+
@AllArgsConstructor
9+
public class TbSideImageLineConfig {
10+
11+
static final TbSideImageLineConfig DEFAULT = new TbSideImageLineConfig(ObjectFit.NONE);
12+
13+
private ObjectFit objectFit;
14+
15+
public TbSideImageLineConfig(TbSideImageLineConfig other) {
16+
this.objectFit = other.objectFit;
17+
}
18+
19+
public static TbSideImageLineConfig newInstance() {
20+
return new TbSideImageLineConfig(DEFAULT);
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.rocketbase.mail.styling;
2+
3+
import lombok.Getter;
4+
5+
public enum ObjectFit {
6+
CONTAIN("contain"),
7+
COVER("cover"),
8+
FILL("fill"),
9+
INHERENT("inherent"),
10+
INITIAL("initial"),
11+
NONE("none"),
12+
REVERT("revert"),
13+
REVERT_LAYER("revert-layer"),
14+
SCALE_DOWN("scale-down"),
15+
UNSET("unset");
16+
17+
@Getter
18+
private String value;
19+
20+
ObjectFit(String value) {
21+
this.value = value;
22+
}
23+
}

email-template-builder/src/main/resources/templates/email/layout.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@
261261
line-height: {{ c.imageText.lineHeight | default('1.325') }};
262262
}
263263

264+
.body-gallery img,
265+
.body-side-image img {
266+
object-fit: {{ c.sideImageLine.objectFit | default('none') }};
267+
}
268+
264269
.body-sub {
265270
margin-top: 25px;
266271
padding-top: 25px;
@@ -387,6 +392,9 @@
387392
<td class="attributes_item" {% if line.valueWidth is not empty %} width="{{- line.valueWidth -}}" {% endif %} style="color: {{ c.font.table.color | default('#333333') }}; font-family: {{ c.font.family | default("'Nunito Sans', Helvetica, Arial, sans-serif") | raw }}; font-size: {{ c.font.table.size | default('16px') }}; padding: 0; word-break: break-word;" valign="top">
388393
<span class="f-fallback">{{entry.value | escape}}</span>
389394
</td>
395+
396+
397+
390398
</tr>
391399
{% endfor %}
392400
</table>

0 commit comments

Comments
 (0)