Loading...
Loading...
Compare original and translation side by side
manifest.jsonmanifest.jsoncomponent.tsxcomponent.tsxwix.elementsRemovalStatewix.elementsRemovalStatestyle.cssstyle.cssbox-sizing: border-boxtransition: allprefers-reduced-motion--display: [value]display: var(--display)box-sizing: border-boxtransition: allprefers-reduced-motion--display: [value]display: var(--display)types.tstypes.ts{
"selector": ".component-name",
"displayName": "Component Name",
"archetype": "Container",
"layout": {
"resizeDirection": "horizontalAndVertical",
"contentResizeDirection": "horizontal"
},
"cssProperties": {
"backgroundColor": {
"displayName": "Background Color",
"defaultValue": "#ffffff"
}
},
"data": {
"columns": {
"dataType": "number",
"displayName": "Number of Columns",
"number": { "minimum": 1, "maximum": 4 }
}
},
"elements": {
"title": {
"elementType": "inlineElement",
"inlineElement": {
"selector": ".component-name__title",
"displayName": "Title",
"data": {
"titleText": {
"dataType": "text",
"displayName": "Title Text"
}
},
"behaviors": {
"selectable": true,
"removable": true
}
}
}
}
}{
"selector": ".component-name",
"displayName": "Component Name",
"archetype": "Container",
"layout": {
"resizeDirection": "horizontalAndVertical",
"contentResizeDirection": "horizontal"
},
"cssProperties": {
"backgroundColor": {
"displayName": "Background Color",
"defaultValue": "#ffffff"
}
},
"data": {
"columns": {
"dataType": "number",
"displayName": "Number of Columns",
"number": { "minimum": 1, "maximum": 4 }
}
},
"elements": {
"title": {
"elementType": "inlineElement",
"inlineElement": {
"selector": ".component-name__title",
"displayName": "Title",
"data": {
"titleText": {
"dataType": "text",
"displayName": "Title Text"
}
},
"behaviors": {
"selectable": true,
"removable": true
}
}
}
}
}| Type | Runtime Value | Use Case |
|---|---|---|
| string | Names, titles, descriptions |
| string | Predefined options |
| number | Quantities, dimensions |
| boolean | Toggles, flags |
| Object | Accessibility attributes |
| | Navigation links |
| | Images |
| Video object | Media content |
| Sanitized SVG object | Icons, graphics |
| string (YYYY-MM-DD) | Date values |
| string (hh:mm) | Time values |
| string | External URLs |
| string (HTML) | Formatted content |
| Array | Collections, lists |
| string | HTML dir attribute |
| Array of menu items | Navigation menus |
| 类型 | 运行时值 | 使用场景 |
|---|---|---|
| string | 名称、标题、描述 |
| string | 预定义选项 |
| number | 数量、尺寸 |
| boolean | 开关、标记 |
| Object | 无障碍属性 |
| | 导航链接 |
| | 图片 |
| Video对象 | 媒体内容 |
| 经过清理的SVG对象 | 图标、图形 |
| string(YYYY-MM-DD) | 日期值 |
| string(hh:mm) | 时间值 |
| string | 外部URL |
| string(HTML) | 格式化内容 |
| Array | 集合、列表 |
| string | HTML dir属性 |
| 菜单项数组 | 导航菜单 |
displaygappaddingmarginwidthheightfontfontSizefontWeighttextAligncolorbackgroundColorbackgroundImageborderborderRadiusboxShadowalignItemsjustifyContentflexDirectiondisplaygappaddingmarginwidthheightfontfontSizefontWeighttextAligncolorbackgroundColorbackgroundImageborderborderRadiusboxShadowalignItemsjustifyContentflexDirectioninterface ComponentProps {
// Standard props (always present)
className: string;
id: string;
wix?: Wix;
// Component-level data (from editorElement.data)
columns?: number;
layout?: string;
// Element props (from elements definitions)
elementProps?: {
title?: {
titleText?: string;
wix?: Wix;
};
button?: {
buttonText?: string;
buttonLink?: Link;
wix?: Wix;
};
};
}interface ComponentProps {
// 标准props(始终存在)
className: string;
id: string;
wix?: Wix;
// 组件级数据(来自editorElement.data)
columns?: number;
layout?: string;
// 元素props(来自元素定义)
elementProps?: {
title?: {
titleText?: string;
wix?: Wix;
};
button?: {
buttonText?: string;
buttonLink?: Link;
wix?: Wix;
};
};
}// Title sub-component
interface TitleProps {
titleText?: string;
className: string;
}
const Title: FC<TitleProps> = ({ titleText = "Default Title", className }) => (
<h2 className={className}>{titleText}</h2>
);
// Main component
const ProductCard: FC<ProductCardProps> = ({
className,
id,
elementProps,
wix
}) => {
const removalState = wix?.elementsRemovalState || {};
return (
<div className={`product-card ${className}`} id={id}>
{!removalState['title'] && (
<Title
className="product-card__title"
{...elementProps?.title}
/>
)}
{!removalState['button'] && (
<Button
className="product-card__button"
{...elementProps?.button}
/>
)}
</div>
);
};// 标题子组件
interface TitleProps {
titleText?: string;
className: string;
}
const Title: FC<TitleProps> = ({ titleText = "Default Title", className }) => (
<h2 className={className}>{titleText}</h2>
);
// 主组件
const ProductCard: FC<ProductCardProps> = ({
className,
id,
elementProps,
wix
}) => {
const removalState = wix?.elementsRemovalState || {};
return (
<div className={`product-card ${className}`} id={id}>
{!removalState['title'] && (
<Title
className="product-card__title"
{...elementProps?.title}
/>
)}
{!removalState['button'] && (
<Button
className="product-card__button"
{...elementProps?.button}
/>
)}
</div>
);
};const removalState = wix?.elementsRemovalState || {};
return (
<div className={`component ${className}`} id={id}>
{!removalState['elementKey'] && <Element />}
</div>
);const removalState = wix?.elementsRemovalState || {};
return (
<div className={`component ${className}`} id={id}>
{!removalState['elementKey'] && <Element />}
</div>
);width: 100%; height: 100%clamp()width: 100%; height: 100%clamp().component {
--display: block;
--background-color: #ffffff;
--text-color: #333333;
display: var(--display);
background-color: var(--background-color);
color: var(--text-color);
pointer-events: auto;
}.component {
--display: block;
--background-color: #ffffff;
--text-color: #333333;
display: var(--display);
background-color: var(--background-color);
color: var(--text-color);
pointer-events: auto;
}className="product-card__title".product-card__title { ... }"selector": ".product-card__title"className="product-card__title".product-card__title { ... }"selector": ".product-card__title"| Relationship | Value | Use Case |
|---|---|---|
| Tight (icon + label) | 0.25-0.5rem (4-8px) | Clustering related items |
| Same category | 1-1.5rem (16-24px) | Card sections, form fields |
| Different sections | 2-3rem (32-48px) | Major content blocks |
| Emphasis/Drama | 4rem+ (64px+) | Hero content, luxury feel |
| 关系 | 值 | 使用场景 |
|---|---|---|
| 紧凑(图标+标签) | 0.25-0.5rem(4-8px) | 相关项聚类 |
| 同类项 | 1-1.5rem(16-24px) | 卡片区块、表单字段 |
| 不同区块 | 2-3rem(32-48px) | 主要内容块 |
| 强调/突出 | 4rem+(64px+) | 首屏内容、高端风格 |
// Import in component
import { heroImage } from './assets/defaultImages';
// Usage
<img src={heroImage} alt="Hero" /><imageUrlName>
{ "description": "Modern cityscape at sunset", "width": 1920, "height": 1088 }
</imageUrlName>'./assets/defaultImages'// 在组件中导入
import { heroImage } from './assets/defaultImages';
// 使用
<img src={heroImage} alt="Hero" /><imageUrlName>
{ "description": "Modern cityscape at sunset", "width": 1920, "height": 1088 }
</imageUrlName>'./assets/defaultImages'src/site/components/
└── {component-name}/
├── manifest.json # Component manifest
├── component.tsx # React component
├── style.css # CSS styles
├── types.ts # TypeScript types
└── assets/ # Optional assets
└── defaultImages.tssrc/site/components/
└── {component-name}/
├── manifest.json # 组件清单
├── component.tsx # React组件
├── style.css # CSS样式
├── types.ts # TypeScript类型定义
└── assets/ # 可选资源
└── defaultImages.tsextensions.tsimport { extensions } from "@wix/astro/builders";
import manifest from "./site/components/my-component/manifest.json";
export const sitecomponentMyComponent = extensions.siteComponent({
...manifest,
id: "{{GENERATE_UUID}}",
description: "My Component",
type: "platform.builder.{{GENERATE_UUID}}",
resources: {
client: {
component: "./site/components/my-component/component.tsx",
componentUrl: "./site/components/my-component/component.tsx",
},
},
});idtypeidrandomUUID()extensions.tsimport { extensions } from "@wix/astro/builders";
import manifest from "./site/components/my-component/manifest.json";
export const sitecomponentMyComponent = extensions.siteComponent({
...manifest,
id: "{{GENERATE_UUID}}",
description: "My Component",
type: "platform.builder.{{GENERATE_UUID}}",
resources: {
client: {
component: "./site/components/my-component/component.tsx",
componentUrl: "./site/components/my-component/component.tsx",
},
},
});idtypeidrandomUUID()src/extensions.tssrc/extensions.tsany@ts-ignore@ts-expect-errorany@ts-ignore@ts-expect-error@typescript-eslint/no-unused-varsimgsrchttps://...wixstatic.comwindowdocumentuseEffectdangerouslySetInnerHTML<style>stylewindow.fetchno-restricted-propertiesexhaustive-depsuseEffectuseCallbackconstletvar@typescript-eslint/no-unused-varsimgsrchttps://...wixstatic.comwindowdocumentuseEffectdangerouslySetInnerHTML<style>stylewindow.fetchno-restricted-propertiesexhaustive-depsuseEffectuseCallbackconstletvar@wix/design-system@wix/wix-ui-icons-common@wix/design-system@wix/wix-ui-icons-common