canvas-component-definition
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCanonical definition
标准定义
A Canvas component is a package of:
- A React implementation ()
index.jsx - Canvas metadata/schema ()
component.yml - Naming and structure compatibility (, folder path, story path)
machineName - Canvas-compatible props/slots modeling
All four parts are required for the component to be usable in Drupal Canvas.
Canvas组件是一个包含以下部分的包:
- React实现文件()
index.jsx - Canvas元数据/模式文件()
component.yml - 命名与结构兼容性(、文件夹路径、Story路径)
machineName - 兼容Canvas的props/slots建模
这四个部分是组件能在Drupal Canvas中使用的必要条件。
Minimum contract (MUST)
最低要求(必须满足)
Every Canvas component MUST satisfy all checks below:
- Component folder exists at (use the repository's configured components root, which may be defined in
<components-root>/<machine-name>/).env - React implementation exists at
<components-root>/<machine-name>/index.jsx - Metadata exists at
<components-root>/<machine-name>/component.yml - includes required top-level keys (
component.yml,name,machineName,status,required,props)slots - Folder name exactly matches in
machineName(kebab-case)component.yml - A matching story exists at (use the repository's configured stories root)
<stories-root>/<machine-name>.stories.jsx - Props/slots follow Canvas rules (for example, avoid unsupported array-of-object prop shapes; use slots for repeatable complex content)
If any item is missing, the component is incomplete for Canvas usage.
每个Canvas组件都必须通过以下所有检查:
- 组件文件夹存在于(使用仓库中配置的组件根目录,该目录可能在
<components-root>/<machine-name>/中定义).env - React实现文件存在于
<components-root>/<machine-name>/index.jsx - 元数据文件存在于
<components-root>/<machine-name>/component.yml - 包含必填的顶级键(
component.yml、name、machineName、status、required、props)slots - 文件夹名称与中的
component.yml完全匹配(短横线分隔的小写格式)machineName - 对应的Story文件存在于(使用仓库中配置的Story根目录)
<stories-root>/<machine-name>.stories.jsx - Props/slots遵循Canvas规则(例如,避免不支持的对象数组类型props;使用slots处理可重复的复杂内容)
如果缺少任意一项,该组件就无法在Canvas中正常使用。