自定义组件描述json
- 生成自定义组件描述 (案例地址: https://github.com/D2cGen/c2djsonpro)
export type SingleCompnentItem = {
elementProps?: string[];
propsFactory?: string;
hasChildren?: boolean;
renderItemProps?: string;
componentName?: string;
whiteProps?: string[];
blackProps?: string[];
} | null;
export type SingleComponent = {
components?: {
[key: string]: SingleCompnentItem;
};
functions?: {
[key: string]: {
pattern?: string;
};
};
};
{
components: {
'Image': {
propsFactory: propsFactory.imageFactory
},
'View': null,
'Text': null,
'TextInput': {
propsFactory: propsFactory.inputFactory
},
'ScrollView': null,
'FlatList': {
elementProps: [
'renderItem',
'ListHeaderComponent',
'ListFooterComponent'
],
renderItemProps: 'renderItem',
propsFactory: propsFactory.flatListFactory,
whiteProps: [
'style.flex',
'style.paddingTop',
'style.paddingLeft',
'style.paddingBottom',
'style.paddingRight',
'style.paddingHorizontal',
'style.paddingVertical'
]
},
},
functions: {
'StyleSheet': {
pattern: 'StyleSheet.create(',
},
"ViewProps": {
pattern: '& ViewProps'
}
}
}
- 步骤一 lib库json声明案例 https://github.com/D2cGen/c2djsonpro/tree/main/src/webpro
- 项目重构中,将会支持这些组件 设计稿转代码
https://ant.design/components/collapse-cn
https://ant.design/components/card-cn
https://ant.design/components/descriptions-cn
https://ant.design/components/drawer-cn
https://ant.design/components/empty-cn
https://ant.design/components/form-cn
https://ant.design/components/input-cn
https://ant.design/components/list-cn
https://ant.design/components/popover-cn
https://ant.design/components/tabs-cn
https://ant.design/components/upload-cn