fix: List with actions style should be the right (#16239)

* update css

* should not affect vertical style

* update logic
pull/16275/head
zombieJ 6 years ago committed by GitHub
parent 197c424e54
commit e541a2492c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,7 @@
import * as React from 'react';
export function cloneElement(element: React.ReactNode, ...restArgs: any[]) {
if (!React.isValidElement(element)) return element;
return React.cloneElement(element, ...restArgs);
}

@ -4,6 +4,7 @@ import classNames from 'classnames';
import { ListGridType, ColumnType } from './index'; import { ListGridType, ColumnType } from './index';
import { Col } from '../grid'; import { Col } from '../grid';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
import { cloneElement } from '../_util/reactNode';
export interface ListItemProps extends React.HTMLAttributes<HTMLDivElement> { export interface ListItemProps extends React.HTMLAttributes<HTMLDivElement> {
className?: string; className?: string;
@ -129,11 +130,7 @@ export default class Item extends React.Component<ListItemProps, any> {
{extra} {extra}
</div>, </div>,
] ]
: [ : [children, actionsContent, cloneElement(extra, { key: 'extra' })]}
children,
actionsContent,
extra ? React.cloneElement(extra as React.ReactElement<any>, { key: 'extra' }) : null,
]}
</div> </div>
); );

@ -43,10 +43,6 @@
align-items: center; align-items: center;
padding: @list-item-padding; padding: @list-item-padding;
&-no-flex {
display: block;
}
&-content { &-content {
color: @text-color; color: @text-color;
} }
@ -206,6 +202,20 @@
padding-bottom: 0; padding-bottom: 0;
border-bottom: none; border-bottom: none;
} }
// ============================ without flex ============================
&-item-no-flex {
display: block;
}
// Horizontal
&:not(.@{list-prefix-cls}-vertical) {
.@{list-prefix-cls}-item-no-flex {
.@{list-prefix-cls}-item-action {
float: right;
}
}
}
} }
@import './bordered'; @import './bordered';

Loading…
Cancel
Save