Skip to content

Commit

Permalink
fix: ellipsis the title when width is too narrow (#412)
Browse files Browse the repository at this point in the history
* fix: ellipsis the title when width is too narrow

* test: update snapshots with collapse
  • Loading branch information
mortalYoung authored Sep 7, 2021
1 parent 86da4ce commit 55efbb7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/components/collapse/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const collapseHeaderClassName = getBEMElement(
defaultCollapseClassName,
'header'
);
export const collapseTitleClassName = getBEMElement(
collapseHeaderClassName,
'title'
);
export const collapseContentClassName = getBEMElement(
defaultCollapseClassName,
'content'
Expand Down
5 changes: 4 additions & 1 deletion src/components/collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
collapseHeaderClassName,
collapseExtraClassName,
collapseContentClassName,
collapseTitleClassName,
} from './base';
import { select } from 'mo/common/dom';

Expand Down Expand Up @@ -371,7 +372,9 @@ export function Collapse(props: ICollapseProps) {
: 'chevron-right'
}
/>
{panel.name}
<span className={collapseTitleClassName}>
{panel.name}
</span>
<div className={collapseExtraClassName}>
{isActive && (
<Toolbar
Expand Down
6 changes: 6 additions & 0 deletions src/components/collapse/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ $collapse__extra: #{$collapse}__extra;
&:focus {
border-color: var(--list-focusOutline);
}

&__title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

&__extra {
Expand Down
18 changes: 15 additions & 3 deletions src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ exports[`Test Workbench Component Match The WorkbenchView snapshot 1`] = `
<span
class="codicon codicon-chevron-right"
/>
打开的编辑器
<span
class="mo-collapse__header__title"
>
打开的编辑器
</span>
<div
class="mo-collapse__extra"
/>
Expand All @@ -156,7 +160,11 @@ exports[`Test Workbench Component Match The WorkbenchView snapshot 1`] = `
<span
class="codicon codicon-chevron-right"
/>
无打开文件夹
<span
class="mo-collapse__header__title"
>
无打开文件夹
</span>
<div
class="mo-collapse__extra"
/>
Expand Down Expand Up @@ -193,7 +201,11 @@ exports[`Test Workbench Component Match The WorkbenchView snapshot 1`] = `
<span
class="codicon codicon-chevron-right"
/>
轮廓
<span
class="mo-collapse__header__title"
>
轮廓
</span>
<div
class="mo-collapse__extra"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ exports[`The Explorer Component Match Snapshot 1`] = `
<span
className="codicon codicon-chevron-right"
/>
Open
<span
className="mo-collapse__header__title"
>
Open
</span>
<div
className="mo-collapse__extra"
/>
Expand All @@ -84,7 +88,11 @@ exports[`The Explorer Component Match Snapshot 1`] = `
<span
className="codicon codicon-chevron-right"
/>
test
<span
className="mo-collapse__header__title"
>
test
</span>
<div
className="mo-collapse__extra"
/>
Expand Down

0 comments on commit 55efbb7

Please sign in to comment.