fix(ellipsis): set the height of ellipsis manually

This commit is contained in:
unix
2020-06-26 07:52:32 +08:00
parent 965654f91a
commit 228bf62fc3
3 changed files with 8 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ exports[`Ellipsis should render correctly 1`] = `
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 10px;
min-width: 0;
}
</style></span></div>"

View File

@@ -6,7 +6,7 @@ describe('Ellipsis', () => {
it('should render correctly', () => {
const wrapper = mount(
<div style={{ width: '1px' }}>
<Ellipsis>text</Ellipsis>
<Ellipsis height="10px">text</Ellipsis>
</div>,
)
expect(wrapper.html()).toMatchSnapshot()

View File

@@ -1,6 +1,10 @@
import React from 'react'
const Ellipsis: React.FC<React.PropsWithChildren<{}>> = ({ children }) => {
export type EllipsisProps = {
height: string
}
const Ellipsis: React.FC<React.PropsWithChildren<EllipsisProps>> = ({ children, height }) => {
return (
<span>
{children}
@@ -9,6 +13,7 @@ const Ellipsis: React.FC<React.PropsWithChildren<{}>> = ({ children }) => {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: ${height};
min-width: 0;
}
`}</style>