Files
cms-SiteForge/app/static/studio-experience-v829.js
T

47 lines
2.4 KiB
JavaScript
Raw Normal View History

/* SiteForge V8.29: presentation-only studio helpers. No persisted-schema changes. */
'use strict';
(function(root){
const themes=new Set(['automotive','industrial','corporate','minimal']);
const pages=new Set(['home','listing','product','article','about','contact']);
const categories={
visual:new Set(['hero','banner','carousel','gallery','image','image_text','image-grid','video','slider']),
business:new Set(['collection','products','product_list','brand_wall','brands','features','stats','testimonials','faq','contact','form','cta','map']),
advanced:new Set(['layout','columns','tabs','accordion','html-embed','embed','spacer','divider'])
};
function categoryOf(key){for(const [name,ids] of Object.entries(categories))if(ids.has(key))return name;return 'basic'}
function groupBlocks(blocks,query=''){
const result={basic:[],visual:[],business:[],advanced:[]};
const q=String(query).trim().toLocaleLowerCase().slice(0,70);
for(const [key,block] of Object.entries(blocks||{})){
if(!block||typeof block!=='object')continue;
const text=[key,block.name,block.description].join(' ').toLocaleLowerCase();
if(q&&!text.includes(q))continue;
result[categoryOf(key)].push({key,block});
}
return result;
}
function previewUrl(theme,page){
if(!themes.has(theme)||!pages.has(page))return null;
return `/api/factory/themes/${theme}/preview?page_type=${page}`;
}
/* Only CSS-token values accepted by the existing server-side block validator. */
const designPalettes={
automotive:['#ffffff','#14283d','#f3f6f9','#102e47'],
industrial:['#ffffff','#193f59','#eef5f8','#104a6d'],
corporate:['#ffffff','#262d58','#f4f3fb','#34397b'],
minimal:['#faf9f5','#292924','#f0efe9','#30302c']
};
function stylePreset(theme,preset){
const [base,ink,soft,dark]=designPalettes[themes.has(theme)?theme:'corporate'];
switch(preset){
case 'clean':return {background:base,text_color:ink,padding:72};
case 'soft':return {background:soft,text_color:ink,padding:58};
case 'feature':return {background:dark,text_color:'#ffffff',padding:90};
default:return null;
}
}
const api=Object.freeze({categoryOf,groupBlocks,previewUrl,stylePreset});
if(typeof module!=='undefined'&&module.exports)module.exports=api;
if(root)root.SiteForgeStudioExperience=api;
})(typeof window!=='undefined'?window:null);