diff --git a/desktop/flipper-plugin/src/ui/Highlight.tsx b/desktop/flipper-plugin/src/ui/Highlight.tsx
index 5889c27dc..65c6cb4cf 100644
--- a/desktop/flipper-plugin/src/ui/Highlight.tsx
+++ b/desktop/flipper-plugin/src/ui/Highlight.tsx
@@ -7,7 +7,6 @@
* @format
*/
-import styled from '@emotion/styled';
import React, {
useEffect,
memo,
@@ -19,19 +18,20 @@ import React, {
import {debounce} from 'lodash';
import {theme} from './theme';
-const Highlighted = styled.span({
- backgroundColor: theme.searchHighlightBackground,
-});
-
export interface HighlightManager {
setFilter(text: string | undefined): void;
render(text: string): React.ReactNode;
+ setHighlightColor(color: string | undefined): void;
}
-function createHighlightManager(initialText: string = ''): HighlightManager {
+function createHighlightManager(
+ initialText: string = '',
+ initialHighlightColor: string = theme.searchHighlightBackground.yellow,
+): HighlightManager {
const callbacks = new Set<(prev: string, next: string) => void>();
let matches = 0;
let currentFilter = initialText;
+ let currHighlightColor = initialHighlightColor;
const Highlight: React.FC<{text: string}> = memo(({text}) => {
const [, setUpdate] = useState(0);
@@ -65,9 +65,9 @@ function createHighlightManager(initialText: string = ''): HighlightManager {
) : (
<>
{text.substr(0, index)}
-
+
{text.substr(index, currentFilter.length)}
-
+
{text.substr(index + currentFilter.length)}
>
)}
@@ -87,6 +87,12 @@ function createHighlightManager(initialText: string = ''): HighlightManager {
render(text: string) {
return ;
},
+ setHighlightColor(color: string) {
+ if (color !== currHighlightColor) {
+ currHighlightColor = color;
+ callbacks.forEach((cb) => cb(currentFilter, currentFilter));
+ }
+ },
};
}
@@ -98,21 +104,32 @@ export const HighlightContext = createContext({
// stub implementation in case we render a component without a Highlight context
return text;
},
+ setHighlightColor(_color: string) {
+ throw new Error('Cannot set the color of a stub highlight manager');
+ },
});
export function HighlightProvider({
text,
+ highlightColor,
children,
}: {
text: string | undefined;
+ highlightColor?: string | undefined;
children: React.ReactElement;
}) {
- const [highlightManager] = useState(() => createHighlightManager(text));
+ const [highlightManager] = useState(() =>
+ createHighlightManager(text, highlightColor),
+ );
useEffect(() => {
highlightManager.setFilter(text);
}, [text, highlightManager]);
+ useEffect(() => {
+ highlightManager.setHighlightColor(highlightColor);
+ }, [highlightColor, highlightManager]);
+
return (
{children}
diff --git a/desktop/flipper-plugin/src/ui/data-inspector/__tests__/DataInspector.node.tsx b/desktop/flipper-plugin/src/ui/data-inspector/__tests__/DataInspector.node.tsx
index abf31c55f..657187239 100644
--- a/desktop/flipper-plugin/src/ui/data-inspector/__tests__/DataInspector.node.tsx
+++ b/desktop/flipper-plugin/src/ui/data-inspector/__tests__/DataInspector.node.tsx
@@ -115,9 +115,7 @@ test.local('can filter for data', async () => {
expect(element.parentElement).toMatchInlineSnapshot(`
"j
-
+
son
"
diff --git a/desktop/flipper-plugin/src/ui/data-table/DataTable.tsx b/desktop/flipper-plugin/src/ui/data-table/DataTable.tsx
index 11569df64..461a70a0b 100644
--- a/desktop/flipper-plugin/src/ui/data-table/DataTable.tsx
+++ b/desktop/flipper-plugin/src/ui/data-table/DataTable.tsx
@@ -609,6 +609,10 @@ export function DataTable(
tableState.highlightSearchSetting.highlightEnabled
? tableState.searchValue
: ''
+ }
+ highlightColor={
+ tableState.highlightSearchSetting.color ||
+ theme.searchHighlightBackground.yellow
}>
{mainSection}
diff --git a/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx b/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx
index 6c3568b60..6f2337175 100644
--- a/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx
+++ b/desktop/flipper-plugin/src/ui/data-table/DataTableManager.tsx
@@ -12,6 +12,7 @@ import {Percentage} from '../../utils/widthUtils';
import {MutableRefObject, Reducer} from 'react';
import {DataSource, DataSourceVirtualizer} from '../../data-source/index';
import produce, {castDraft, immerable, original} from 'immer';
+import {theme} from '../theme';
export type OnColumnResize = (id: string, size: number | Percentage) => void;
export type Sorting = {
@@ -106,7 +107,8 @@ type DataManagerActions =
| Action<'setAutoScroll', {autoScroll: boolean}>
| Action<'toggleSearchValue'>
| Action<'clearSearchHistory'>
- | Action<'toggleHighlightSearch'>;
+ | Action<'toggleHighlightSearch'>
+ | Action<'setSearchHighlightColor', {color: string}>;
type DataManagerConfig = {
dataSource: DataSource;
@@ -309,6 +311,12 @@ export const dataTableManagerReducer = produce<
!draft.highlightSearchSetting.highlightEnabled;
break;
}
+ case 'setSearchHighlightColor': {
+ if (draft.highlightSearchSetting.color !== action.color) {
+ draft.highlightSearchSetting.color = action.color;
+ }
+ break;
+ }
default: {
throw new Error('Unknown action ' + (action as any).type);
}
@@ -341,6 +349,7 @@ export type DataTableManager = {
dataSource: DataSource;
toggleSearchValue(): void;
toggleHighlightSearch(): void;
+ setSearchHighlightColor(color: string): void;
};
export function createDataTableManager(
@@ -393,6 +402,9 @@ export function createDataTableManager(
toggleHighlightSearch() {
dispatch({type: 'toggleHighlightSearch'});
},
+ setSearchHighlightColor(color) {
+ dispatch({type: 'setSearchHighlightColor', color});
+ },
dataSource,
};
}
@@ -440,7 +452,7 @@ export function createInitialState(
autoScroll: prefs?.autoScroll ?? config.autoScroll ?? false,
highlightSearchSetting: prefs?.highlightSearchSetting ?? {
highlightEnabled: false,
- color: '',
+ color: theme.searchHighlightBackground.yellow,
},
};
// @ts-ignore
diff --git a/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx b/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx
index fdc1aa9d0..a240ecbc0 100644
--- a/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx
+++ b/desktop/flipper-plugin/src/ui/data-table/TableContextMenu.tsx
@@ -8,7 +8,7 @@
*/
import {CopyOutlined, FilterOutlined, TableOutlined} from '@ant-design/icons';
-import {Checkbox, Menu, Switch} from 'antd';
+import {Badge, Checkbox, Menu, Select, Switch} from 'antd';
import {Layout} from 'flipper-plugin';
import {
DataTableDispatch,
@@ -25,8 +25,10 @@ import {toFirstUpper} from '../../utils/toFirstUpper';
import {DataSource} from '../../data-source/index';
import {renderColumnValue} from './TableRow';
import {textContent} from '../../utils/textContent';
+import {theme} from '../theme';
const {Item, SubMenu} = Menu;
+const {Option} = Select;
export function tableContextMenuFactory(
datasource: DataSource,
@@ -197,6 +199,7 @@ export function tableContextMenuFactory(
e.stopPropagation();
e.preventDefault();
}}>
+ Highlight search terms
(
});
}}
/>
- Highlight search terms
+
+
+
+ {
+ e.stopPropagation();
+ e.preventDefault();
+ }}>
+ Highlight search color
+
+ }
+ color={color}
+ />
+
+ ),
+ )}
+
diff --git a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx
index 4e4b7cd09..066888924 100644
--- a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx
+++ b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTable.node.tsx
@@ -59,7 +59,7 @@ test('update and append', async () => {
>
test DataTable
@@ -70,7 +70,7 @@ test('update and append', async () => {
>
true
@@ -123,7 +123,7 @@ test('column visibility', async () => {
>
test DataTable
@@ -134,7 +134,7 @@ test('column visibility', async () => {
>
true
@@ -160,7 +160,7 @@ test('column visibility', async () => {
>
test DataTable
diff --git a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTableRecords.node.tsx b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTableRecords.node.tsx
index 7244728f8..16b067c23 100644
--- a/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTableRecords.node.tsx
+++ b/desktop/flipper-plugin/src/ui/data-table/__tests__/DataTableRecords.node.tsx
@@ -52,7 +52,7 @@ test('update and append', async () => {
>
test DataTable
@@ -63,7 +63,7 @@ test('update and append', async () => {
>
true
diff --git a/desktop/flipper-plugin/src/ui/elements-inspector/elements.tsx b/desktop/flipper-plugin/src/ui/elements-inspector/elements.tsx
index 761c97d45..881d00646 100644
--- a/desktop/flipper-plugin/src/ui/elements-inspector/elements.tsx
+++ b/desktop/flipper-plugin/src/ui/elements-inspector/elements.tsx
@@ -118,7 +118,7 @@ class PartialHighlight extends PureComponent<{
content: string;
}> {
static HighlightedText = styled.span<{selected: boolean}>((props) => ({
- backgroundColor: theme.searchHighlightBackground,
+ backgroundColor: theme.searchHighlightBackground.yellow,
color: props.selected ? `${theme.textColorPrimary} !important` : 'auto',
}));
diff --git a/desktop/flipper-plugin/src/ui/theme.tsx b/desktop/flipper-plugin/src/ui/theme.tsx
index 7e052dd21..2bde12e6d 100644
--- a/desktop/flipper-plugin/src/ui/theme.tsx
+++ b/desktop/flipper-plugin/src/ui/theme.tsx
@@ -21,7 +21,12 @@ export const theme = {
textColorSecondary: 'var(--flipper-text-color-secondary)',
textColorPlaceholder: 'var(--flipper-text-color-placeholder)',
textColorActive: 'var(--light-color-button-active)',
- searchHighlightBackground: antColors.yellow[3],
+ searchHighlightBackground: {
+ yellow: antColors.yellow[3],
+ red: antColors.red[3],
+ green: antColors.green[3],
+ blue: antColors.blue[3],
+ } as const,
selectionBackgroundColor: 'var(--flipper-primary-background-wash)',
disabledColor: 'var(--flipper-disabled-color)',
backgroundDefault: 'var(--flipper-background-default)',
diff --git a/desktop/flipper-ui-core/src/chrome/__tests__/flipper_messages.node.tsx b/desktop/flipper-ui-core/src/chrome/__tests__/flipper_messages.node.tsx
index 4e5831751..0eebc94da 100644
--- a/desktop/flipper-ui-core/src/chrome/__tests__/flipper_messages.node.tsx
+++ b/desktop/flipper-ui-core/src/chrome/__tests__/flipper_messages.node.tsx
@@ -129,7 +129,7 @@ test('It can render rows', async () => {
>
00:00:00.000
@@ -140,7 +140,7 @@ test('It can render rows', async () => {
>
Android Phone
@@ -151,7 +151,7 @@ test('It can render rows', async () => {
>
FB4A
@@ -162,7 +162,7 @@ test('It can render rows', async () => {
>
unique-string
@@ -173,7 +173,7 @@ test('It can render rows', async () => {
>
@@ -183,7 +183,7 @@ test('It can render rows', async () => {
>
@@ -193,7 +193,7 @@ test('It can render rows', async () => {
>
toClient:send