Skip to content

Commit b89feb9

Browse files
bvaughnOrDuan
authored andcommitted
Make Elements panel feel less cluttered (facebook#1091)
Reimagined Settings, TreeView, and Node components.: * Redesigned toolbar to focus more on search and remove clutter * Move "highlight-updates" and "highlight-search" options into settings panel * Changed attribute filtering logic to show all attributes of type number/string/bool and filter others * Elements tree nodes wrap now for better readability * Breadcrumbs doesn't wrap, but scrolls horizontally, to take up less space * Margins and paddings tweaked
1 parent 77edff5 commit b89feb9

File tree

10 files changed

+242
-241
lines changed

10 files changed

+242
-241
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ node_modules
66
npm-debug.log
77
yarn-error.log
88
.DS_Store
9+
yarn-error.log
910

frontend/Breadcrumb.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,26 @@ type State ={
3434

3535
class Breadcrumb extends React.Component<Props, State> {
3636
context: {theme: Theme};
37+
// $FlowFixMe createRef()
38+
selectedListItem = React.createRef();
3739

3840
constructor(props) {
3941
super(props);
4042
this.state = { hovered: null };
4143
}
4244

45+
componentDidMount() {
46+
if (this.props.selected) {
47+
this.ensureInView();
48+
}
49+
}
50+
51+
componentDidUpdate(prevProps, prevState) {
52+
if (this.props.selected !== prevProps.selected) {
53+
this.ensureInView();
54+
}
55+
}
56+
4357
handleCrumbMouseOver(id) {
4458
this.setState({ hovered: id });
4559
this.props.hover(id, true);
@@ -51,11 +65,13 @@ class Breadcrumb extends React.Component<Props, State> {
5165
}
5266

5367
render() {
54-
var theme = this.context.theme;
68+
const {theme} = this.context;
69+
const {path, selected} = this.props;
70+
5571
return (
5672
<ul style={containerStyle(theme)}>
57-
{this.props.path.map(({ id, node }) => {
58-
const isSelected = id === this.props.selected;
73+
{path.map(({ id, node }) => {
74+
const isSelected = id === selected;
5975
const style = itemStyle(
6076
isSelected,
6177
node.get('nodeType'),
@@ -69,6 +85,7 @@ class Breadcrumb extends React.Component<Props, State> {
6985
onMouseOver={() => this.handleCrumbMouseOver(id)}
7086
onMouseOut={() => this.handleCrumbMouseOut(id)}
7187
onClick={isSelected ? null : () => this.props.select(id)}
88+
ref={isSelected ? this.selectedListItem : undefined}
7289
>
7390
{node.get('name') || '"' + node.get('text') + '"'}
7491
</li>
@@ -77,6 +94,21 @@ class Breadcrumb extends React.Component<Props, State> {
7794
</ul>
7895
);
7996
}
97+
98+
ensureInView() {
99+
const selectedListItem = this.selectedListItem.current;
100+
if (selectedListItem != null) {
101+
if (typeof selectedListItem.scrollIntoViewIfNeeded === 'function') {
102+
selectedListItem.scrollIntoViewIfNeeded({
103+
inline: 'nearest',
104+
});
105+
} else if (typeof selectedListItem.scrollIntoView === 'function') {
106+
selectedListItem.scrollIntoView({
107+
inline: 'nearest',
108+
});
109+
}
110+
}
111+
}
80112
}
81113

82114
Breadcrumb.contextTypes = {
@@ -86,13 +118,13 @@ Breadcrumb.contextTypes = {
86118
const containerStyle = (theme: Theme) => ({
87119
fontFamily: sansSerif.family,
88120
listStyle: 'none',
89-
padding: 0,
121+
padding: '0 0.5rem',
90122
margin: 0,
91123
maxHeight: '80px',
92-
overflow: 'auto',
93-
marginTop: '2px',
94124
backgroundColor: theme.base01,
95125
borderTop: `1px solid ${theme.base03}`,
126+
whiteSpace: 'nowrap',
127+
overflow: 'auto',
96128
});
97129

98130
const itemStyle = (isSelected: boolean, nodeType: string, theme: Theme) => {
@@ -114,7 +146,6 @@ const itemStyle = (isSelected: boolean, nodeType: string, theme: Theme) => {
114146
MozUserSelect: 'none',
115147
userSelect: 'none',
116148
display: 'inline-block',
117-
marginRight: '2px',
118149
};
119150
};
120151

frontend/DataView/DataView.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import type {Theme, DOMEvent} from '../types';
1414

15-
const {sansSerif} = require('../Themes/Fonts');
1615
const PropTypes = require('prop-types');
1716
const React = require('react');
1817
const Simple = require('./Simple');
@@ -317,51 +316,44 @@ function alphanumericSort(a: string, b: string): number {
317316
const nameStyle = (isComplex: boolean, theme: Theme) => ({
318317
cursor: isComplex ? 'pointer' : 'default',
319318
color: theme.special03,
320-
margin: '2px 3px',
319+
margin: '0 0.25rem',
321320
});
322321

323322
const previewStyle = (theme: Theme) => ({
324323
display: 'flex',
325-
margin: '2px 3px',
326324
whiteSpace: 'pre',
327325
wordBreak: 'break-word',
328326
flex: 1,
329327
color: theme.special01,
330328
});
331329

332330
const emptyStyle = (theme: Theme) => ({
333-
marginLeft: '0.75rem',
334-
padding: '0 5px',
331+
lineHeight: '1.25rem',
335332
color: theme.base04,
336-
fontFamily: sansSerif.family,
337-
fontSize: sansSerif.sizes.normal,
338-
fontStyle: 'italic',
333+
paddingLeft: '1rem',
339334
});
340335

341336
const missingStyle = (theme: Theme) => ({
342-
fontSize: sansSerif.sizes.normal,
343337
fontWeight: 'bold',
344-
marginLeft: '0.75rem',
345-
padding: '2px 5px',
338+
lineHeight: '1.25rem',
346339
color: theme.base03,
340+
paddingLeft: '1rem',
347341
});
348342

349343
const collapsedArrowStyle = (theme: Theme) => ({
350344
borderColor: `transparent transparent transparent ${theme.base03}`,
351345
borderStyle: 'solid',
352-
borderWidth: '4px 0 4px 7px',
346+
borderWidth: '4px 0 4px 6px',
353347
display: 'inline-block',
354-
marginLeft: 1,
355-
verticalAlign: 'top',
348+
verticalAlign: 'middle',
356349
});
357350

358351
const expandedArrowStyle = (theme: Theme) => ({
359352
borderColor: `${theme.base03} transparent transparent transparent`,
360353
borderStyle: 'solid',
361-
borderWidth: '7px 4px 0 4px',
354+
borderWidth: '6px 4px 0 4px',
362355
display: 'inline-block',
363-
marginTop: 1,
364-
verticalAlign: 'top',
356+
verticalAlign: 'middle',
365357
});
366358

367359
const sparseArrayHoleStyle = (theme: Theme) => ({
@@ -384,9 +376,7 @@ var styles = {
384376
opener: {
385377
cursor: 'pointer',
386378
marginLeft: -10,
387-
paddingRight: 3,
388379
position: 'absolute',
389-
top: 4,
390380
},
391381

392382
toggler: {
@@ -398,6 +388,7 @@ var styles = {
398388
head: {
399389
display: 'flex',
400390
position: 'relative',
391+
lineHeight: '1.25rem',
401392
},
402393

403394
value: {

0 commit comments

Comments
 (0)