mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-24 04:15:54 +08:00
fix(ellipsis): set the height of ellipsis manually
This commit is contained in:
@@ -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>"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user