-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: 组件折叠面板collapse #2926
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: 组件折叠面板collapse #2926
Conversation
src/renderers/Collapse2.tsx
Outdated
| /** | ||
| * 内容区域 | ||
| */ | ||
| body?: Array<Schema>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换成 SchemaCollection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
src/renderers/Collapse2.tsx
Outdated
| @@ -0,0 +1,171 @@ | |||
| import React from 'react'; | |||
| import {Renderer, RendererProps} from '../factory'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把组件的部分抽象到component中,render只保留schema定义与映射相关
scss/components/_collapse-panel.scss
Outdated
|
|
||
| &-content-box { | ||
| padding: px2rem(16px) px2rem(16px); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
颜色等信息,在主题中兼容吧
| label: 'Collapse 折叠器', | ||
| path: '/zh-CN/components/collapse', | ||
| getComponent: () => | ||
| import('../../docs/zh-CN/components/collapse.md').then( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前原来的文档上改?为何要加个新文档?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts-ingore 已经不需要了,可以去掉
src/components/CollapsePanel.tsx
Outdated
| } from '../Schema'; | ||
| import {SchemaNode} from '../types'; | ||
|
|
||
| export interface CollapsePanelProps extends RendererProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component 不应该 extends RendererProps
src/components/Collapse2.tsx
Outdated
| import {SchemaNode} from '../types'; | ||
| import remove from 'lodash/remove'; | ||
|
|
||
| export interface Collapse2Props extends RendererProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既然是 component,就不应该 extends RendererProps
src/components/Collapse2.tsx
Outdated
| constructor(props: Collapse2Props) { | ||
| super(props); | ||
|
|
||
| let activeKey = props.$schema.defaultActiveKey || props.$schema.activeKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
组件层应该不关注 $schema 这个属性。另外如果外部控制 activeKey,目前看来是不同步的,因为没看到 didUpdate props 同步 state 的逻辑。
src/components/Collapse2.tsx
Outdated
| onChange: (item: CollapsePanelProps, collapsed: boolean) => this.collapseChange(item, collapsed) | ||
| }); | ||
|
|
||
| return this.props.render('panel-' + id, child, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要调用 props.render ,组件层不应该使用这个方法。如果要做到内容动态化,是由渲染器那层去控制的。这里你定义类型为 JSX.element 或者 () => JSX.element 即可。
src/components/CollapseGroup.tsx
Outdated
| CollapseGroupState | ||
| > { | ||
| static propsList: Array<string> = [ | ||
| 'wrapperComponent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
先不要了
| * 自定义切换图标 | ||
| */ | ||
| expandIcon?: SchemaCollection; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SchemaObject
| /** | ||
| * 标题 | ||
| */ | ||
| header?: string | SchemaCollection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
整个组件还是需要从renderer中拆出去成为一个component,要不还是没法儿直接通过component的方式用了,拆过去的部分只用header即可,renderer部分留两个,给做title个兼容
src/components/Collapse.tsx
Outdated
| showArrow?: boolean; | ||
| expandIcon?: React.ReactElement | null; | ||
| headingClassName?: string; | ||
| collapseTitle?: React.ReactElement | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和header不是很呼应
src/components/Collapse.tsx
Outdated
| className?: string; | ||
| classPrefix: string; | ||
| classnames: ClassNamesFn; | ||
| titlePosition?: 'top' | 'bottom'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title还是header?
src/components/Collapse.tsx
Outdated
| headerPosition?: 'top' | 'bottom'; | ||
| header?: React.ReactElement; | ||
| body: any; | ||
| bodyClassName?: SchemaClassName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是 string
src/components/Collapse.tsx
Outdated
|
|
||
| export class Collapse extends React.Component<CollapseProps, CollapseState> { | ||
|
|
||
| static propsList: Array<string> = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这东西是渲染器里面,配置下发属性黑名单的,在 component 里面没有意义
src/components/CollapseGroup.tsx
Outdated
| accordion?: boolean; | ||
| expandIcon?: SchemaNode; | ||
| expandIconPosition?: 'left' | 'right'; | ||
| body?: SchemaCollection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Body 应该是 Array<React.ReactElement> ?
src/components/CollapseGroup.tsx
Outdated
| CollapseGroupProps, | ||
| CollapseGroupState | ||
| > { | ||
| static propsList: Array<string> = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, 这个在 component 里面是无效的
src/components/CollapseGroup.tsx
Outdated
| import cx from 'classnames'; | ||
|
|
||
| export interface CollapseGroupProps { | ||
| activeKey?: Array<string | number | never> | string | number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个属性好像没有用上?
src/renderers/Collapse.tsx
Outdated
| : body | ||
| ? render('body', body) | ||
| : null} | ||
| onChange={onChange} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 onChange 出去有点危险,这个不是表单项,上层接收到 onChange 后不知道该如何处理。建议去掉,不要触发。
* feat: 组件折叠面板collapse * feat: 组件折叠面板collapse * fix: collapse组件部分抽象到component * feat:增加collapse-group组件 * fix: 修复collapse样式 * feat: collapse组件扩充 * fix: 使用header兼容title * fix: collapse参数调整 * fix: 修改collapse的参数 * fix: collapse参数修改 * fix: update tests * fix: schema中去掉function Co-authored-by: hongyang03 <[email protected]>
这个变动的性质是?
需求背景和解决方案
设计文档:http://wiki.baidu.com/pages/viewpage.action?pageId=1693671823
更新日志
请求合并前的自查清单