Skip to content

Commit e940687

Browse files
authored
Merge pull request #32395 from storybookjs/sidnioulz/issue-32249-tooltip-filesearch-ui-cleanup
UI: Review FileSearchList tooltip behavior and align style with sidebar
2 parents 08d081b + d020218 commit e940687

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

code/core/src/manager/components/sidebar/FileList.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ export const FileListLi = styled('li')(({ theme }) => ({
4242
},
4343
}));
4444

45-
export const FileListItem = styled('div')(({ theme }) => ({
45+
export const FileListItem = styled('div')({
4646
display: 'flex',
4747
flexDirection: 'column',
4848
position: 'relative',
49-
}));
49+
});
5050

5151
export const FileListItemContentWrapper = styled.div<{
5252
selected: boolean;
@@ -141,8 +141,7 @@ export const FileListExport = styled('ul')(({ theme }) => ({
141141
}));
142142

143143
export const FileListItemExport = styled('li')<{ error: boolean }>(({ theme, error }) => ({
144-
padding: '8px 16px 8px 16px',
145-
marginLeft: '30px',
144+
padding: '8px 16px 8px 58px',
146145
display: 'flex',
147146
gap: '8px',
148147
alignItems: 'center',
@@ -188,10 +187,14 @@ export const FileListItemExportNameContent = styled('span')(({ theme }) => ({
188187
whiteSpace: 'nowrap',
189188
textOverflow: 'ellipsis',
190189
overflow: 'hidden',
191-
maxWidth: 'calc(100% - 160px)',
192190
display: 'inline-block',
191+
color: theme.base === 'dark' ? theme.color.lightest : theme.color.darkest,
193192
}));
194193

194+
export const FileListItemExportNameContentWithExport = styled(FileListItemExportNameContent)({
195+
maxWidth: 'calc(100% - 120px)',
196+
});
197+
195198
export const DefaultExport = styled('span')(({ theme }) => ({
196199
display: 'inline-block',
197200
padding: `1px ${theme.appBorderRadius}px`,

code/core/src/manager/components/sidebar/FileSearchList.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import type {
66
FileComponentSearchResponsePayload,
77
} from 'storybook/internal/core-events';
88

9-
import { ChevronDownIcon, ChevronRightIcon, ComponentIcon } from '@storybook/icons';
9+
import {
10+
BookmarkHollowIcon,
11+
ChevronSmallDownIcon,
12+
ChevronSmallRightIcon,
13+
ComponentIcon,
14+
} from '@storybook/icons';
1015

1116
import type { VirtualItem } from '@tanstack/react-virtual';
1217
import { useVirtualizer } from '@tanstack/react-virtual';
@@ -24,6 +29,7 @@ import {
2429
FileListItemExport,
2530
FileListItemExportName,
2631
FileListItemExportNameContent,
32+
FileListItemExportNameContentWithExport,
2733
FileListItemLabel,
2834
FileListItemPath,
2935
FileListLi,
@@ -40,16 +46,14 @@ export interface NewStoryPayload extends CreateNewStoryRequestPayload {
4046
selectedItemId: string | number;
4147
}
4248

43-
const ChevronRightIconStyled = styled(ChevronRightIcon)(({ theme }) => ({
44-
display: 'none',
45-
alignSelf: 'center',
49+
const TreeExpandIconStyled = styled(ChevronSmallRightIcon)(({ theme }) => ({
4650
color: theme.color.mediumdark,
51+
marginTop: 2,
4752
}));
4853

49-
const ChevronDownIconStyled = styled(ChevronDownIcon)(({ theme }) => ({
50-
display: 'none',
51-
alignSelf: 'center',
54+
const TreeCollapseIconStyled = styled(ChevronSmallDownIcon)(({ theme }) => ({
5255
color: theme.color.mediumdark,
56+
marginTop: 2,
5357
}));
5458

5559
interface FileSearchListProps {
@@ -189,6 +193,11 @@ export const FileSearchList = memo(function FileSearchList({
189193
searchResult.exportedComponents?.length === 0
190194
}
191195
>
196+
{itemSelected ? (
197+
<TreeCollapseIconStyled size={14} />
198+
) : (
199+
<TreeExpandIconStyled size={14} />
200+
)}
192201
<FileListIconWrapper error={itemError}>
193202
<ComponentIcon />
194203
</FileListIconWrapper>
@@ -198,7 +207,6 @@ export const FileSearchList = memo(function FileSearchList({
198207
</FileListItemLabel>
199208
<FileListItemPath>{searchResult.filepath}</FileListItemPath>
200209
</FileListItemContent>
201-
{itemSelected ? <ChevronDownIconStyled /> : <ChevronRightIconStyled />}
202210
</FileListItemContentWrapper>
203211
{/* @ts-expect-error (non strict) */}
204212
{searchResult?.exportedComponents?.length > 1 && itemSelected && (
@@ -249,19 +257,20 @@ export const FileSearchList = memo(function FileSearchList({
249257
}}
250258
>
251259
<FileListItemExportName>
252-
<ComponentIcon />
260+
<BookmarkHollowIcon />
253261
{component.default ? (
254262
<>
255-
<FileListItemExportNameContent>
263+
<FileListItemExportNameContentWithExport>
256264
{searchResult.filepath.split('/').at(-1)?.split('.')?.at(0)}
257-
</FileListItemExportNameContent>
265+
</FileListItemExportNameContentWithExport>
258266
<DefaultExport>Default export</DefaultExport>
259267
</>
260268
) : (
261-
component.name
269+
<FileListItemExportNameContent>
270+
{component.name}
271+
</FileListItemExportNameContent>
262272
)}
263273
</FileListItemExportName>
264-
<ChevronRightIconStyled />
265274
</FileListItemExport>
266275
);
267276
})}
@@ -340,15 +349,15 @@ export const FileSearchList = memo(function FileSearchList({
340349
<WithTooltip
341350
{...itemProps}
342351
style={{ width: '100%' }}
352+
trigger="hover"
343353
hasChrome={false}
344-
closeOnOutsideClick={true}
354+
delayHide={100}
355+
delayShow={200}
356+
placement="top-start"
345357
tooltip={
346358
<TooltipNote
347-
// @ts-expect-error (non strict)
348359
note={
349-
noExports
350-
? "We can't evaluate exports for this file. You can't create a story for it automatically"
351-
: null
360+
"We can't evaluate exports for this file. Automatic story creation is disabled."
352361
}
353362
/>
354363
}

0 commit comments

Comments
 (0)