Browse Source

use ul in list

pull/15890/head
zombiej 6 years ago
parent
commit
c6903c9cc9
  1. 7
      components/list/Item.tsx
  2. 6
      components/list/index.tsx
  3. 130
      components/list/style/index.less

7
components/list/Item.tsx

@ -112,9 +112,10 @@ export default class Item extends React.Component<ListItemProps, any> {
))}
</ul>
);
const Tag = grid ? 'div' : 'li';
const itemChildren = (
<div
{...others}
<Tag
{...others as any} // `li` element don't have `onCopy` prop. Cast to any.
className={classNames(`${prefixCls}-item`, className, {
[`${prefixCls}-item-no-flex`]: !this.isFlexMode(),
})}
@ -134,7 +135,7 @@ export default class Item extends React.Component<ListItemProps, any> {
actionsContent,
extra ? React.cloneElement(extra as React.ReactElement<any>, { key: 'extra' }) : null,
]}
</div>
</Tag>
);
return grid ? (

6
components/list/index.tsx

@ -233,7 +233,11 @@ export default class List<T> extends React.Component<ListProps<T>> {
);
});
childrenContent = grid ? <Row gutter={grid.gutter}>{childrenList}</Row> : childrenList;
childrenContent = grid ? (
<Row gutter={grid.gutter}>{childrenList}</Row>
) : (
<ul className={`${prefixCls}-items`}>{childrenList}</ul>
);
} else if (!children && !isLoading) {
childrenContent = this.renderEmpty(prefixCls, renderEmpty);
}

130
components/list/style/index.less

@ -37,76 +37,82 @@
text-align: center;
}
&-item {
display: flex;
align-items: center;
padding: @list-item-padding;
&-items {
margin: 0;
padding: 0;
list-style: none;
&-no-flex {
display: block;
}
&-content {
color: @text-color;
}
&-meta {
.@{list-prefix-cls}-item {
display: flex;
flex: 1;
align-items: flex-start;
font-size: 0;
&-avatar {
margin-right: @list-item-meta-avatar-margin-right;
align-items: center;
padding: @list-item-padding;
&-no-flex {
display: block;
}
&-content {
flex: 1 0;
}
&-title {
margin-bottom: 4px;
color: @text-color;
font-size: @font-size-base;
line-height: 22px;
> a {
}
&-meta {
display: flex;
flex: 1;
align-items: flex-start;
font-size: 0;
&-avatar {
margin-right: @list-item-meta-avatar-margin-right;
}
&-content {
flex: 1 0;
}
&-title {
margin-bottom: 4px;
color: @text-color;
transition: all 0.3s;
&:hover {
color: @primary-color;
font-size: @font-size-base;
line-height: 22px;
> a {
color: @text-color;
transition: all 0.3s;
&:hover {
color: @primary-color;
}
}
}
&-description {
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
}
}
&-description {
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
}
}
&-action {
flex: 0 0 auto;
margin-left: 48px;
padding: 0;
font-size: 0;
list-style: none;
& > li {
position: relative;
display: inline-block;
padding: 0 8px;
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
text-align: center;
cursor: pointer;
}
& > li:first-child {
padding-left: 0;
}
&-split {
position: absolute;
top: 50%;
right: 0;
width: 1px;
height: 14px;
margin-top: -7px;
background-color: @border-color-split;
&-action {
flex: 0 0 auto;
margin-left: 48px;
padding: 0;
font-size: 0;
list-style: none;
& > li {
position: relative;
display: inline-block;
padding: 0 8px;
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
text-align: center;
cursor: pointer;
}
& > li:first-child {
padding-left: 0;
}
&-split {
position: absolute;
top: 50%;
right: 0;
width: 1px;
height: 14px;
margin-top: -7px;
background-color: @border-color-split;
}
}
}
}
@ -147,7 +153,7 @@
min-height: 32px;
}
&-something-after-last-item .@{ant-prefix}-spin-container > &-item:last-child {
&-something-after-last-item .@{ant-prefix}-spin-container > &-items > &-item:last-child {
border-bottom: 1px solid @border-color-split;
}

Loading…
Cancel
Save