From 228bf62fc39ee5123810eae7727605a840ea3f04 Mon Sep 17 00:00:00 2001 From: unix Date: Fri, 26 Jun 2020 07:52:32 +0800 Subject: [PATCH 1/2] fix(ellipsis): set the height of ellipsis manually --- .../shared/__tests__/__snapshots__/ellipsis.test.tsx.snap | 1 + components/shared/__tests__/ellipsis.test.tsx | 2 +- components/shared/ellipsis.tsx | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/shared/__tests__/__snapshots__/ellipsis.test.tsx.snap b/components/shared/__tests__/__snapshots__/ellipsis.test.tsx.snap index 55de572..e29bb1d 100644 --- a/components/shared/__tests__/__snapshots__/ellipsis.test.tsx.snap +++ b/components/shared/__tests__/__snapshots__/ellipsis.test.tsx.snap @@ -6,6 +6,7 @@ exports[`Ellipsis should render correctly 1`] = ` overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + line-height: 10px; min-width: 0; } " diff --git a/components/shared/__tests__/ellipsis.test.tsx b/components/shared/__tests__/ellipsis.test.tsx index 9a064d6..293d68a 100644 --- a/components/shared/__tests__/ellipsis.test.tsx +++ b/components/shared/__tests__/ellipsis.test.tsx @@ -6,7 +6,7 @@ describe('Ellipsis', () => { it('should render correctly', () => { const wrapper = mount(
- text + text
, ) expect(wrapper.html()).toMatchSnapshot() diff --git a/components/shared/ellipsis.tsx b/components/shared/ellipsis.tsx index 6a6f218..9ec8c1b 100644 --- a/components/shared/ellipsis.tsx +++ b/components/shared/ellipsis.tsx @@ -1,6 +1,10 @@ import React from 'react' -const Ellipsis: React.FC> = ({ children }) => { +export type EllipsisProps = { + height: string +} + +const Ellipsis: React.FC> = ({ children, height }) => { return ( {children} @@ -9,6 +13,7 @@ const Ellipsis: React.FC> = ({ children }) => { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + line-height: ${height}; min-width: 0; } `} From e05195ab4877e85ed386fbf6eb2e4f42a9517af1 Mon Sep 17 00:00:00 2001 From: unix Date: Fri, 26 Jun 2020 07:53:16 +0800 Subject: [PATCH 2/2] refactor: migrate to new ellipsis component --- components/auto-complete/auto-complete-item.tsx | 6 +++--- .../select/__tests__/__snapshots__/index.test.tsx.snap | 10 ++++++++++ .../__tests__/__snapshots__/multiple.test.tsx.snap | 1 + components/select/select-option.tsx | 2 +- components/select/select.tsx | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/components/auto-complete/auto-complete-item.tsx b/components/auto-complete/auto-complete-item.tsx index 6d6fb08..a78c315 100644 --- a/components/auto-complete/auto-complete-item.tsx +++ b/components/auto-complete/auto-complete-item.tsx @@ -39,7 +39,7 @@ const AutoCompleteItem: React.FC> return (
- {children} + {children}