Fix React devtools experience

Summary:
Currently most components are shown anonymously in the component tree, because using `styled` creates unnamed components, shown as the HTML elements they result in.

This has two downsides:
1. React errors / warnings are really vague and it is hard to locate where they are coming from
2. The React Devtools don't show which components are rendering.
3. The effect of the latter it is hard to copy-from-example when developing plugins. This leads to a lot of inconsitency and duplication in the layouts of components

Reviewed By: jknoxville

Differential Revision: D18503675

fbshipit-source-id: 5a9ea1765346fb4c6a49e37ffa4d0b4bbcd86587
This commit is contained in:
Michel Weststrate
2019-11-15 02:08:05 -08:00
committed by Facebook Github Bot
parent 24097ea9b2
commit 0a8222410c
62 changed files with 183 additions and 20 deletions

View File

@@ -5,28 +5,28 @@ exports[`notifications for leaks 1`] = `
<Styled(div)> <Styled(div)>
CloseableReference leaked for CloseableReference leaked for
<Styled(span) <Text
code={true} code={true}
> >
com.facebook.imagepipeline.memory.NativeMemoryChunk com.facebook.imagepipeline.memory.NativeMemoryChunk
</Styled(span)> </Text>
(identity hashcode: (identity hashcode:
deadbeef deadbeef
). ).
</Styled(div)> </Styled(div)>
<Styled(div)> <Styled(div)>
<Styled(span) <Text
bold={true} bold={true}
> >
Stacktrace: Stacktrace:
</Styled(span)> </Text>
</Styled(div)> </Styled(div)>
<Styled(div)> <Styled(div)>
<Styled(span) <Text
code={true} code={true}
> >
&lt;unavailable&gt; &lt;unavailable&gt;
</Styled(span)> </Text>
</Styled(div)> </Styled(div)>
</React.Fragment> </React.Fragment>
`; `;

View File

@@ -9,6 +9,12 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled('div')({ /**
* A Block styled div
*/
const Block = styled('div')({
display: 'block', display: 'block',
}); });
Block.displayName = 'Block';
export default Block;

View File

@@ -10,9 +10,12 @@
import FlexBox from './FlexBox'; import FlexBox from './FlexBox';
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled(FlexBox)({ const Box = styled(FlexBox)({
height: '100%', height: '100%',
overflow: 'auto', overflow: 'auto',
position: 'relative', position: 'relative',
width: '100%', width: '100%',
}); });
Box.displayName = 'Box';
export default Box;

View File

@@ -185,10 +185,12 @@ const StyledButton = styled('div')(
}, },
}), }),
); );
StyledButton.displayName = 'Button:StyledButton';
const Icon = styled(Glyph)(({hasText}: {hasText: boolean}) => ({ const Icon = styled(Glyph)(({hasText}: {hasText: boolean}) => ({
marginRight: hasText ? 3 : 0, marginRight: hasText ? 3 : 0,
})); }));
Icon.displayName = 'Button:Icon';
type OwnProps = { type OwnProps = {
/** /**

View File

@@ -18,6 +18,7 @@ const ButtonGroupContainer = styled('div')({
marginLeft: 0, marginLeft: 0,
}, },
}); });
ButtonGroupContainer.displayName = 'ButtonGroup:ButtonGroupContainer';
/** /**
* Group a series of buttons together. * Group a series of buttons together.

View File

@@ -19,6 +19,7 @@ const IconContainer = styled('div')({
alignItems: 'center', alignItems: 'center',
pointerEvents: 'none', pointerEvents: 'none',
}); });
IconContainer.displayName = 'ButtonGroupChain:IconContainer';
const ButtonGroupChainContainer = styled('div')( const ButtonGroupChainContainer = styled('div')(
(props: {iconSize: number}) => ({ (props: {iconSize: number}) => ({
@@ -39,6 +40,7 @@ const ButtonGroupChainContainer = styled('div')(
}, },
}), }),
); );
IconContainer.displayName = 'ButtonGroupChain:ButtonGroupChainContainer';
type Props = { type Props = {
/** /**

View File

@@ -23,6 +23,7 @@ const CheckboxContainer = styled('input')({
marginRight: 5, marginRight: 5,
verticalAlign: 'middle', verticalAlign: 'middle',
}); });
CheckboxContainer.displayName = 'Checkbox:CheckboxContainer';
/** /**
* A checkbox to toggle UI state * A checkbox to toggle UI state

View File

@@ -9,6 +9,9 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled('div')({ const CodeBlock = styled('div')({
fontFamily: 'monospace', fontFamily: 'monospace',
}); });
CodeBlock.displayName = 'CodeBlock';
export default CodeBlock;

View File

@@ -18,6 +18,7 @@ type MenuTemplate = Array<MenuItemConstructorOptions>;
const Container = styled('div')({ const Container = styled('div')({
display: 'contents', display: 'contents',
}); });
Container.displayName = 'ContextMenuProvider:Container';
/** /**
* Flipper's root is already wrapped with this component, so plugins should not * Flipper's root is already wrapped with this component, so plugins should not

View File

@@ -20,6 +20,7 @@ export const ErrorBlockContainer = styled(CodeBlock)({
padding: 10, padding: 10,
whiteSpace: 'pre', whiteSpace: 'pre',
}); });
ErrorBlockContainer.displayName = 'ErrorBlock:ErrorBlockContainer';
/** /**
* Displaying error messages in a red box. * Displaying error messages in a red box.

View File

@@ -19,11 +19,13 @@ const ErrorBoundaryContainer = styled(View)({
overflow: 'auto', overflow: 'auto',
padding: 10, padding: 10,
}); });
ErrorBoundaryContainer.displayName = 'ErrorBoundary:ErrorBoundaryContainer';
const ErrorBoundaryStack = styled(ErrorBlock)({ const ErrorBoundaryStack = styled(ErrorBlock)({
marginBottom: 10, marginBottom: 10,
whiteSpace: 'pre', whiteSpace: 'pre',
}); });
ErrorBoundaryStack.displayName = 'ErrorBoundary:ErrorBoundaryStack';
type ErrorBoundaryProps = { type ErrorBoundaryProps = {
/** Function to dynamically generate the heading of the ErrorBox. */ /** Function to dynamically generate the heading of the ErrorBox. */

View File

@@ -18,7 +18,10 @@ type Props = {
/** /**
* A container using flexbox to layout its children * A container using flexbox to layout its children
*/ */
export default styled(View)(({shrink}: Props) => ({ const FlexBox = styled(View)(({shrink}: Props) => ({
display: 'flex', display: 'flex',
flexShrink: shrink == null || shrink ? 1 : 0, flexShrink: shrink == null || shrink ? 1 : 0,
})); }));
FlexBox.displayName = 'FlexBox';
export default FlexBox;

View File

@@ -13,8 +13,11 @@ import styled from 'react-emotion';
/** /**
* A container displaying its children horizontally and vertically centered. * A container displaying its children horizontally and vertically centered.
*/ */
export default styled(View)({ const FlexCenter = styled(View)({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}); });
FlexCenter.displayName = 'FlexCenter';
export default FlexCenter;

View File

@@ -13,6 +13,9 @@ import styled from 'react-emotion';
/** /**
* A container displaying its children in a column * A container displaying its children in a column
*/ */
export default styled(FlexBox)({ const FlexColumn = styled(FlexBox)({
flexDirection: 'column', flexDirection: 'column',
}); });
FlexColumn.displayName = 'FlexColumn';
export default FlexColumn;

View File

@@ -13,6 +13,9 @@ import styled from 'react-emotion';
/** /**
* A container displaying its children in a row * A container displaying its children in a row
*/ */
export default styled(FlexBox)({ const FlexRow = styled(FlexBox)({
flexDirection: 'row', flexDirection: 'row',
}); });
FlexRow.displayName = 'FlexRow';
export default FlexRow;

View File

@@ -22,6 +22,7 @@ const FocusableBoxBorder = styled(Box)({
right: '0', right: '0',
top: '0', top: '0',
}); });
FocusableBoxBorder.displayName = 'FocusableBox:FocusableBoxBorder';
type Props = { type Props = {
onBlur?: (e: React.FocusEvent) => void; onBlur?: (e: React.FocusEvent) => void;

View File

@@ -20,6 +20,7 @@ const ColoredIconBlack = styled('img')(({size}: {size: number}) => ({
width: size, width: size,
flexShrink: 0, flexShrink: 0,
})); }));
ColoredIconBlack.displayName = 'Glyph:ColoredIconBlack';
const ColoredIconCustom = styled('div')( const ColoredIconCustom = styled('div')(
(props: {size: number; color?: string; src: string}) => ({ (props: {size: number; color?: string; src: string}) => ({
@@ -35,6 +36,7 @@ const ColoredIconCustom = styled('div')(
flexShrink: 0, flexShrink: 0,
}), }),
); );
ColoredIconCustom.displayName = 'Glyph:ColoredIconCustom';
function ColoredIcon( function ColoredIcon(
props: { props: {
@@ -79,7 +81,7 @@ function ColoredIcon(
); );
} }
} }
ColoredIcon.displayName = 'Glyph:ColoredIcon';
ColoredIcon.contextTypes = { ColoredIcon.contextTypes = {
glyphColor: PropTypes.string, glyphColor: PropTypes.string,
}; };

View File

@@ -17,6 +17,7 @@ const LargeHeading = styled('div')({
borderBottom: '1px solid #ddd', borderBottom: '1px solid #ddd',
marginBottom: 10, marginBottom: 10,
}); });
LargeHeading.displayName = 'Heading:LargeHeading';
const SmallHeading = styled('div')({ const SmallHeading = styled('div')({
fontSize: 12, fontSize: 12,
@@ -25,6 +26,7 @@ const SmallHeading = styled('div')({
marginBottom: 10, marginBottom: 10,
textTransform: 'uppercase', textTransform: 'uppercase',
}); });
SmallHeading.displayName = 'Heading:SmallHeading';
/** /**
* A heading component. * A heading component.

View File

@@ -9,8 +9,11 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled('div')({ const HorizontalRule = styled('div')({
backgroundColor: '#c9ced4', backgroundColor: '#c9ced4',
height: 1, height: 1,
margin: '5px 0', margin: '5px 0',
}); });
HorizontalRule.displayName = 'HorizontalRule';
export default HorizontalRule;

View File

@@ -31,6 +31,8 @@ const Input = styled('input')(({compact}: {compact?: boolean}) => ({
padding: compact ? '0 5px' : '0 10px', padding: compact ? '0 5px' : '0 10px',
})); }));
Input.displayName = 'Input';
Input.defaultProps = { Input.defaultProps = {
type: 'text', type: 'text',
}; };

View File

@@ -93,6 +93,7 @@ type InteractiveState = {
const InteractiveContainer = styled('div')({ const InteractiveContainer = styled('div')({
willChange: 'transform, height, width, z-index', willChange: 'transform, height, width, z-index',
}); });
InteractiveContainer.displayName = 'Interactive:InteractiveContainer';
export default class Interactive extends React.Component< export default class Interactive extends React.Component<
InteractiveProps, InteractiveProps,

View File

@@ -9,7 +9,10 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled('div')({ const Label = styled('div')({
fontSize: 12, fontSize: 12,
fontWeight: 'bold', fontWeight: 'bold',
}); });
Label.displayName = 'Label';
export default Label;

View File

@@ -20,6 +20,7 @@ const StyledLink = styled('span')({
textDecoration: 'underline', textDecoration: 'underline',
}, },
}); });
StyledLink.displayName = 'Link:StyledLink';
export default class Link extends Component<{ export default class Link extends Component<{
href: string; href: string;

View File

@@ -30,6 +30,8 @@ const LoadingIndicator = styled('div')((props: {size: number}) => ({
borderLeftColor: 'rgba(0, 0, 0, 0.4)', borderLeftColor: 'rgba(0, 0, 0, 0.4)',
})); }));
LoadingIndicator.displayName = 'LoadingIndicator';
LoadingIndicator.defaultProps = { LoadingIndicator.defaultProps = {
size: 50, size: 50,
}; };

View File

@@ -43,6 +43,7 @@ const Markers = styled('div')((props: {totalTime: number}) => ({
left: 5, left: 5,
}, },
})); }));
Markers.displayName = 'MarkerTimeline:Markers';
const Point = styled(FlexRow)( const Point = styled(FlexRow)(
(props: { (props: {
@@ -104,6 +105,7 @@ const Point = styled(FlexRow)(
}, },
}), }),
); );
Point.displayName = 'MakerTimeline:Point';
const Time = styled('span')({ const Time = styled('span')({
color: colors.light30, color: colors.light30,
@@ -111,12 +113,14 @@ const Time = styled('span')({
marginRight: 4, marginRight: 4,
marginTop: -2, marginTop: -2,
}); });
Time.displayName = 'MakerTimeline:Time';
const Code = styled(Text)({ const Code = styled(Text)({
overflow: 'hidden', overflow: 'hidden',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
marginTop: -1, marginTop: -1,
}); });
Code.displayName = 'MakerTimeline:Code';
type TimePoint = { type TimePoint = {
timestamp: number; timestamp: number;

View File

@@ -23,6 +23,7 @@ const Overlay = styled('div')({
top: 0, top: 0,
zIndex: 99999, zIndex: 99999,
}); });
Overlay.displayName = 'ModalOverlay:Overlay';
export default class ModalOverlay extends Component<{ export default class ModalOverlay extends Component<{
onClose: () => void; onClose: () => void;

View File

@@ -30,5 +30,6 @@ const MultiLineInput = styled('textarea')({
...multilineStyle, ...multilineStyle,
padding: '0 10px', padding: '0 10px',
}); });
MultiLineInput.displayName = 'MultiLineInput';
export default MultiLineInput; export default MultiLineInput;

View File

@@ -41,12 +41,14 @@ type TabSizes = {
const OrderableContainer = styled('div')({ const OrderableContainer = styled('div')({
position: 'relative', position: 'relative',
}); });
OrderableContainer.displayName = 'Orderable:OrderableContainer';
const OrderableItemContainer = styled('div')( const OrderableItemContainer = styled('div')(
(props: {orientation: 'vertical' | 'horizontal'}) => ({ (props: {orientation: 'vertical' | 'horizontal'}) => ({
display: props.orientation === 'vertical' ? 'block' : 'inline-block', display: props.orientation === 'vertical' ? 'block' : 'inline-block',
}), }),
); );
OrderableItemContainer.displayName = 'Orderable:OrderableItemContainer';
class OrderableItem extends Component<{ class OrderableItem extends Component<{
orientation: OrderableOrientation; orientation: OrderableOrientation;

View File

@@ -21,6 +21,7 @@ const Chevron = styled(Glyph)({
marginLeft: -2, marginLeft: -2,
marginBottom: 1, marginBottom: 1,
}); });
Chevron.displayName = 'Panel:Chevron';
/** /**
* A Panel component. * A Panel component.

View File

@@ -19,6 +19,7 @@ const Anchor = styled('img')({
left: '50%', left: '50%',
transform: 'translate(-50%, calc(100% + 2px))', transform: 'translate(-50%, calc(100% + 2px))',
}); });
Anchor.displayName = 'Popover.Anchor';
type Opts = { type Opts = {
minWidth?: number; minWidth?: number;
@@ -56,6 +57,7 @@ const PopoverContainer = styled(FlexColumn)((props: {opts?: Opts}) => ({
backgroundColor: colors.white, backgroundColor: colors.white,
}, },
})); }));
PopoverContainer.displayName = 'Popover:PopoverContainer';
type Props = { type Props = {
children: React.ReactNode; children: React.ReactNode;

View File

@@ -21,6 +21,7 @@ const IFrame = styled('iframe')({
top: 0, top: 0,
left: 0, left: 0,
}); });
IFrame.displayName = 'ResizeSensor:IFrame';
/** /**
* Listener for resize events. * Listener for resize events.

View File

@@ -16,15 +16,18 @@ const Label = styled('label')({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
}); });
Label.displayName = 'Select:Label';
const LabelText = styled(Text)({ const LabelText = styled(Text)({
fontWeight: 500, fontWeight: 500,
marginRight: 5, marginRight: 5,
}); });
LabelText.displayName = 'Select:LabelText';
const SelectMenu = styled('select')((props: {grow?: boolean}) => ({ const SelectMenu = styled('select')((props: {grow?: boolean}) => ({
flexGrow: props.grow ? 1 : 0, flexGrow: props.grow ? 1 : 0,
})); }));
SelectMenu.displayName = 'Select:SelectMenu';
/** /**
* Dropdown to select from a list of options * Dropdown to select from a list of options

View File

@@ -23,6 +23,7 @@ import React from 'react';
const SidebarInteractiveContainer = styled(Interactive)({ const SidebarInteractiveContainer = styled(Interactive)({
flex: 'none', flex: 'none',
}); });
SidebarInteractiveContainer.displayName = 'Sidebar:SidebarInteractiveContainer';
type SidebarPosition = 'left' | 'top' | 'right' | 'bottom'; type SidebarPosition = 'left' | 'top' | 'right' | 'bottom';
@@ -45,6 +46,7 @@ const SidebarContainer = styled(FlexColumn)(
whiteSpace: props.overflow ? 'nowrap' : 'normal', whiteSpace: props.overflow ? 'nowrap' : 'normal',
}), }),
); );
SidebarContainer.displayName = 'Sidebar:SidebarContainer';
type SidebarProps = { type SidebarProps = {
/** /**

View File

@@ -11,8 +11,11 @@ import {colors} from './colors';
import Label from './Label'; import Label from './Label';
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled(Label)({ const SidebarLabel = styled(Label)({
color: colors.blackAlpha30, color: colors.blackAlpha30,
fontSize: 12, fontSize: 12,
padding: 10, padding: 10,
}); });
SidebarLabel.displayName = 'SidebarLabel';
export default SidebarLabel;

View File

@@ -35,6 +35,7 @@ const Padder = styled('div')(
backgroundColor, backgroundColor,
}), }),
); );
Padder.displayName = 'StackTrace:Padder';
const Container = styled('div')( const Container = styled('div')(
({isCrash, padded}: {isCrash?: boolean; padded?: boolean}) => ({ ({isCrash, padded}: {isCrash?: boolean; padded?: boolean}) => ({
@@ -46,6 +47,7 @@ const Container = styled('div')(
overflow: 'hidden', overflow: 'hidden',
}), }),
); );
Container.displayName = 'StackTrace:Container';
const Title = styled(FlexRow)(({isCrash}: {isCrash?: boolean}) => ({ const Title = styled(FlexRow)(({isCrash}: {isCrash?: boolean}) => ({
color: isCrash ? colors.red : 'inherit', color: isCrash ? colors.red : 'inherit',
@@ -53,12 +55,14 @@ const Title = styled(FlexRow)(({isCrash}: {isCrash?: boolean}) => ({
alignItems: 'center', alignItems: 'center',
minHeight: 32, minHeight: 32,
})); }));
Title.displayName = 'StackTrace:Title';
const Reason = styled(Text)(({isCrash}: {isCrash?: boolean}) => ({ const Reason = styled(Text)(({isCrash}: {isCrash?: boolean}) => ({
color: isCrash ? colors.red : colors.light80, color: isCrash ? colors.red : colors.light80,
fontWeight: 'bold', fontWeight: 'bold',
fontSize: 13, fontSize: 13,
})); }));
Reason.displayName = 'StackTrace:Reason';
const Line = styled(Text)( const Line = styled(Text)(
({isCrash, isBold}: {isCrash?: boolean; isBold?: boolean}) => ({ ({isCrash, isBold}: {isCrash?: boolean; isBold?: boolean}) => ({
@@ -66,8 +70,10 @@ const Line = styled(Text)(
fontWeight: isBold ? 'bold' : 'normal', fontWeight: isBold ? 'bold' : 'normal',
}), }),
); );
Line.displayName = 'StackTrace:Line';
const Icon = styled(Glyph)({marginRight: 5}); const Icon = styled(Glyph)({marginRight: 5});
Icon.displayName = 'StackTrace:Icon';
const COLUMNS = { const COLUMNS = {
lineNumber: 40, lineNumber: 40,

View File

@@ -18,6 +18,7 @@ const DownscaledGlyph = styled(Glyph)({
height: 12, height: 12,
width: 12, width: 12,
}); });
DownscaledGlyph.displayName = 'StarButton:DownscaledGlyph';
export function StarButton({ export function StarButton({
starred, starred,

View File

@@ -29,5 +29,6 @@ const StatusIndicator = styled('div')(
width: diameter, width: diameter,
}), }),
); );
StatusIndicator.displayName = 'StatusIndicator';
export default StatusIndicator; export default StatusIndicator;

View File

@@ -21,6 +21,7 @@ const TabList = styled(FlexRow)({
justifyContent: 'center', justifyContent: 'center',
alignItems: 'stretch', alignItems: 'stretch',
}); });
TabList.displayName = 'Tabs:TabList';
const TabListItem = styled('div')( const TabListItem = styled('div')(
(props: { (props: {
@@ -65,6 +66,7 @@ const TabListItem = styled('div')(
}, },
}), }),
); );
TabListItem.displayName = 'Tabs:TabListItem';
const TabListAddItem = styled(TabListItem)({ const TabListAddItem = styled(TabListItem)({
borderRight: 'none', borderRight: 'none',
@@ -72,6 +74,7 @@ const TabListAddItem = styled(TabListItem)({
flexGrow: 0, flexGrow: 0,
fontWeight: 'bold', fontWeight: 'bold',
}); });
TabListAddItem.displayName = 'Tabs:TabListAddItem';
const CloseButton = styled('div')({ const CloseButton = styled('div')({
color: '#000', color: '#000',
@@ -91,16 +94,19 @@ const CloseButton = styled('div')({
color: '#fff', color: '#fff',
}, },
}); });
CloseButton.displayName = 'Tabs:CloseButton';
const OrderableContainer = styled('div')({ const OrderableContainer = styled('div')({
display: 'inline-block', display: 'inline-block',
}); });
OrderableContainer.displayName = 'Tabs:OrderableContainer';
const TabContent = styled('div')({ const TabContent = styled('div')({
height: '100%', height: '100%',
overflow: 'auto', overflow: 'auto',
width: '100%', width: '100%',
}); });
TabContent.displayName = 'Tabs:TabContent';
/** /**
* A Tabs component. * A Tabs component.

View File

@@ -19,10 +19,11 @@ const Container = styled('div')({
marginTop: 11, marginTop: 11,
marginBottom: 10, marginBottom: 10,
}); });
Container.displayName = 'TabsContainer:Container';
export const TabsContext = React.createContext(true); export const TabsContext = React.createContext(true);
export default function(props: {children: any}) { export default function TabsContainer(props: {children: any}) {
return ( return (
<Container> <Container>
<TabsContext.Provider value={true}>{props.children}</TabsContext.Provider> <TabsContext.Provider value={true}>{props.children}</TabsContext.Provider>

View File

@@ -55,5 +55,6 @@ const Text = styled('span')(
: props.whiteSpace, : props.whiteSpace,
}), }),
); );
Text.displayName = 'Text';
export default Text; export default Text;

View File

@@ -19,5 +19,6 @@ const TextParagraph = styled('div')({
marginBottom: 0, marginBottom: 0,
}, },
}); });
TextParagraph.displayName = 'TextParagraph';
export default TextParagraph; export default TextParagraph;

View File

@@ -10,9 +10,12 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
import {inputStyle} from './Input'; import {inputStyle} from './Input';
export default styled('textarea')(({compact}: {compact?: boolean}) => ({ const Textarea = styled('textarea')(({compact}: {compact?: boolean}) => ({
...inputStyle(compact || false), ...inputStyle(compact || false),
lineHeight: 'normal', lineHeight: 'normal',
padding: compact ? '5px' : '8px', padding: compact ? '5px' : '8px',
resize: 'none', resize: 'none',
})); }));
Textarea.displayName = 'Textarea';
export default Textarea;

View File

@@ -34,16 +34,19 @@ export const StyledButton = styled('div')((props: {toggled: boolean}) => ({
transition: 'all cubic-bezier(0.3, 1.5, 0.7, 1) 0.3s', transition: 'all cubic-bezier(0.3, 1.5, 0.7, 1) 0.3s',
}, },
})); }));
StyledButton.displayName = 'ToggleSwitch:StyledButton';
const Container = styled(FlexRow)({ const Container = styled(FlexRow)({
alignItems: 'center', alignItems: 'center',
cursor: 'pointer', cursor: 'pointer',
}); });
Container.displayName = 'ToggleSwitch:Container';
const Label = styled(Text)({ const Label = styled(Text)({
marginLeft: 7, marginLeft: 7,
marginRight: 7, marginRight: 7,
}); });
Label.displayName = 'ToggleSwitch:Label';
type Props = { type Props = {
/** /**

View File

@@ -34,9 +34,11 @@ const Toolbar = styled(FlexRow)(
width: '100%', width: '100%',
}), }),
); );
Toolbar.displayName = 'Toolbar';
export const Spacer = styled(FlexBox)({ export const Spacer = styled(FlexBox)({
flexGrow: 1, flexGrow: 1,
}); });
Spacer.displayName = 'Spacer';
export default Toolbar; export default Toolbar;

View File

@@ -15,6 +15,7 @@ import PropTypes from 'prop-types';
const TooltipContainer = styled('div')({ const TooltipContainer = styled('div')({
display: 'contents', display: 'contents',
}); });
TooltipContainer.displayName = 'Tooltip:TooltipContainer';
type TooltipProps = { type TooltipProps = {
/** Content shown in the tooltip */ /** Content shown in the tooltip */

View File

@@ -83,6 +83,7 @@ const TooltipBubble = styled('div')(
color: props.options.color, color: props.options.color,
}), }),
); );
TooltipBubble.displayName = 'TooltipProvider:TooltipBubble';
// vertical offset on bubble when position is 'below' // vertical offset on bubble when position is 'below'
const BUBBLE_BELOW_POSITION_VERTICAL_OFFSET = -10; const BUBBLE_BELOW_POSITION_VERTICAL_OFFSET = -10;
@@ -120,6 +121,7 @@ const TooltipTail = styled('div')(
right: props.right, right: props.right,
}), }),
); );
TooltipTail.displayName = 'TooltipProvider:TooltipTail';
type TooltipProps = { type TooltipProps = {
children: React.ReactNode; children: React.ReactNode;

View File

@@ -9,8 +9,11 @@
import styled from 'react-emotion'; import styled from 'react-emotion';
export default styled('div')({ const VerticalRule = styled('div')({
backgroundColor: '#c9ced4', backgroundColor: '#c9ced4',
width: 3, width: 3,
margin: '0', margin: '0',
}); });
VerticalRule.displayName = 'VerticalRule';
export default VerticalRule;

View File

@@ -20,5 +20,6 @@ const View = styled('div')((props: Props) => ({
position: 'relative', position: 'relative',
width: props.grow ? '100%' : 'auto', width: props.grow ? '100%' : 'auto',
})); }));
View.displayName = 'View';
export default View; export default View;

View File

@@ -24,6 +24,7 @@ const Inner = styled(FlexColumn)(
width: '100%', width: '100%',
}), }),
); );
Inner.displayName = 'VirtualList:Inner';
const Content = styled(FlexColumn)(({top}: {top: TopProperty<number>}) => ({ const Content = styled(FlexColumn)(({top}: {top: TopProperty<number>}) => ({
alignItems: 'flex-start', alignItems: 'flex-start',
@@ -32,6 +33,7 @@ const Content = styled(FlexColumn)(({top}: {top: TopProperty<number>}) => ({
minWidth: '100%', minWidth: '100%',
overflow: 'visible', overflow: 'visible',
})); }));
Content.displayName = 'VirtualList:Content';
type VirtualListProps = { type VirtualListProps = {
data: Array<any>; data: Array<any>;

View File

@@ -21,26 +21,32 @@ import React, {KeyboardEvent} from 'react';
const NullValue = styled('span')({ const NullValue = styled('span')({
color: 'rgb(128, 128, 128)', color: 'rgb(128, 128, 128)',
}); });
NullValue.displayName = 'DataDescription:NullValue';
const UndefinedValue = styled('span')({ const UndefinedValue = styled('span')({
color: 'rgb(128, 128, 128)', color: 'rgb(128, 128, 128)',
}); });
UndefinedValue.displayName = 'DataDescription:UndefinedValue';
const StringValue = styled('span')({ const StringValue = styled('span')({
color: colors.cherryDark1, color: colors.cherryDark1,
}); });
StringValue.displayName = 'DataDescription:StringValue';
const ColorValue = styled('span')({ const ColorValue = styled('span')({
color: colors.blueGrey, color: colors.blueGrey,
}); });
ColorValue.displayName = 'DataDescription:ColorValue';
const SymbolValue = styled('span')({ const SymbolValue = styled('span')({
color: 'rgb(196, 26, 22)', color: 'rgb(196, 26, 22)',
}); });
SymbolValue.displayName = 'DataDescription:SymbolValue';
const NumberValue = styled('span')({ const NumberValue = styled('span')({
color: colors.tealDark1, color: colors.tealDark1,
}); });
NumberValue.displayName = 'DataDescription:NumberValue';
const ColorBox = styled('span')((props: {color: string}) => ({ const ColorBox = styled('span')((props: {color: string}) => ({
backgroundColor: props.color, backgroundColor: props.color,
@@ -51,20 +57,24 @@ const ColorBox = styled('span')((props: {color: string}) => ({
verticalAlign: 'middle', verticalAlign: 'middle',
width: 12, width: 12,
})); }));
ColorBox.displayName = 'DataDescription:ColorBox';
const FunctionKeyword = styled('span')({ const FunctionKeyword = styled('span')({
color: 'rgb(170, 13, 145)', color: 'rgb(170, 13, 145)',
fontStyle: 'italic', fontStyle: 'italic',
}); });
FunctionKeyword.displayName = 'DataDescription:FunctionKeyword';
const FunctionName = styled('span')({ const FunctionName = styled('span')({
fontStyle: 'italic', fontStyle: 'italic',
}); });
FunctionName.displayName = 'DataDescription:FunctionName';
const ColorPickerDescription = styled('div')({ const ColorPickerDescription = styled('div')({
display: 'inline', display: 'inline',
position: 'relative', position: 'relative',
}); });
ColorPickerDescription.displayName = 'DataDescription:ColorPickerDescription';
type DataDescriptionProps = { type DataDescriptionProps = {
path?: Array<string>; path?: Array<string>;

View File

@@ -34,18 +34,22 @@ const BaseContainer = styled('div')(
userSelect: 'text', userSelect: 'text',
}), }),
); );
BaseContainer.displayName = 'DataInspector:BaseContainer';
const RecursiveBaseWrapper = styled('span')({ const RecursiveBaseWrapper = styled('span')({
color: colors.red, color: colors.red,
}); });
RecursiveBaseWrapper.displayName = 'DataInspector:RecursiveBaseWrapper';
const Wrapper = styled('span')({ const Wrapper = styled('span')({
color: '#555', color: '#555',
}); });
Wrapper.displayName = 'DataInspector:Wrapper';
const PropertyContainer = styled('span')({ const PropertyContainer = styled('span')({
paddingTop: '2px', paddingTop: '2px',
}); });
PropertyContainer.displayName = 'DataInspector:PropertyContainer';
const ExpandControl = styled('span')({ const ExpandControl = styled('span')({
color: '#6e6e6e', color: '#6e6e6e',
@@ -54,10 +58,12 @@ const ExpandControl = styled('span')({
marginRight: 5, marginRight: 5,
whiteSpace: 'pre', whiteSpace: 'pre',
}); });
ExpandControl.displayName = 'DataInspector:ExpandControl';
export const InspectorName = styled('span')({ export const InspectorName = styled('span')({
color: colors.grapeDark1, color: colors.grapeDark1,
}); });
InspectorName.displayName = 'DataInspector:InspectorName';
const nameTooltipOptions: TooltipOptions = { const nameTooltipOptions: TooltipOptions = {
position: 'toLeft', position: 'toLeft',

View File

@@ -17,6 +17,7 @@ import React from 'react';
const PreviewContainer = styled('span')({ const PreviewContainer = styled('span')({
fontStyle: 'italic', fontStyle: 'italic',
}); });
PreviewContainer.displayName = 'DataPreview:PreviewContainer';
function intersperse(arr: Array<any>, sep: string) { function intersperse(arr: Array<any>, sep: string) {
if (arr.length === 0) { if (arr.length === 0) {

View File

@@ -27,6 +27,8 @@ const DesktopDropdownContainer = styled('div')({
borderBottom: 'none', borderBottom: 'none',
}, },
}); });
DesktopDropdownContainer.displayName =
'DesktopDropdown:DesktopDropdownContainer';
export function DesktopDropdown(props: { export function DesktopDropdown(props: {
deactivate?: () => void; deactivate?: () => void;
@@ -57,6 +59,8 @@ const DesktopDropdownItemContainer = styled('div')(
}, },
}), }),
); );
DesktopDropdownItemContainer.displayName =
'DesktopDropdownItem:DesktopDropdownItemContainer';
type DesktopDropdownItemState = {hovered: boolean}; type DesktopDropdownItemState = {hovered: boolean};
@@ -126,3 +130,4 @@ export const DesktopDropdownSelectedItem = styled(DesktopDropdownItem)({
position: 'absolute', position: 'absolute',
}, },
}); });
DesktopDropdownSelectedItem.displayName = 'DesktopDropdownSelectedItem';

View File

@@ -72,6 +72,7 @@ const ElementsRowContainer = styled(ContextMenu)((props: any) => ({
backgroundColor: backgroundColorHover(props), backgroundColor: backgroundColorHover(props),
}, },
})); }));
ElementsRowContainer.displayName = 'Elements:ElementsRowContainer';
const ElementsRowDecoration = styled(FlexRow)({ const ElementsRowDecoration = styled(FlexRow)({
flexShrink: 0, flexShrink: 0,
@@ -82,6 +83,7 @@ const ElementsRowDecoration = styled(FlexRow)({
width: 16, width: 16,
top: -1, top: -1,
}); });
ElementsRowDecoration.displayName = 'Elements:ElementsRowDecoration';
const ElementsLine = styled('div')((props: {childrenCount: number}) => ({ const ElementsLine = styled('div')((props: {childrenCount: number}) => ({
backgroundColor: colors.light20, backgroundColor: colors.light20,
@@ -93,12 +95,14 @@ const ElementsLine = styled('div')((props: {childrenCount: number}) => ({
width: 2, width: 2,
borderRadius: '999em', borderRadius: '999em',
})); }));
ElementsLine.displayName = 'Elements:ElementsLine';
const DecorationImage = styled('img')({ const DecorationImage = styled('img')({
height: 12, height: 12,
marginRight: 5, marginRight: 5,
width: 12, width: 12,
}); });
DecorationImage.displayName = 'Elements:DecorationImage';
const NoShrinkText = styled(Text)({ const NoShrinkText = styled(Text)({
flexShrink: 0, flexShrink: 0,
@@ -107,20 +111,25 @@ const NoShrinkText = styled(Text)({
userSelect: 'none', userSelect: 'none',
fontWeight: 400, fontWeight: 400,
}); });
NoShrinkText.displayName = 'Elements:NoShrinkText';
const ElementsRowAttributeContainer = styled(NoShrinkText)({ const ElementsRowAttributeContainer = styled(NoShrinkText)({
color: colors.dark80, color: colors.dark80,
fontWeight: 300, fontWeight: 300,
marginLeft: 5, marginLeft: 5,
}); });
ElementsRowAttributeContainer.displayName =
'Elements:ElementsRowAttributeContainer';
const ElementsRowAttributeKey = styled('span')({ const ElementsRowAttributeKey = styled('span')({
color: colors.tomato, color: colors.tomato,
}); });
ElementsRowAttributeKey.displayName = 'Elements:ElementsRowAttributeKey';
const ElementsRowAttributeValue = styled('span')({ const ElementsRowAttributeValue = styled('span')({
color: colors.slateDark3, color: colors.slateDark3,
}); });
ElementsRowAttributeValue.displayName = 'Elements:ElementsRowAttributeValue';
class PartialHighlight extends PureComponent<{ class PartialHighlight extends PureComponent<{
selected: boolean; selected: boolean;
@@ -403,12 +412,14 @@ const ElementsContainer = styled(FlexColumn)({
minWidth: '100%', minWidth: '100%',
overflow: 'auto', overflow: 'auto',
}); });
ElementsContainer.displayName = 'Elements:ElementsContainer';
const ElementsBox = styled(FlexColumn)({ const ElementsBox = styled(FlexColumn)({
alignItems: 'flex-start', alignItems: 'flex-start',
flex: 1, flex: 1,
overflow: 'auto', overflow: 'auto',
}); });
ElementsBox.displayName = 'Elements:ElementsBox';
export type DecorateRow = (e: Element) => ReactElement<any> | undefined | null; export type DecorateRow = (e: Element) => ReactElement<any> | undefined | null;

View File

@@ -40,6 +40,7 @@ const FilterText = styled('div')({
color: `${colors.white} !important`, color: `${colors.white} !important`,
}, },
}); });
FilterText.displayName = 'FilterRow:FilterText';
type Props = { type Props = {
children: React.ReactNode; children: React.ReactNode;

View File

@@ -39,6 +39,7 @@ const Token = styled(Text)(
}, },
}), }),
); );
Token.displayName = 'FilterToken:Token';
const Key = styled(Text)( const Key = styled(Text)(
(props: {type: 'exclude' | 'include' | 'enum'; focused?: boolean}) => ({ (props: {type: 'exclude' | 'include' | 'enum'; focused?: boolean}) => ({
@@ -60,6 +61,7 @@ const Key = styled(Text)(
}, },
}), }),
); );
Key.displayName = 'FilterToken:Key';
const Value = styled(Text)({ const Value = styled(Text)({
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
@@ -69,6 +71,7 @@ const Value = styled(Text)({
lineHeight: '21px', lineHeight: '21px',
paddingLeft: 3, paddingLeft: 3,
}); });
Value.displayName = 'FilterToken:Value';
const Chevron = styled('div')((props: {focused?: boolean}) => ({ const Chevron = styled('div')((props: {focused?: boolean}) => ({
border: 0, border: 0,
@@ -88,6 +91,7 @@ const Chevron = styled('div')((props: {focused?: boolean}) => ({
backgroundColor: 'transparent', backgroundColor: 'transparent',
}, },
})); }));
Chevron.displayName = 'FilterToken:Chevron';
type Props = { type Props = {
filter: Filter; filter: Filter;

View File

@@ -27,6 +27,7 @@ const SearchBar = styled(Toolbar)({
height: 42, height: 42,
padding: 6, padding: 6,
}); });
SearchBar.displayName = 'Searchable:SearchBar';
export const SearchBox = styled(FlexBox)({ export const SearchBox = styled(FlexBox)({
backgroundColor: colors.white, backgroundColor: colors.white,
@@ -37,6 +38,7 @@ export const SearchBox = styled(FlexBox)({
alignItems: 'center', alignItems: 'center',
paddingLeft: 4, paddingLeft: 4,
}); });
SearchBox.displayName = 'Searchable:SearchBox';
export const SearchInput = styled(Input)( export const SearchInput = styled(Input)(
(props: {focus?: boolean; regex?: boolean; isValidInput?: boolean}) => ({ (props: {focus?: boolean; regex?: boolean; isValidInput?: boolean}) => ({
@@ -56,6 +58,7 @@ export const SearchInput = styled(Input)(
}, },
}), }),
); );
SearchInput.displayName = 'Searchable:SearchInput';
const Clear = styled(Text)({ const Clear = styled(Text)({
position: 'absolute', position: 'absolute',
@@ -75,6 +78,7 @@ const Clear = styled(Text)({
backgroundColor: 'rgba(0,0,0,0.15)', backgroundColor: 'rgba(0,0,0,0.15)',
}, },
}); });
Clear.displayName = 'Searchable:Clear';
export const SearchIcon = styled(Glyph)({ export const SearchIcon = styled(Glyph)({
marginRight: 3, marginRight: 3,
@@ -82,11 +86,13 @@ export const SearchIcon = styled(Glyph)({
marginTop: -1, marginTop: -1,
minWidth: 16, minWidth: 16,
}); });
SearchIcon.displayName = 'Searchable:SearchIcon';
const Actions = styled(FlexRow)({ const Actions = styled(FlexRow)({
marginLeft: 8, marginLeft: 8,
flexShrink: 0, flexShrink: 0,
}); });
Actions.displayName = 'Searchable:Actions';
export type SearchableProps = { export type SearchableProps = {
addFilter: (filter: Filter) => void; addFilter: (filter: Filter) => void;
@@ -131,6 +137,8 @@ const Searchable = (
Component: React.ComponentType<any>, Component: React.ComponentType<any>,
): React.ComponentType<any> => ): React.ComponentType<any> =>
class extends PureComponent<Props, State> { class extends PureComponent<Props, State> {
static displayName = `Searchable(${Component.displayName})`;
static defaultProps = { static defaultProps = {
placeholder: 'Search...', placeholder: 'Search...',
}; };

View File

@@ -148,6 +148,7 @@ const Container = styled(FlexColumn)((props: {canOverflow?: boolean}) => ({
overflow: props.canOverflow ? 'scroll' : 'visible', overflow: props.canOverflow ? 'scroll' : 'visible',
flexGrow: 1, flexGrow: 1,
})); }));
Container.displayName = 'ManagedTable:Container';
const globalTableState: {[key: string]: TableColumnSizes} = {}; const globalTableState: {[key: string]: TableColumnSizes} = {};

View File

@@ -145,6 +145,7 @@ const Container = styled(FlexColumn)((props: {canOverflow?: boolean}) => ({
overflow: props.canOverflow ? 'scroll' : 'visible', overflow: props.canOverflow ? 'scroll' : 'visible',
flexGrow: 1, flexGrow: 1,
})); }));
Container.displayName = 'ManagedTable_immutable:Container';
const globalTableState: {[key: string]: TableColumnSizes} = {}; const globalTableState: {[key: string]: TableColumnSizes} = {};

View File

@@ -29,6 +29,7 @@ import React from 'react';
const TableHeaderArrow = styled('span')({ const TableHeaderArrow = styled('span')({
float: 'right', float: 'right',
}); });
TableHeaderArrow.displayName = 'TableHead:TableHeaderArrow';
const TableHeaderColumnInteractive = styled(Interactive)({ const TableHeaderColumnInteractive = styled(Interactive)({
display: 'inline-block', display: 'inline-block',
@@ -37,10 +38,13 @@ const TableHeaderColumnInteractive = styled(Interactive)({
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
width: '100%', width: '100%',
}); });
TableHeaderColumnInteractive.displayName =
'TableHead:TableHeaderColumnInteractive';
const TableHeaderColumnContainer = styled('div')({ const TableHeaderColumnContainer = styled('div')({
padding: '0 8px', padding: '0 8px',
}); });
TableHeaderColumnContainer.displayName = 'TableHead:TableHeaderColumnContainer';
const TableHeadContainer = styled(FlexRow)( const TableHeadContainer = styled(FlexRow)(
(props: {horizontallyScrollable?: boolean}) => ({ (props: {horizontallyScrollable?: boolean}) => ({
@@ -56,6 +60,7 @@ const TableHeadContainer = styled(FlexRow)(
minWidth: props.horizontallyScrollable ? 'min-content' : 0, minWidth: props.horizontallyScrollable ? 'min-content' : 0,
}), }),
); );
TableHeadContainer.displayName = 'TableHead:TableHeadContainer';
const TableHeadColumnContainer = styled('div')( const TableHeadColumnContainer = styled('div')(
(props: {width: string | number}) => ({ (props: {width: string | number}) => ({
@@ -81,6 +86,7 @@ const TableHeadColumnContainer = styled('div')(
}, },
}), }),
); );
TableHeadColumnContainer.displayName = 'TableHead:TableHeadColumnContainer';
const RIGHT_RESIZABLE = {right: true}; const RIGHT_RESIZABLE = {right: true};

View File

@@ -84,6 +84,7 @@ const TableBodyRowContainer = styled(FlexRow)(
}, },
}), }),
); );
TableBodyRowContainer.displayName = 'TableRow:TableBodyRowContainer';
const TableBodyColumnContainer = styled('div')( const TableBodyColumnContainer = styled('div')(
(props: { (props: {
@@ -105,6 +106,7 @@ const TableBodyColumnContainer = styled('div')(
justifyContent: props.justifyContent, justifyContent: props.justifyContent,
}), }),
); );
TableBodyColumnContainer.displayName = 'TableRow:TableBodyColumnContainer';
type Props = { type Props = {
columnSizes: TableColumnSizes; columnSizes: TableColumnSizes;

View File

@@ -35,6 +35,7 @@ const NonWrappingText = styled(Text)({
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
userSelect: 'none', userSelect: 'none',
}); });
NonWrappingText.displayName = 'TypeBasedValueRenderer:NonWrappingText';
const BooleanValue = styled(NonWrappingText)((props: {active?: boolean}) => ({ const BooleanValue = styled(NonWrappingText)((props: {active?: boolean}) => ({
'&::before': { '&::before': {
@@ -48,6 +49,7 @@ const BooleanValue = styled(NonWrappingText)((props: {active?: boolean}) => ({
marginTop: 1, marginTop: 1,
}, },
})); }));
BooleanValue.displayName = 'TypeBasedValueRenderer:BooleanValue';
export function renderValue(val: Value) { export function renderValue(val: Value) {
switch (val.type) { switch (val.type) {