Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit c2b3627

Browse files
MicahRamirezjasonLaster
authored andcommitted
Implement Photon ResultList Design (#5839)
* initial pass on showing the icons in the result list * tweaks * integrated jason's changes, styling needs to be looked over it looks pretty close IMO * addressing cc feedback about getSourceClassnames doing too much, removed unused badge in QuickOpenResult * Ensure all icons are the same size and align; nits * Tweak position of tab icon * Fix jest * Shim around jest errors for now * Reset yarn.lock to master
1 parent 8c3c581 commit c2b3627

File tree

13 files changed

+101
-30
lines changed

13 files changed

+101
-30
lines changed

assets/images/Svg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const svg = {
4747
stepOut: require("./stepOut.svg"),
4848
stepOver: require("./stepOver.svg"),
4949
subSettings: require("./subSettings.svg"),
50+
tab: require("./tab.svg"),
5051
toggleBreakpoints: require("./toggle-breakpoints.svg"),
5152
togglePanes: require("./toggle-panes.svg"),
5253
typescript: require("./typescript.svg"),

assets/images/tab.svg

Lines changed: 6 additions & 0 deletions
Loading

src/components/PrimaryPanes/SourcesTree.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ import {
3838
getDirectories,
3939
isDirectory,
4040
nodeHasChildren,
41-
updateTree,
42-
getExtension
41+
updateTree
4342
} from "../../utils/sources-tree";
4443

45-
import { getRawSourceURL } from "../../utils/source";
44+
import { getRawSourceURL, getSourceClassnames } from "../../utils/source";
4645
import { copyToTheClipboard } from "../../utils/clipboard";
4746
import { features } from "../../utils/prefs";
4847

@@ -72,13 +71,6 @@ type State = {
7271
highlightItems?: any
7372
};
7473

75-
const sourceTypes = {
76-
coffee: "coffeescript",
77-
js: "javascript",
78-
jsx: "react",
79-
ts: "typescript"
80-
};
81-
8274
class SourcesTree extends Component<Props, State> {
8375
focusItem: Function;
8476
selectItem: Function;
@@ -214,13 +206,14 @@ class SourcesTree extends Component<Props, State> {
214206
if (!nodeHasChildren(item)) {
215207
const obj = item.contents.get("id");
216208
const source = sources.get(obj);
217-
if (source && source.get("isBlackBoxed")) {
218-
return <img className="blackBox" />;
219-
}
220-
221-
const sourceType = sourceTypes[getExtension(source)];
222-
const classNames = classnames("source-icon", sourceType || "file");
223-
return <img className={classNames} />;
209+
return (
210+
<img
211+
className={classnames(
212+
getSourceClassnames(source.toJS()),
213+
"source-icon"
214+
)}
215+
/>
216+
);
224217
}
225218

226219
return <img className="folder" />;

src/components/QuickOpenModal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import {
2222
import { scrollList } from "../utils/result-list";
2323
import {
2424
formatSymbols,
25-
formatSources,
2625
parseLineColumn,
27-
formatShortcutResults
26+
formatShortcutResults,
27+
formatSources
2828
} from "../utils/quick-open";
2929
import Modal from "./shared/Modal";
3030
import SearchInput from "./shared/SearchInput";
@@ -419,7 +419,7 @@ function mapStateToProps(state) {
419419

420420
return {
421421
enabled: getQuickOpenEnabled(state),
422-
sources: formatSources(getRelativeSources(state)),
422+
sources: formatSources(getRelativeSources(state), getTabs(state).toArray()),
423423
selectedSource,
424424
symbols: formatSymbols(getSymbols(state, selectedSource)),
425425
symbolsLoading: isSymbolsLoading(state, selectedSource),

src/components/shared/ResultList.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
padding: 10px;
2727
flex-direction: row;
2828
border-bottom: 1px solid var(--theme-splitter-color);
29+
line-height: 18px;
2930
}
3031

3132
.result-list.small li {
@@ -57,8 +58,24 @@
5758
background: var(--grey-70);
5859
}
5960

61+
.result-list li .result-item-icon {
62+
background-color: var(--theme-comment);
63+
}
64+
.result-list li.selected .result-item-icon {
65+
background-color: var(--theme-selection-color);
66+
}
67+
68+
.result-list li .result-item-icon.tab {
69+
mask-size: 150%;
70+
mask-position: 2px 4px;
71+
}
72+
73+
.result-list li img.result-item-icon {
74+
width: 16px;
75+
height: 16px;
76+
}
77+
6078
.result-list li .title {
61-
line-height: 1.5em;
6279
word-break: break-all;
6380
text-overflow: ellipsis;
6481
white-space: nowrap;

src/components/shared/ResultList.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export default class ResultList extends Component<Props> {
5353

5454
return (
5555
<li {...props}>
56+
<div>
57+
<img className={item.icon} />
58+
</div>
5659
<div id={`${item.id}-title`} className="title">
5760
{item.title}
5861
</div>

src/components/shared/Svg.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ img.source-icon {
4747
height: 15px;
4848
}
4949

50+
img.result-item-icon {
51+
height: 18px;
52+
width: 18px;
53+
}
54+
5055
img.domain {
5156
mask: url(/images/domain.svg) no-repeat;
5257
}
@@ -63,6 +68,10 @@ img.javascript {
6368
mask: url(/images/javascript.svg) no-repeat;
6469
}
6570

71+
img.tab {
72+
mask: url(/images/tab.svg) no-repeat;
73+
}
74+
6675
img.react {
6776
mask: url(/images/react.svg) no-repeat;
6877
}
@@ -86,6 +95,13 @@ img.source-icon {
8695
display: inline-block;
8796
}
8897

98+
img.result-item-icon {
99+
mask-size: 100%;
100+
margin-inline-end: 15px;
101+
margin-inline-start: 5px;
102+
display: inline-block;
103+
}
104+
89105
.refresh svg,
90106
.shortcut svg,
91107
.worker svg {

src/components/shared/tests/__snapshots__/ResultList.spec.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ exports[`Result list should render the component 1`] = `
1616
role="option"
1717
title="value"
1818
>
19+
<div>
20+
<img />
21+
</div>
1922
<div
2023
className="title"
2124
id="0-title"
@@ -38,6 +41,9 @@ exports[`Result list should render the component 1`] = `
3841
role="option"
3942
title="value 1"
4043
>
44+
<div>
45+
<img />
46+
</div>
4147
<div
4248
className="title"
4349
id="1-title"

src/components/tests/__snapshots__/QuickOpenModal.spec.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,9 @@ exports[`QuickOpenModal showErrorEmoji false when count + query 1`] = `
865865
onClick={[Function]}
866866
role="option"
867867
>
868+
<div>
869+
<img />
870+
</div>
868871
<div
869872
className="title"
870873
id="undefined-title"
@@ -890,6 +893,9 @@ exports[`QuickOpenModal showErrorEmoji false when count + query 1`] = `
890893
onClick={[Function]}
891894
role="option"
892895
>
896+
<div>
897+
<img />
898+
</div>
893899
<div
894900
className="title"
895901
id="undefined-title"

src/reducers/sources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type { Record } from "../utils/makeRecord";
2424

2525
type Tab = string;
2626
export type SourcesMap = Map<string, SourceRecord>;
27-
type TabList = List<Tab>;
27+
export type TabList = List<Tab>;
2828

2929
export type SourcesState = {
3030
sources: SourcesMap,

0 commit comments

Comments
 (0)