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

chore: merge feature into master #27488

Merged
merged 29 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e6cc000
feat: Input.Textarea support size props (#27110)
fireairforce Oct 12, 2020
288f0ca
merge feature
afc163 Oct 13, 2020
1123666
Merge pull request #27122 from ant-design/master-to-merge-feature
afc163 Oct 13, 2020
2788140
Merge pull request #27137 from ant-design/master
afc163 Oct 14, 2020
7d59890
feat: 🖼 Image support preview.getContainer (#26713)
rfreling Oct 15, 2020
1f1956c
Merge branch 'feature' into merge-into-feature
hengkx Oct 21, 2020
605bb2f
fix conflict
hengkx Oct 21, 2020
4cd2cfa
update snap
hengkx Oct 21, 2020
bcc05fc
Merge pull request #27275 from ant-design/merge-into-feature
afc163 Oct 21, 2020
b969bb4
feat: Modal method add bodyStyle (#27292)
hengkx Oct 22, 2020
5e1665d
docs: image fear add version (#27291)
hengkx Oct 22, 2020
888e28f
docs(Modal): add version (#27300)
hengkx Oct 22, 2020
b4c6740
feat: add loading prop for Statistic (#26811)
appleshell Oct 23, 2020
7e782da
feat: ConfigProvider add form requiredMark (#27322)
hengkx Oct 24, 2020
ab4aeca
feat: modal.update() supports functional updating (#27162) (#27163)
Mongkii Oct 24, 2020
7be4339
Merge branch 'feature' into merge
hengkx Oct 24, 2020
af6d8f7
fix: snap
hengkx Oct 24, 2020
bae5509
Merge pull request #27349 from ant-design/merge
hengkx Oct 24, 2020
6b1d73b
feat: Avatar.Group add size props (#27348)
hengkx Oct 24, 2020
c373710
chore: Adjust collapse arrow position align with first line (#27363)
zombieJ Oct 26, 2020
23f8cce
feat: Table summary support align (#27365)
zombieJ Oct 26, 2020
6880bf7
Merge pull request #27388 from ant-design/master
afc163 Oct 27, 2020
7c0e888
feat: components used in confirm title and content support prefixCls …
Chersquwn Oct 28, 2020
4ec9e23
Merge pull request #27421 from shaodahong/merge-to-feature
shaodahong Oct 28, 2020
0bf5a43
chore: feature merge master
zombieJ Oct 30, 2020
f6f3166
Merge pull request #27477 from ant-design/feature-merge-master
zombieJ Oct 30, 2020
d052543
feat: Row support `wrap` (#27469)
zombieJ Oct 30, 2020
0afb8de
feat: support Image element prop for Avatar component (#27448)
headwindz Oct 31, 2020
39c192a
Merge branch 'master' into chore-conflict-feature
Nov 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions components/avatar/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,43 @@ Array [
</span>
</span>
</div>,
<div
class="ant-divider ant-divider-horizontal"
role="separator"
/>,
<div
class="ant-avatar-group"
>
<span
class="ant-avatar ant-avatar-lg ant-avatar-circle ant-avatar-image"
>
<img
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
/>
</span>
<span
class="ant-avatar ant-avatar-lg ant-avatar-circle"
style="background-color:#f56a00"
>
<span
class="ant-avatar-string"
style="opacity:0"
>
K
</span>
</span>
<span
class="ant-avatar ant-avatar-lg ant-avatar-circle"
style="color:#f56a00;background-color:#fde3cf"
>
<span
class="ant-avatar-string"
style="opacity:0"
>
+2
</span>
</span>
</div>,
]
`;

Expand Down Expand Up @@ -760,6 +797,18 @@ Array [
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
/>
</span>,
<span
class="ant-avatar ant-avatar-circle ant-avatar-image"
>
<div
class="ant-image"
>
<img
class="ant-image-img"
src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"
/>
</div>
</span>,
<span
class="ant-avatar ant-avatar-circle"
style="color:#f56a00;background-color:#fde3cf"
Expand Down
12 changes: 9 additions & 3 deletions components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { composeRef } from '../_util/ref';
import { Breakpoint, responsiveArray, ScreenSizeMap } from '../_util/responsiveObserve';
import useBreakpoint from '../grid/hooks/useBreakpoint';

export type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;

export interface AvatarProps {
/** Shape of avatar, options:`circle`, `square` */
shape?: 'circle' | 'square';
/*
* Size of avatar, options: `large`, `small`, `default`
* or a custom number size
* */
size?: 'large' | 'small' | 'default' | number | ScreenSizeMap;
size?: AvatarSize;
gap?: number;
/** Src of image avatar */
src?: string;
Expand Down Expand Up @@ -128,12 +130,14 @@ const InternalAvatar: React.ForwardRefRenderFunction<unknown, AvatarProps> = (pr
[`${prefixCls}-sm`]: size === 'small',
});

const hasImageElement = React.isValidElement(src);

const classString = classNames(
prefixCls,
sizeCls,
{
[`${prefixCls}-${shape}`]: shape,
[`${prefixCls}-image`]: src && isImgExist,
[`${prefixCls}-image`]: hasImageElement || (src && isImgExist),
[`${prefixCls}-icon`]: icon,
},
className,
Expand All @@ -150,10 +154,12 @@ const InternalAvatar: React.ForwardRefRenderFunction<unknown, AvatarProps> = (pr
: {};

let childrenToRender;
if (src && isImgExist) {
if (typeof src === 'string' && isImgExist) {
childrenToRender = (
<img src={src} draggable={draggable} srcSet={srcSet} onError={handleImgLoadError} alt={alt} />
);
} else if (hasImageElement) {
childrenToRender = src;
} else if (icon) {
childrenToRender = icon;
} else if (mounted || scale !== 1) {
Expand Down
13 changes: 13 additions & 0 deletions components/avatar/demo/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ class Demo extends React.Component {
</Tooltip>
<Avatar style={{ backgroundColor: '#1890ff' }} icon={<AntDesignOutlined />} />
</Avatar.Group>
<Divider />
<Avatar.Group
maxCount={2}
size="large"
maxStyle={{ color: '#f56a00', backgroundColor: '#fde3cf' }}
>
<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
<Avatar style={{ backgroundColor: '#f56a00' }}>K</Avatar>
<Tooltip title="Ant User" placement="top">
<Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} />
</Tooltip>
<Avatar style={{ backgroundColor: '#1890ff' }} icon={<AntDesignOutlined />} />
</Avatar.Group>
</>
);
}
Expand Down
5 changes: 4 additions & 1 deletion components/avatar/demo/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ title:
Image, Icon and letter are supported, and the latter two kinds of avatar can have custom colors and background colors.

```tsx
import { Avatar } from 'antd';
import { Avatar, Image } from 'antd';
import { UserOutlined } from '@ant-design/icons';

ReactDOM.render(
Expand All @@ -23,6 +23,9 @@ ReactDOM.render(
<Avatar>U</Avatar>
<Avatar size={40}>USER</Avatar>
<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
<Avatar
src={<Image src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />}
/>
<Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf' }}>U</Avatar>
<Avatar style={{ backgroundColor: '#87d068' }} icon={<UserOutlined />} />
</>,
Expand Down
16 changes: 12 additions & 4 deletions components/avatar/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import toArray from 'rc-util/lib/Children/toArray';
import { cloneElement } from '../_util/reactNode';
import { ConfigContext } from '../config-provider';
import Avatar from './avatar';
import Avatar, { AvatarSize } from './avatar';
import Popover from '../popover';

export interface GroupProps {
Expand All @@ -14,12 +14,19 @@ export interface GroupProps {
maxCount?: number;
maxStyle?: React.CSSProperties;
maxPopoverPlacement?: 'top' | 'bottom';
/*
* Size of avatar, options: `large`, `small`, `default`
* or a custom number size
* */
size?: AvatarSize;
}

const Group: React.FC<GroupProps> = props => {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const { prefixCls: customizePrefixCls, className = '', maxCount, maxStyle } = props;
const { prefixCls: customizePrefixCls, className = '', maxCount, maxStyle, size } = props;

const prefixCls = getPrefixCls('avatar-group', customizePrefixCls);

const cls = classNames(
prefixCls,
{
Expand All @@ -31,6 +38,7 @@ const Group: React.FC<GroupProps> = props => {
const { children, maxPopoverPlacement = 'top' } = props;
const childrenWithProps = toArray(children).map((child, index) => {
return cloneElement(child, {
size,
key: `avatar-key-${index}`,
});
});
Expand All @@ -47,7 +55,7 @@ const Group: React.FC<GroupProps> = props => {
placement={maxPopoverPlacement}
overlayClassName={`${prefixCls}-popover`}
>
<Avatar style={maxStyle}>{`+${numOfChildren - maxCount}`}</Avatar>
<Avatar style={maxStyle} size={size}>{`+${numOfChildren - maxCount}`}</Avatar>
</Popover>,
);
return (
Expand All @@ -58,7 +66,7 @@ const Group: React.FC<GroupProps> = props => {
}
return (
<div className={cls} style={props.style}>
{children}
{childrenWithProps}
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion components/avatar/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Avatars can be used to represent people or objects. It supports images, `Icon`s,
| icon | Custom icon type for an icon avatar | ReactNode | - | |
| shape | The shape of avatar | `circle` \| `square` | `circle` | |
| size | The size of the avatar | number \| `large` \| `small` \| `default` \| `{ xs: number, sm: number, ...}` | `default` | 4.7.0 |
| src | The address of the image for an image avatar | string | - | |
| src | The address of the image for an image avatar or image element | string \| ReactNode | - | |
| srcSet | A list of sources to use for different screen resolutions | string | - | |
| onError | Handler when img load error, return false to prevent default fallback behavior | () => boolean | - | |

Expand All @@ -31,3 +31,4 @@ Avatars can be used to represent people or objects. It supports images, `Icon`s,
| maxCount | Max avatars to show | number | - | |
| maxPopoverPlacement | The placement of excess avatar Popover | `top` \| `bottom` | `top` | |
| maxStyle | The style of excess avatar style | CSSProperties | - | |
| size | The size of the avatar | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.8.0 |
3 changes: 2 additions & 1 deletion components/avatar/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/aBcnbw68hP/Avatar.svg
| icon | 设置头像的自定义图标 | ReactNode | - | |
| shape | 指定头像的形状 | `circle` \| `square` | `circle` | |
| size | 设置头像的大小 | number \| `large` \| `small` \| `default` \| `{ xs: number, sm: number, ...}` | `default` | 4.7.0 |
| src | 图片类头像的资源地址 | string | - | |
| src | 图片类头像的资源地址或者图片元素 | string \| ReactNode | - | |
| srcSet | 设置图片类头像响应式资源地址 | string | - | |
| onError | 图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为 | () => boolean | - | |

Expand All @@ -36,3 +36,4 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/aBcnbw68hP/Avatar.svg
| maxCount | 显示的最大头像个数 | number | - | |
| maxPopoverPlacement | 多余头像气泡弹出位置 | `top` \| `bottom` | `top` | |
| maxStyle | 多余头像样式 | CSSProperties | - | |
| size | 设置头像的大小 | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.8.0 |
3 changes: 1 addition & 2 deletions components/collapse/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@
.iconfont-mixin();

position: absolute;
top: 50%;
top: ceil(@padding-sm + (@font-size-base * @line-height-base - @font-size-base) / 2);
left: @collapse-header-arrow-left;
display: inline-block;
font-size: @font-size-sm;
transform: translateY(-50%);

& svg {
transition: transform 0.24s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14643,7 +14643,7 @@ exports[`ConfigProvider components Input configProvider componentSize large 1`]
</span>
</span>
<textarea
class="config-input"
class="config-input config-input-lg"
/>
</div>
`;
Expand Down