Skip to content

Commit

Permalink
fix: Should allow inline style for Descriptions component, close #17533
Browse files Browse the repository at this point in the history
… (#17558)
  • Loading branch information
m-mitchell authored and dengfuping committed Jul 10, 2019
1 parent d52b85f commit 4e629da
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
59 changes: 59 additions & 0 deletions components/descriptions/__tests__/__snapshots__/index.test.js.snap
@@ -1,5 +1,64 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Descriptions Descriptions support style 1`] = `
<Descriptions
column={
Object {
"lg": 3,
"md": 3,
"sm": 2,
"xl": 3,
"xs": 1,
"xxl": 3,
}
}
size="default"
style={
Object {
"backgroundColor": "#e8e8e8",
}
}
>
<div
className="ant-descriptions"
style={
Object {
"backgroundColor": "#e8e8e8",
}
}
>
<div
className="ant-descriptions-view"
>
<table>
<tbody>
<tr
className="ant-descriptions-row"
key="0"
>
<td
className="ant-descriptions-item"
colSpan={1}
>
<span
className="ant-descriptions-item-label ant-descriptions-item-no-label"
key="label"
/>
<span
className="ant-descriptions-item-content"
key="content"
>
Cloud Database
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</Descriptions>
`;

exports[`Descriptions Descriptions.Item support className 1`] = `
<Descriptions
column={
Expand Down
9 changes: 9 additions & 0 deletions components/descriptions/__tests__/index.test.js
Expand Up @@ -151,4 +151,13 @@ describe('Descriptions', () => {
);
expect(wrapper).toMatchSnapshot();
});

it('Descriptions support style', () => {
const wrapper = mount(
<Descriptions style={{ backgroundColor: '#e8e8e8' }}>
<Descriptions.Item>Cloud Database</Descriptions.Item>
</Descriptions>,
);
expect(wrapper).toMatchSnapshot();
});
});
2 changes: 2 additions & 0 deletions components/descriptions/index.tsx
Expand Up @@ -281,6 +281,7 @@ class Descriptions extends React.Component<
children,
bordered = false,
layout = 'horizontal',
style,
} = this.props;
const prefixCls = getPrefixCls('descriptions', customizePrefixCls);

Expand All @@ -306,6 +307,7 @@ class Descriptions extends React.Component<
[`${prefixCls}-${size}`]: size !== 'default',
[`${prefixCls}-bordered`]: !!bordered,
})}
style={style}
>
{title && <div className={`${prefixCls}-title`}>{title}</div>}
<div className={`${prefixCls}-view`}>
Expand Down

0 comments on commit 4e629da

Please sign in to comment.