Skip to content

Conversation

@hy993658052
Copy link
Collaborator

这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • [✓] 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化语料改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 其他改动(是关于什么的改动?)

需求背景和解决方案

设计文档:http://wiki.baidu.com/pages/viewpage.action?pageId=1693671823

更新日志

语言 更新描述
英文 A new Collapse component is added, and the function and style are improved and optimized on the basis of the original Collapse component
中文 增加新折叠面板组件,在原折叠面板组件的基础上对功能和样式进行了改进和优化

请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • [✓] 文档已补充或无须补充
  • [✓] 代码演示已提供或无须提供
  • [✓] TypeScript 定义已补充或无须补充
  • [✓] Changelog 已提供或无须提供

/**
* 内容区域
*/
body?: Array<Schema>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

换成 SchemaCollection

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@@ -0,0 +1,171 @@
import React from 'react';
import {Renderer, RendererProps} from '../factory';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把组件的部分抽象到component中,render只保留schema定义与映射相关


&-content-box {
padding: px2rem(16px) px2rem(16px);
}
Copy link
Collaborator

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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前原来的文档上改?为何要加个新文档?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts-ingore 已经不需要了,可以去掉

} from '../Schema';
import {SchemaNode} from '../types';

export interface CollapsePanelProps extends RendererProps {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component 不应该 extends RendererProps

import {SchemaNode} from '../types';
import remove from 'lodash/remove';

export interface Collapse2Props extends RendererProps {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既然是 component,就不应该 extends RendererProps

constructor(props: Collapse2Props) {
super(props);

let activeKey = props.$schema.defaultActiveKey || props.$schema.activeKey;
Copy link
Member

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 的逻辑。

onChange: (item: CollapsePanelProps, collapsed: boolean) => this.collapseChange(item, collapsed)
});

return this.props.render('panel-' + id, child, {
Copy link
Member

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 即可。

CollapseGroupState
> {
static propsList: Array<string> = [
'wrapperComponent',
Copy link
Collaborator

@yangwei9012 yangwei9012 Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先不要了

* 自定义切换图标
*/
expandIcon?: SchemaCollection;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SchemaObject

/**
* 标题
*/
header?: string | SchemaCollection;
Copy link
Collaborator

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个兼容

showArrow?: boolean;
expandIcon?: React.ReactElement | null;
headingClassName?: string;
collapseTitle?: React.ReactElement | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和header不是很呼应

className?: string;
classPrefix: string;
classnames: ClassNamesFn;
titlePosition?: 'top' | 'bottom';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title还是header?

headerPosition?: 'top' | 'bottom';
header?: React.ReactElement;
body: any;
bodyClassName?: SchemaClassName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是 string


export class Collapse extends React.Component<CollapseProps, CollapseState> {

static propsList: Array<string> = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这东西是渲染器里面,配置下发属性黑名单的,在 component 里面没有意义

accordion?: boolean;
expandIcon?: SchemaNode;
expandIconPosition?: 'left' | 'right';
body?: SchemaCollection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Body 应该是 Array<React.ReactElement> ?

CollapseGroupProps,
CollapseGroupState
> {
static propsList: Array<string> = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, 这个在 component 里面是无效的

import cx from 'classnames';

export interface CollapseGroupProps {
activeKey?: Array<string | number | never> | string | number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个属性好像没有用上?

: body
? render('body', body)
: null}
onChange={onChange}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 onChange 出去有点危险,这个不是表单项,上层接收到 onChange 后不知道该如何处理。建议去掉,不要触发。

@2betop 2betop merged commit 4dfb286 into baidu:master Nov 23, 2021
movemoving pushed a commit to movemoving/amis that referenced this pull request Dec 20, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants