@@ -19,11 +41,7 @@ const AvatarList = ({ children, size, ...other }) => {
};
const Item = ({ src, size, tips, onClick = () => {} }) => {
- const cls = classNames(styles.avatarItem, {
- [styles.avatarItemLarge]: size === 'large',
- [styles.avatarItemSmall]: size === 'small',
- [styles.avatarItemMini]: size === 'mini',
- });
+ const cls = avatarSizeToClassName(size);
return (
diff --git a/src/components/AvatarList/index.less b/src/components/AvatarList/index.less
index 8660ba4352eb91434fe68ddbbd356303cc2a170e..31d670565bd82fe8b08138d5dfa1d8082682aaa8 100644
--- a/src/components/AvatarList/index.less
+++ b/src/components/AvatarList/index.less
@@ -40,6 +40,11 @@
width: 20px;
height: 20px;
line-height: 20px;
+
+ .ant-avatar-string {
+ font-size: 12px;
+ line-height: 18px;
+ }
}
}
}
diff --git a/src/components/AvatarList/index.test.js b/src/components/AvatarList/index.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2b5bc438d882fc608a1e25869118e01c38a4484c
--- /dev/null
+++ b/src/components/AvatarList/index.test.js
@@ -0,0 +1,29 @@
+import React from 'react';
+import range from 'lodash/range';
+import { mount } from 'enzyme';
+import AvatarList from './index';
+
+const renderItems = numItems =>
+ range(numItems).map(i => (
+
+ ));
+
+describe('AvatarList', () => {
+ it('renders all items', () => {
+ const wrapper = mount({renderItems(4)});
+ expect(wrapper.find('AvatarList').length).toBe(1);
+ expect(wrapper.find('Item').length).toBe(4);
+ expect(wrapper.findWhere(node => node.key() === 'exceed').length).toBe(0);
+ });
+
+ it('renders max of 3 items', () => {
+ const wrapper = mount({renderItems(4)});
+ expect(wrapper.find('AvatarList').length).toBe(1);
+ expect(wrapper.find('Item').length).toBe(3);
+ expect(wrapper.findWhere(node => node.key() === 'exceed').length).toBe(1);
+ });
+});
diff --git a/src/components/AvatarList/index.zh-CN.md b/src/components/AvatarList/index.zh-CN.md
index 4ec0c136adb883c9cef94a8cbddfc33fcc831569..bdab181ce0ed6f1ff8d07422672085410033a815 100644
--- a/src/components/AvatarList/index.zh-CN.md
+++ b/src/components/AvatarList/index.zh-CN.md
@@ -11,13 +11,15 @@ cols: 1
### AvatarList
-| 参数 | 说明 | 类型 | 默认值 |
-|----------|------------------------------------------|-------------|-------|
-| size | 头像大小 | `large`、`small` 、`mini`, `default` | `default` |
+| 参数 | 说明 | 类型 | 默认值 |
+| ---------------- | -------- | ---------------------------------- | --------- |
+| size | 头像大小 | `large`、`small` 、`mini`, `default` | `default` |
+| maxLength | 要显示的最大项目 | number | - |
+| excessItemsStyle | 多余的项目风格 | CSSProperties | - |
### AvatarList.Item
-| 参数 | 说明 | 类型 | 默认值 |
-|----------|------------------------------------------|-------------|-------|
-| tips | 头像展示文案 | ReactNode | - |
-| src | 头像图片连接 | string | - |
+| 参数 | 说明 | 类型 | 默认值 |
+| ---- | ------ | --------- | --- |
+| tips | 头像展示文案 | ReactNode | - |
+| src | 头像图片连接 | string | - |