Skip to content

Commit

Permalink
[Discover] Update array field format to use a CSS class instead of in…
Browse files Browse the repository at this point in the history
…line styles
  • Loading branch information
davismcphee committed Jul 21, 2022
1 parent 79ace87 commit ebebb66
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import { escape, isFunction } from 'lodash';
import { euiThemeVars } from '@kbn/ui-theme';
import { IFieldFormat, HtmlContextTypeConvert, FieldFormatsContentType } from '../types';
import { asPrettyString, getHighlightHtml } from '../utils';

Expand All @@ -34,8 +33,7 @@ export const setup = (
htmlContextTypeConvert?: HtmlContextTypeConvert
): HtmlContextTypeConvert => {
const convert = getConvertFn(format, htmlContextTypeConvert);
const highlightColor = euiThemeVars.euiColorMediumShade;
const highlight = (text: string) => `<span style="color: ${highlightColor};">${text}</span>`;
const highlight = (text: string) => `<span class="ffArray__highlight">${text}</span>`;

const recurse: HtmlContextTypeConvert = (value, options = {}) => {
if (value == null) {
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/field_formats/common/field_format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('FieldFormat class', () => {
const f = getTestFormat();

expect(f.convert([123, 456, 789], 'html')).toMatchInlineSnapshot(
`"<span style=\\"color: #98a2b3;\\">[</span>123<span style=\\"color: #98a2b3;\\">,</span> 456<span style=\\"color: #98a2b3;\\">,</span> 789<span style=\\"color: #98a2b3;\\">]</span>"`
`"<span class=\\"ffArray__highlight\\">[</span>123<span class=\\"ffArray__highlight\\">,</span> 456<span class=\\"ffArray__highlight\\">,</span> 789<span class=\\"ffArray__highlight\\">]</span>"`
);
});

Expand All @@ -164,16 +164,16 @@ describe('FieldFormat class', () => {
];

expect(f.convert(newlineList, 'html')).toMatchInlineSnapshot(`
"<span style=\\"color: #98a2b3;\\">[</span>
"<span class=\\"ffArray__highlight\\">[</span>
{
&quot;foo&quot;: &quot;bar&quot;,
&quot;fizz&quot;: &quot;buzz&quot;
}<span style=\\"color: #98a2b3;\\">,</span>
}<span class=\\"ffArray__highlight\\">,</span>
{
&quot;bar&quot;: &quot;foo&quot;,
&quot;buzz&quot;: &quot;fizz&quot;
}
<span style=\\"color: #98a2b3;\\">]</span>"
<span class=\\"ffArray__highlight\\">]</span>"
`);
});
});
Expand Down
1 change: 1 addition & 0 deletions src/plugins/field_formats/public/index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import './lib/converters/index';
@import './lib/content_types/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ffArray__highlight {
color: $euiColorMediumShade;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './html_content_type';

0 comments on commit ebebb66

Please sign in to comment.