Skip to content

Commit

Permalink
fix(file-explorer): trim and avoid shrinks the icon on long file names (
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Sep 26, 2022
1 parent 121cf65 commit bc12d03
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion sandpack-react/src/components/FileExplorer/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const explorerClassName = css({
padding: 0,
marginBottom: "$space$2",

span: {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
overflow: "hidden",
},

svg: {
marginRight: "$space$1",
},
Expand Down Expand Up @@ -61,10 +67,11 @@ export const File: React.FC<Props> = ({
data-active={active}
onClick={onClickButton}
style={{ paddingLeft: 18 * depth + "px" }}
title={fileName}
type="button"
>
{getIcon()}
{fileName}
<span>{fileName}</span>
</button>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const Component: React.FC = () => (
"/index.tsx": "",
"/src/app.tsx": "",
"/src/components/button.tsx": "",
"/src/components/really-loooooooong-naaameeee.tsx": "",
}}
theme="dark"
>
Expand Down
2 changes: 1 addition & 1 deletion sandpack-react/src/presets/Sandpack.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("getSandpackCssText", () => {
</SandpackProvider>
);

expect(getSandpackCssText().length).toBe(4315);
expect(getSandpackCssText().length).toBe(4343);
expect(getSandpackCssText()).not.toContain(componentClassName);
});

Expand Down
1 change: 1 addition & 0 deletions sandpack-react/src/styles/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const buttonClassName = css({
'&[data-active="true"]': { color: "$colors$accent" },

svg: {
minWidth: "$space$4",
width: "$space$4",
height: "$space$4",
},
Expand Down

0 comments on commit bc12d03

Please sign in to comment.