s_skaidocsTài liệu

Schema config chuẩn của theme · v1

Schema chuẩn gồm 111 key, do hệ thống quản lý trong modules/themeconfig/standard.json. Mọi theme đều nhận schema này khi mở cấu hình và khi render. Theme không cần sao chép schema chuẩn.

File và cấu trúc

Chỉ có thư mục config/; các file nằm phẳng:

  • config/config_schema.json: default của key chuẩn và định nghĩa field riêng của theme.
  • config/config_data.json: giá trị user đã lưu.
  • config/theme.json: thông tin theme hiện có, không thay bằng bộ schema này.
  • config/nav-{key}.json: profile navigation riêng, tiếp tục giữ cơ chế hiện có.

Phiên bản schema chuẩn là 1 trong mã hệ thống. Không thêm trường version vào config_schema.json/config_data.json vì hai file này là map key → field/value.

Schema bất biến

Field chuẩn có type, label, group, standard_config=1, locked=true và translatable do hệ thống quy định. Theme chỉ được bổ sung default cho field chuẩn. Các thuộc tính type, locked, fallback, css_variable của theme không thay thế định nghĩa chuẩn. Xóa một key chuẩn khỏi file theme không xóa key đó khỏi schema có hiệu lực. Không có API xóa schema hệ thống. Field riêng vẫn khai báo bình thường và không được dùng trùng key chuẩn để đổi kiểu.

Thứ tự ưu tiên

1. Thiết kế riêng của element hoặc profile menu đã lưu.

2. config_data.json của website.

3. Default trong config_schema.json của theme.

4. Key fallback chuẩn, ví dụ button_radius → border_radius.

5. Default của element, nằm trong fallback CSS var.

Giá trị trống/null không tạo biến CSS riêng; 0 và false vẫn có ý nghĩa. User đổi theme config thì preview render lại và các element đang theo theme nhận giá trị mới. Không copy màu/font đã tính ra vào JSON của element.

Config thiết kế phát ra CSS variables --skai-{key-với-dấu-gạch-ngang}. Số của key kích thước có css_unit=px được chuyển sang px; line-height không tự thêm px. Font là CSS font-family; theme tự cung cấp font-face/stylesheet, hệ thống không tự tải font từ mạng.

Ví dụ schema theme

Ví dụ
{
  "primary_color": {"default": "#f46b16"},
  "border_radius": {"default": 8},
  "body_font": {"default": "Inter, system-ui, sans-serif"},
  "brand_story": {"type": "textarea", "label": "Câu chuyện thương hiệu", "group": "Riêng của theme", "default": ""}
}

Ví dụ giá trị user

Ví dụ
{
  "primary_color": "#14532d",
  "on_primary_color": "#ffffff",
  "button_radius": "12px",
  "body_font_size": "16px",
  "h1_font_size": "48px",
  "h1_font_size_mobile": "30px",
  "logo": {"src": "/assets/logo.svg", "alt": "Tên thương hiệu"},
  "site_name": "t:brand.name"
}

Element hệ thống và thiết kế riêng

Tất cả 104 định nghĩa element hệ thống đã có liên kết font chuẩn. Những thuộc tính màu, bo góc, khoảng cách, chữ và bóng có vai trò tương ứng được nối với token chuẩn, giữ fallback của element. Button mặc định dùng button_primary_background → primary_color và button_primary_color → on_primary_color. Button theo kiểu có tone primary/secondary dùng token của tone đó. Kiểu chữ tiêu đề có key riêng cho H1–H6 và tablet/mobile.

Logo lấy configs.logo khi chưa có ảnh riêng và logo_source=theme. Chọn logo_source=custom để dùng riêng, kể cả khi muốn để trống. Link, ảnh hoặc nội dung đã nhập riêng vẫn được giữ.

Trong tab Thiết kế, thuộc tính dùng token hiển thị nhãn Theo theme. Nhập giá trị mới tạo override riêng. Nhấn ↺ để bỏ override và trở lại default kế thừa của element. Responsive giữ thứ tự desktop → tablet → mobile như hiện tại.

