From cb11b360fc1e4e9fce3a306712abab8a3787e1f1 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 30 Mar 2023 08:43:54 -0700 Subject: [PATCH] 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 --- .../src/ui/components/StackTrace.tsx | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/desktop/flipper-ui-core/src/ui/components/StackTrace.tsx b/desktop/flipper-ui-core/src/ui/components/StackTrace.tsx index df6692967..a925a7818 100644 --- a/desktop/flipper-ui-core/src/ui/components/StackTrace.tsx +++ b/desktop/flipper-ui-core/src/ui/components/StackTrace.tsx @@ -9,7 +9,6 @@ import {Component} from 'react'; import Text from './Text'; -import {colors} from './colors'; import ManagedTable from './table/ManagedTable'; import FlexRow from './FlexRow'; import Glyph from './Glyph'; @@ -22,6 +21,7 @@ import { TableColumns, TableBodyColumn, } from './table/types'; +import {theme} from 'flipper-plugin'; const Padder = styled.div<{ padded?: boolean; @@ -34,9 +34,8 @@ Padder.displayName = 'StackTrace:Padder'; const Container = styled.div<{isCrash?: boolean; padded?: boolean}>( ({isCrash, padded}) => ({ - backgroundColor: isCrash ? colors.redTint : 'transprent', border: padded - ? `1px solid ${isCrash ? colors.red : colors.light15}` + ? `1px solid ${isCrash ? theme.errorColor : theme.dividerColor}` : 'none', borderRadius: padded ? 5 : 0, overflow: 'hidden', @@ -45,7 +44,7 @@ const Container = styled.div<{isCrash?: boolean; padded?: boolean}>( Container.displayName = 'StackTrace:Container'; const Title = styled(FlexRow)<{isCrash?: boolean}>(({isCrash}) => ({ - color: isCrash ? colors.red : 'inherit', + color: isCrash ? theme.errorColor : 'inherit', padding: 8, alignItems: 'center', minHeight: 32, @@ -53,18 +52,21 @@ const Title = styled(FlexRow)<{isCrash?: boolean}>(({isCrash}) => ({ Title.displayName = 'StackTrace:Title'; const Reason = styled(Text)<{isCrash?: boolean}>(({isCrash}) => ({ - color: isCrash ? colors.red : colors.light80, + color: isCrash ? theme.errorColor : theme.textColorPrimary, fontWeight: 'bold', fontSize: 13, })); Reason.displayName = 'StackTrace:Reason'; -const Line = styled(Text)<{isCrash?: boolean; isBold?: boolean}>( - ({isCrash, isBold}) => ({ - color: isCrash ? colors.red : colors.light80, - fontWeight: isBold ? 'bold' : 'normal', - }), -); +const Line = styled(Text)<{ + isCrash?: boolean; + isBold?: boolean; + color?: string; +}>(({isBold, color}) => ({ + color: color ?? theme.textColorPrimary, + fontWeight: isBold ? 'bold' : 'normal', + overflow: 'visible', +})); Line.displayName = 'StackTrace:Line'; const Icon = styled(Glyph)({marginRight: 5}); @@ -148,6 +150,18 @@ export default class StackTrace extends Component<{ 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) => ({ key: String(i), columns: (Object.keys(columns) as Array).reduce<{ @@ -156,7 +170,11 @@ export default class StackTrace extends Component<{ acc[cv] = { align: cv === 'lineNumber' ? 'right' : 'left', value: ( - + {String(l[cv])} ), @@ -177,7 +195,7 @@ export default class StackTrace extends Component<{ name="stop" variant="filled" size={16} - color={colors.red} + color={theme.errorColor} /> )}