Use theme colours
Summary: Stacktrace component was not properly displaying on Light/Dark mode as it was using colours not from the theme. This change addresses that. Reviewed By: ivanmisuno Differential Revision: D44537750 fbshipit-source-id: 1d95313bfc9b5ef386864fa230348b76dce6d648
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aa6f04815b
commit
cb11b360fc
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
import {Component} from 'react';
|
import {Component} from 'react';
|
||||||
import Text from './Text';
|
import Text from './Text';
|
||||||
import {colors} from './colors';
|
|
||||||
import ManagedTable from './table/ManagedTable';
|
import ManagedTable from './table/ManagedTable';
|
||||||
import FlexRow from './FlexRow';
|
import FlexRow from './FlexRow';
|
||||||
import Glyph from './Glyph';
|
import Glyph from './Glyph';
|
||||||
@@ -22,6 +21,7 @@ import {
|
|||||||
TableColumns,
|
TableColumns,
|
||||||
TableBodyColumn,
|
TableBodyColumn,
|
||||||
} from './table/types';
|
} from './table/types';
|
||||||
|
import {theme} from 'flipper-plugin';
|
||||||
|
|
||||||
const Padder = styled.div<{
|
const Padder = styled.div<{
|
||||||
padded?: boolean;
|
padded?: boolean;
|
||||||
@@ -34,9 +34,8 @@ Padder.displayName = 'StackTrace:Padder';
|
|||||||
|
|
||||||
const Container = styled.div<{isCrash?: boolean; padded?: boolean}>(
|
const Container = styled.div<{isCrash?: boolean; padded?: boolean}>(
|
||||||
({isCrash, padded}) => ({
|
({isCrash, padded}) => ({
|
||||||
backgroundColor: isCrash ? colors.redTint : 'transprent',
|
|
||||||
border: padded
|
border: padded
|
||||||
? `1px solid ${isCrash ? colors.red : colors.light15}`
|
? `1px solid ${isCrash ? theme.errorColor : theme.dividerColor}`
|
||||||
: 'none',
|
: 'none',
|
||||||
borderRadius: padded ? 5 : 0,
|
borderRadius: padded ? 5 : 0,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
@@ -45,7 +44,7 @@ const Container = styled.div<{isCrash?: boolean; padded?: boolean}>(
|
|||||||
Container.displayName = 'StackTrace:Container';
|
Container.displayName = 'StackTrace:Container';
|
||||||
|
|
||||||
const Title = styled(FlexRow)<{isCrash?: boolean}>(({isCrash}) => ({
|
const Title = styled(FlexRow)<{isCrash?: boolean}>(({isCrash}) => ({
|
||||||
color: isCrash ? colors.red : 'inherit',
|
color: isCrash ? theme.errorColor : 'inherit',
|
||||||
padding: 8,
|
padding: 8,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
minHeight: 32,
|
minHeight: 32,
|
||||||
@@ -53,18 +52,21 @@ const Title = styled(FlexRow)<{isCrash?: boolean}>(({isCrash}) => ({
|
|||||||
Title.displayName = 'StackTrace:Title';
|
Title.displayName = 'StackTrace:Title';
|
||||||
|
|
||||||
const Reason = styled(Text)<{isCrash?: boolean}>(({isCrash}) => ({
|
const Reason = styled(Text)<{isCrash?: boolean}>(({isCrash}) => ({
|
||||||
color: isCrash ? colors.red : colors.light80,
|
color: isCrash ? theme.errorColor : theme.textColorPrimary,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
}));
|
}));
|
||||||
Reason.displayName = 'StackTrace:Reason';
|
Reason.displayName = 'StackTrace:Reason';
|
||||||
|
|
||||||
const Line = styled(Text)<{isCrash?: boolean; isBold?: boolean}>(
|
const Line = styled(Text)<{
|
||||||
({isCrash, isBold}) => ({
|
isCrash?: boolean;
|
||||||
color: isCrash ? colors.red : colors.light80,
|
isBold?: boolean;
|
||||||
|
color?: string;
|
||||||
|
}>(({isBold, color}) => ({
|
||||||
|
color: color ?? theme.textColorPrimary,
|
||||||
fontWeight: isBold ? 'bold' : 'normal',
|
fontWeight: isBold ? 'bold' : 'normal',
|
||||||
}),
|
overflow: 'visible',
|
||||||
);
|
}));
|
||||||
Line.displayName = 'StackTrace:Line';
|
Line.displayName = 'StackTrace:Line';
|
||||||
|
|
||||||
const Icon = styled(Glyph)({marginRight: 5});
|
const Icon = styled(Glyph)({marginRight: 5});
|
||||||
@@ -148,6 +150,18 @@ export default class StackTrace extends Component<{
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const colorForColumn = (column: string): string | undefined => {
|
||||||
|
switch (column) {
|
||||||
|
case 'lineNumber':
|
||||||
|
return theme.semanticColors.numberValue;
|
||||||
|
case 'library':
|
||||||
|
return theme.textColorPrimary;
|
||||||
|
case 'address':
|
||||||
|
return theme.semanticColors.stringValue;
|
||||||
|
case 'caller':
|
||||||
|
return theme.textColorSecondary;
|
||||||
|
}
|
||||||
|
};
|
||||||
const rows: TableBodyRow[] = children.map((l, i) => ({
|
const rows: TableBodyRow[] = children.map((l, i) => ({
|
||||||
key: String(i),
|
key: String(i),
|
||||||
columns: (Object.keys(columns) as Array<keyof Child>).reduce<{
|
columns: (Object.keys(columns) as Array<keyof Child>).reduce<{
|
||||||
@@ -156,7 +170,11 @@ export default class StackTrace extends Component<{
|
|||||||
acc[cv] = {
|
acc[cv] = {
|
||||||
align: cv === 'lineNumber' ? 'right' : 'left',
|
align: cv === 'lineNumber' ? 'right' : 'left',
|
||||||
value: (
|
value: (
|
||||||
<Line code isCrash={this.props.isCrash} bold={l.isBold || false}>
|
<Line
|
||||||
|
code
|
||||||
|
isCrash={this.props.isCrash}
|
||||||
|
bold={l.isBold || false}
|
||||||
|
color={colorForColumn(cv)}>
|
||||||
{String(l[cv])}
|
{String(l[cv])}
|
||||||
</Line>
|
</Line>
|
||||||
),
|
),
|
||||||
@@ -177,7 +195,7 @@ export default class StackTrace extends Component<{
|
|||||||
name="stop"
|
name="stop"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
size={16}
|
size={16}
|
||||||
color={colors.red}
|
color={theme.errorColor}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Reason isCrash={this.props.isCrash} code>
|
<Reason isCrash={this.props.isCrash} code>
|
||||||
|
|||||||
Reference in New Issue
Block a user