Các preset mới trong thư viện dùng token thay cho những giá trị mẫu mang vai trò giao diện chung. Page/layout JSON cũ không bị sửa tự động: không thể phân biệt chắc chắn màu mẫu cũ và màu user chủ ý chọn. Muốn chuyển một thuộc tính cũ sang theo theme, reset thuộc tính đó hoặc đổi sang CSS var có fallback.

Custom element và theme code

Ví dụ
.my-primary-button {
  background: var(--skai-button-primary-background, #6d28d9);
  color: var(--skai-button-primary-color, #ffffff);
  border-radius: var(--skai-button-radius, 6px);
  font-family: var(--skai-body-font, inherit);
}

Trong layout HTML cần có {{ head_content }} để nhận biến CSS; trang Visual được engine thêm biến trực tiếp vào style render. Custom element có thể khai báo cùng biểu thức var trong default_styles. User styles vẫn ghi đè default_styles.

Key header/footer chỉ áp dụng khi template gắn đúng vai trò đó. Không gắn màu footer vào mọi Menu dọc vì Menu dọc còn dùng ở sidebar. Key liên hệ, mạng xã hội và SEO là dữ liệu chuẩn để theme dùng qua configs; chúng không tự chèn nội dung, tạo menu hoặc thay markup SEO. Xem Object configs để đọc dữ liệu trong Lingo. Cơ chế fallback của CSS variables không tự thay toàn bộ các giá trị thô trong object configs.

Tương thích và đa ngôn ngữ

Giữ tên key đang dùng như primary_color, secondary_color, body_font, heading_font, border_radius. site_name đọc thêm name hoặc site_title khi chưa có giá trị chuẩn. Alias không ghi đè dữ liệu cũ. Các file legacy settings_schema.json/settings_data.json/setting_data.json vẫn được đọc theo quy tắc tương thích hiện có.

Nội dung văn bản hỗ trợ tham chiếu t: theo locale đang render. Màu sắc, kích thước và font không dịch. logo_dark/logo_mobile là các nguồn tùy chọn để theme chọn theo bố cục; element Logo mặc định dùng logo.

Danh sách key chuẩn

KeyKiểuNhóm / ý nghĩaKế thừaĐơn vị CSS
site_nametextThương hiệu · Tên websiteDefault element / theme—
taglinetextThương hiệu · Khẩu hiệuDefault element / theme—
logoimageThương hiệu · LogoDefault element / theme—
logo_darkimageThương hiệu · Logo nền tốiDefault element / theme—
logo_mobileimageThương hiệu · Logo mobileDefault element / theme—
faviconimageThương hiệu · FaviconDefault element / theme—
primary_colorcolorMàu sắc · Màu chủ đạoDefault element / theme—
secondary_colorcolorMàu sắc · Màu phụDefault element / theme—
accent_colorcolorMàu sắc · Màu nhấnDefault element / theme—
on_primary_colorcolorMàu sắc · Chữ trên màu chủ đạoDefault element / theme—
on_secondary_colorcolorMàu sắc · Chữ trên màu phụDefault element / theme—
on_accent_colorcolorMàu sắc · Chữ trên màu nhấnDefault element / theme—
background_colorcolorMàu sắc · Nền trangDefault element / theme—
surface_colorcolorMàu sắc · Nền bề mặtDefault element / theme—
text_colorcolorMàu sắc · Chữ nội dungDefault element / theme—
muted_text_colorcolorMàu sắc · Chữ phụDefault element / theme—
heading_colorcolorMàu sắc · Chữ tiêu đềtext_color—
border_colorcolorMàu sắc · Màu viềnDefault element / theme—
success_colorcolorMàu sắc · Thành côngDefault element / theme—
warning_colorcolorMàu sắc · Cảnh báoDefault element / theme—
error_colorcolorMàu sắc · LỗiDefault element / theme—
info_colorcolorMàu sắc · Thông tinDefault element / theme—
body_fonttextKiểu chữ · Font nội dungDefault element / theme—
heading_fonttextKiểu chữ · Font tiêu đềbody_font—
body_font_sizetextKiểu chữ · Cỡ chữ nội dungDefault element / themepx
body_line_heighttextKiểu chữ · Chiều cao dòng nội dungDefault element / theme—
heading_line_heighttextKiểu chữ · Chiều cao dòng tiêu đềDefault element / theme—
body_font_weighttextKiểu chữ · Độ đậm nội dungDefault element / theme—
heading_font_weighttextKiểu chữ · Độ đậm tiêu đềbody_font_weight—
h1_font_sizetextKiểu chữ · Cỡ H1 · DesktopDefault element / themepx
h1_font_size_tablettextKiểu chữ · Cỡ H1 · Tableth1_font_sizepx
h1_font_size_mobiletextKiểu chữ · Cỡ H1 · Mobileh1_font_size_tabletpx
h2_font_sizetextKiểu chữ · Cỡ H2 · DesktopDefault element / themepx
h2_font_size_tablettextKiểu chữ · Cỡ H2 · Tableth2_font_sizepx
h2_font_size_mobiletextKiểu chữ · Cỡ H2 · Mobileh2_font_size_tabletpx
h3_font_sizetextKiểu chữ · Cỡ H3 · DesktopDefault element / themepx
h3_font_size_tablettextKiểu chữ · Cỡ H3 · Tableth3_font_sizepx
h3_font_size_mobiletextKiểu chữ · Cỡ H3 · Mobileh3_font_size_tabletpx
h4_font_sizetextKiểu chữ · Cỡ H4 · DesktopDefault element / themepx
h4_font_size_tablettextKiểu chữ · Cỡ H4 · Tableth4_font_sizepx
h4_font_size_mobiletextKiểu chữ · Cỡ H4 · Mobileh4_font_size_tabletpx
h5_font_sizetextKiểu chữ · Cỡ H5 · DesktopDefault element / themepx
h5_font_size_tablettextKiểu chữ · Cỡ H5 · Tableth5_font_sizepx
h5_font_size_mobiletextKiểu chữ · Cỡ H5 · Mobileh5_font_size_tabletpx
h6_font_sizetextKiểu chữ · Cỡ H6 · DesktopDefault element / themepx
h6_font_size_tablettextKiểu chữ · Cỡ H6 · Tableth6_font_sizepx
h6_font_size_mobiletextKiểu chữ · Cỡ H6 · Mobileh6_font_size_tabletpx
container_widthtextBố cục · Rộng khung nội dungDefault element / themepx
container_paddingtextBố cục · Đệm khung nội dungDefault element / themepx
section_spacingtextBố cục · Khoảng cách sectionDefault element / themepx
element_gaptextBố cục · Khoảng cách elementDefault element / themepx
grid_gaptextBố cục · Khoảng cách lướiDefault element / themepx
border_radiusnumberViền và bóng · Bo góc (px)Default element / themepx
border_radius_smallnumberViền và bóng · Bo góc nhỏ (px)border_radiuspx
border_radius_largenumberViền và bóng · Bo góc lớn (px)border_radiuspx
border_widthnumberViền và bóng · Dày viền (px)Default element / themepx
shadow_smalltextViền và bóng · Đổ bóng nhỏDefault element / theme—
shadow_mediumtextViền và bóng · Đổ bóng vừaDefault element / theme—
shadow_largetextViền và bóng · Đổ bóng lớnDefault element / theme—
button_font_weighttextNút bấm · Độ đậm chữ nútbody_font_weight—
button_padding_xtextNút bấm · Đệm ngang nútDefault element / themepx
button_padding_ytextNút bấm · Đệm dọc nútDefault element / themepx
button_radiustextNút bấm · Bo góc nútborder_radiuspx
button_primary_backgroundcolorNút bấm · Nền · primaryprimary_color—
button_primary_colorcolorNút bấm · Chữ · primaryon_primary_color—
button_primary_hover_backgroundcolorNút bấm · Nền hover · primarybutton_primary_background—
button_primary_hover_colorcolorNút bấm · Chữ hover · primarybutton_primary_color—
button_secondary_backgroundcolorNút bấm · Nền · secondarysecondary_color—
button_secondary_colorcolorNút bấm · Chữ · secondaryon_secondary_color—
button_secondary_hover_backgroundcolorNút bấm · Nền hover · secondarybutton_secondary_background—
button_secondary_hover_colorcolorNút bấm · Chữ hover · secondarybutton_secondary_color—
link_colorcolorLiên kết · Màu linkprimary_color—
link_hover_colorcolorLiên kết · Màu link hoverlink_color—
link_underlinecheckboxLiên kết · Gạch chân linkDefault element / theme—
input_backgroundcolorForm · Nền inputsurface_color—
input_colorcolorForm · Chữ inputtext_color—
input_border_colorcolorForm · Viền inputborder_color—
input_focus_colorcolorForm · Viền focusprimary_color—
input_radiustextForm · Bo góc inputborder_radiuspx
input_padding_xtextForm · Đệm ngang inputDefault element / themepx
input_padding_ytextForm · Đệm dọc inputDefault element / themepx
card_backgroundcolorCard · Nền cardsurface_color—
card_border_colorcolorCard · Viền cardborder_color—
card_radiustextCard · Bo góc cardborder_radiuspx
card_shadowtextCard · Bóng cardshadow_small—
card_paddingtextCard · Đệm cardDefault element / themepx
header_backgroundcolorHeader · Nền headerbackground_color—
header_text_colorcolorHeader · Chữ headertext_color—
header_heighttextHeader · Cao headerDefault element / themepx
header_logo_widthtextHeader · Rộng logo headerDefault element / themepx
footer_backgroundcolorFooter · Nền footersurface_color—
footer_text_colorcolorFooter · Chữ footertext_color—
footer_heading_colorcolorFooter · Tiêu đề footerheading_color—
footer_link_colorcolorFooter · Link footerlink_color—
footer_link_hover_colorcolorFooter · Link footer hoverlink_hover_color—
emailtextLiên hệ · EmailDefault element / theme—
phonetextLiên hệ · Điện thoạiDefault element / theme—
working_hourstextLiên hệ · Giờ làm việcDefault element / theme—
addresstextareaLiên hệ · Địa chỉDefault element / theme—
map_urlurlLiên hệ · URL bản đồDefault element / theme—
facebookurlMạng xã hội · FacebookDefault element / theme—
instagramurlMạng xã hội · InstagramDefault element / theme—
youtubeurlMạng xã hội · YoutubeDefault element / theme—
tiktokurlMạng xã hội · TiktokDefault element / theme—
linkedinurlMạng xã hội · LinkedinDefault element / theme—
zalourlMạng xã hội · ZaloDefault element / theme—
seo_titletextSEO · Tiêu đề SEO mặc địnhDefault element / theme—
seo_descriptiontextareaSEO · Mô tả SEO mặc địnhDefault element / theme—
social_imageimageSEO · Ảnh chia sẻDefault element / theme—
transition_durationtextChuyển động · Thời gian chuyển độngDefault element / theme—
transition_easingtextChuyển động · Nhịp chuyển độngDefault element / theme—

Kiểm thử khi thay đổi schema

  • Sửa primary_color hai lần: nút theo theme đổi theo, nút có backgroundColor riêng giữ nguyên.
  • Theme thiếu config: default element vẫn render đúng.
  • border_radius=0 và link_underline=false không bị coi là trống.
  • Theme khai báo primary_color là html: schema có hiệu lực vẫn là color.
  • Lưu rồi tải lại: JSON element không bị ghi màu/font đã resolve.
  • Logo riêng không bị configs.logo thay thế.
  • Kiểm tra font và H1–H6 trên ba breakpoint.
  • Mỗi lần thêm key cần cập nhật standard.json, tài liệu và test. Không đổi nghĩa key cũ âm thầm.