Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generator): support the same type for different themes #211

Merged
merged 1 commit into from
May 27, 2022

Conversation

mengshang918
Copy link
Collaborator

Motivation

form-generator现在组件的配置是按照type分类的,如下:

{
  //未选中任何表单的全局配置
  root:{},
  //输入框的配置
  text:{},
}

以上按照type分类,存在以下问题:

  1. 主题不一致,但是type相同。配置会覆盖
  2. 相同type,默认配置不一样的场景

考虑过的方案

  • 方案一
    用户配置的时候,保证type是唯一的。使用theme:type进行区分。
    缺点:
    • 用户开发自定义主题存在心智负担
  • 方案二
    {
      theme:{
        type:xxx     
       }
    }
    
    缺点:
    • 无法解决问题2
  • 方案三
    generator自动根据组件生成唯一值
    缺点:
    • 侵入性:唯一值需要和组件的主题和组件类型进行绑定,所以需要修改表单协议
    • 该协议不通用,只能在特定的generator下使用

调研后,使用配置不一样的表单的场景比较少见且用户可以通过配置新的主题或组件来解决该问题。所以最终采用方案二

Have you read the Contributing Guidelines on pull requests?

Y

Test Plan

N

Related PRs

N

@mengshang918 mengshang918 self-assigned this May 27, 2022
@mengshang918 mengshang918 added the enhancement New feature or request label May 27, 2022
@mengshang918 mengshang918 added this to the v0.8.0 milestone May 27, 2022
@mengshang918 mengshang918 merged commit 23cf581 into dev May 27, 2022
@mengshang918 mengshang918 deleted the feat/sameType branch May 27, 2022 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant