Skip to content

Commit f7d4f5c

Browse files
committed
feat: add logo_scale and logo_offset_y params to brand-showcase layout
1 parent 94dd9bb commit f7d4f5c

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

server/handlers/seed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func SeedBrands() {
7171
{"goha-corporate", "GOHA Corporate", "goha", "split-left", "og-image", map[string]string{"title": "Corporate Solutions", "subtitle": "Strategic Growth Partner", "bg_color": "#0f1629", "title_color": "#FFD700", "subtitle_color": "#FFFFFF"}},
7272
{"goha-minimal", "GOHA Minimal", "goha", "text-only", "ig-post", map[string]string{"title": "Simple. Elegant. Effective.", "bg_color": "#1a1a3e", "title_color": "#FFFFFF", "subtitle_color": "#FFD700"}},
7373
{"goha-professional", "GOHA Professional", "goha", "overlay-center", "yt-thumbnail", map[string]string{"title": "Professional Excellence", "subtitle": "Building Trust Through Quality", "bg_color": "#1a1a3e", "title_color": "#FFD700", "subtitle_color": "#FFFFFF", "overlay": "dark", "bg_image": "/brands/goha/bg/default-background.png"}},
74-
{"trungnguyen-showcase", "Trung Nguyên Showcase", "trungnguyen", "brand-showcase", "ig-post", map[string]string{"title": "Robot Máy Ép Nhựa – Xu Hướng Tự Động Hóa Ngành Nhựa", "cta_text": "XEM NGAY", "footer_text": "0986 403 790 – 098 210 3223\ndinhduong@trungnguyentw.com\ntrungnguyentw.com", "accent_color": "#fc7400", "title_color": "#FFFFFF", "frame_image": "/brands/trungnguyen/frame_left.png", "feature_image": "/brands/trungnguyen/sample_cover_2.jpg"}},
74+
{"trungnguyen-showcase", "Trung Nguyên Showcase", "trungnguyen", "brand-showcase", "ig-post", map[string]string{"title": "Robot Máy Ép Nhựa – Xu Hướng Tự Động Hóa Ngành Nhựa", "cta_text": "XEM NGAY", "footer_text": "0986 403 790 – 098 210 3223\ndinhduong@trungnguyentw.com\ntrungnguyentw.com", "accent_color": "#fc7400", "title_color": "#FFFFFF", "frame_image": "/brands/trungnguyen/frame_left.png", "feature_image": "/brands/trungnguyen/sample_cover_2.jpg", "logo_scale": "1.5", "logo_offset_y": "60"}},
7575
{"trungnguyen-inner-frame", "Trung Nguyên Inner Frame", "trungnguyen", "inner-frame", "ig-post", map[string]string{"feature_image": "/brands/trungnguyen/inner-frame-default-v2.jpg", "frame_image": "/brands/trungnguyen/bottom-frame.png", "title": "0986 403 790 – 098 210 3223", "subtitle": "trungnguyentw.com"}},
7676
}
7777

server/layouts/brand_showcase.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package layouts
33
import (
44
"fmt"
55
"math"
6+
"strconv"
67
"strings"
78

89
"snapkit/engine"
@@ -22,6 +23,8 @@ func brandShowcase() *BuiltinLayout {
2223
{Key: "feature_image", Type: "image", Label: "Feature Image", Required: true, Searchable: true},
2324
{Key: "frame_image", Type: "image", Label: "Frame Overlay Image"},
2425
{Key: "accent_color", Type: "color", Label: "Accent/CTA Color"},
26+
{Key: "logo_scale", Type: "text", Label: "Logo Scale (e.g. 1.5)"},
27+
{Key: "logo_offset_y", Type: "text", Label: "Logo Y Offset (px)"},
2528
},
2629
},
2730
Render: func(p *engine.RenderParams) string {
@@ -58,10 +61,31 @@ func brandShowcase() *BuiltinLayout {
5861
logoPosStyle = logoPosMap["top-left"]
5962
}
6063

64+
// Logo scale and vertical offset
65+
logoScale := 1.0
66+
if v := p.Get("logo_scale"); v != "" {
67+
if f, err := strconv.ParseFloat(v, 64); err == nil && f > 0 {
68+
logoScale = f
69+
}
70+
}
71+
logoOffsetY := 0
72+
if v := p.Get("logo_offset_y"); v != "" {
73+
if n, err := strconv.Atoi(v); err == nil {
74+
logoOffsetY = r(float64(n))
75+
}
76+
}
77+
6178
logoHTML := ""
6279
if safeLogo != "" {
63-
logoHTML = fmt.Sprintf(`<img src="%s" alt="" style="position:absolute;%s;height:%dpx;max-width:%dpx;object-fit:contain;z-index:3;" onerror="this.style.display='none'" />`,
64-
safeLogo, logoPosStyle, r(100), int(math.Round(float64(w)*0.4)))
80+
logoH := int(math.Round(float64(r(100)) * logoScale))
81+
logoMaxW := int(math.Round(float64(w) * 0.4 * logoScale))
82+
// Apply vertical offset by adding margin-top
83+
offsetStyle := ""
84+
if logoOffsetY != 0 {
85+
offsetStyle = fmt.Sprintf("margin-top:%dpx;", logoOffsetY)
86+
}
87+
logoHTML = fmt.Sprintf(`<img src="%s" alt="" style="position:absolute;%s;height:%dpx;max-width:%dpx;object-fit:contain;z-index:3;%s" onerror="this.style.display='none'" />`,
88+
safeLogo, logoPosStyle, logoH, logoMaxW, offsetStyle)
6589
}
6690

6791
ctaHTML := ""

sync-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ upsert_template "trungnguyen-showcase" \
5252
"trungnguyen" \
5353
"brand-showcase" \
5454
"ig-post" \
55-
'{"title":"Robot Máy Ép Nhựa – Xu Hướng Tự Động Hóa Ngành Nhựa","cta_text":"XEM NGAY","footer_text":"0986 403 790 – 098 210 3223\ndinhduong@trungnguyentw.com\ntrungnguyentw.com","accent_color":"#fc7400","title_color":"#FFFFFF","frame_image":"/brands/trungnguyen/frame_left.png","feature_image":"/brands/trungnguyen/sample_cover_2.jpg"}'
55+
'{"title":"Robot Máy Ép Nhựa – Xu Hướng Tự Động Hóa Ngành Nhựa","cta_text":"XEM NGAY","footer_text":"0986 403 790 – 098 210 3223\ndinhduong@trungnguyentw.com\ntrungnguyentw.com","accent_color":"#fc7400","title_color":"#FFFFFF","frame_image":"/brands/trungnguyen/frame_left.png","feature_image":"/brands/trungnguyen/sample_cover_2.jpg","logo_scale":"1.5","logo_offset_y":"60"}'
5656

5757
echo "=== Done ==="

0 commit comments

Comments
 (0)