Skip to content

Commit

Permalink
[ES|QL] Theme updates for text based languages editor (#186345)
Browse files Browse the repository at this point in the history
## Summary

This is a design pass at the editor. Functionality and layout have not
been changed.

### What has changed?
- Color settings in the `esql_theme.ts`
- Added additional rule groups for color treatment (e.g. more operators
and values)
- Replaced hardcoded style values with EUI variables
- As a result, one set of theme colors now works across light and dark
mode
- Made a few small Monaco configuration (i.e. options) changes that
affect the UI/visual output (e.g. active line styles, line height,
font... the font size is the same, but I believe these other changes
will make it feel larger/more readable)
- Re-ordered the options set to more easily find what is/is not enabled
- Shortened the height of the top bar; tightened up the padding; more
closely matches the footer design

### How does it look?
*Light mode*
![CleanShot 2024-06-17 at 16 13
46@2x](https://github.com/elastic/kibana/assets/446285/5e78c2ac-5be8-4138-b1bf-616373c98bf1)

*Dark mode*
![CleanShot 2024-06-17 at 16 15
49@2x](https://github.com/elastic/kibana/assets/446285/f739742e-92d8-46d0-a4d2-26f8f2669044)

*Compact*
![CleanShot 2024-06-17 at 16 15
26@2x](https://github.com/elastic/kibana/assets/446285/a0f2b129-5973-4742-b428-16ef4f8b1eca)

### What about the other things we saw in the Slack screenshots...
I have some other ideas cookin', but I would like to iterate on those
concepts in Figma and get additional feedback. These entail the
edge-to-edge design, less borders, consolidated header and footer,
smaller CTA buttons, full-height field list, etc. Something like this...

<details>

<summary>Additional design considerations not in this PR</summary>

![CleanShot 2024-06-14 at 22 38
34@2x](https://github.com/elastic/kibana/assets/446285/dd5e0f12-1c9a-4ade-ad80-22376f841a41)

</details>

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
ryankeairns authored Jun 19, 2024
1 parent 2194f85 commit 1c7b595
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 80 deletions.
70 changes: 51 additions & 19 deletions packages/kbn-monaco/src/esql/lib/esql_theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ import { ESQL_TOKEN_POSTFIX } from './constants';
import { monaco } from '../../monaco_imports';

const buildRuleGroup = themeRuleGroupBuilderFactory(ESQL_TOKEN_POSTFIX);
const COMMANDS_COLORS = {
dark: '#a68ac5',
light: '#765b96',
};

const FUNCTIONS_COLORS = {
dark: '#d97797',
light: '#a34a68',
};

export const buildESQlTheme = (): monaco.editor.IStandaloneThemeData => ({
base: darkMode ? 'vs-dark' : 'vs',
Expand Down Expand Up @@ -55,10 +46,16 @@ export const buildESQlTheme = (): monaco.editor.IStandaloneThemeData => ({
euiThemeVars.euiTextColor
),

// source commands
...buildRuleGroup(
['from', 'row', 'show', 'meta'],
euiThemeVars.euiColorPrimaryText,
true // isBold
),

// commands
...buildRuleGroup(
[
'from',
'metrics',
'metadata',
'mv_expand',
Expand All @@ -80,27 +77,44 @@ export const buildESQlTheme = (): monaco.editor.IStandaloneThemeData => ({
'in',
'as',
'expr_ws',
'row',
'show',
'meta',
'limit',
'nulls_ordering_direction',
'nulls_ordering',
'null',
'enrich',
'on',
'with',
'asc',
'desc',
],
darkMode ? COMMANDS_COLORS.dark : COMMANDS_COLORS.light
euiThemeVars.euiColorAccentText,
true // isBold
),

// functions
...buildRuleGroup(['functions'], darkMode ? FUNCTIONS_COLORS.dark : FUNCTIONS_COLORS.light),
...buildRuleGroup(['functions'], euiThemeVars.euiColorPrimaryText),

// operators
...buildRuleGroup(
['or', 'and', 'rp', 'lp', 'plus', 'minus', 'asterisk', 'slash'],
euiThemeVars.euiTextSubduedColor
[
'or',
'and',
'rp', // ')'
'lp', // '('
'eq', // '=='
'cieq', // '=~'
'neq', // '!='
'lt', // '<'
'lte', // '<='
'gt', // '>'
'gte', // '>='
'plus', // '+'
'minus', // '-'
'asterisk', // '*'
'slash', // '/'
'percent', // '%'
],
euiThemeVars.euiColorPrimaryText
),

// comments
Expand All @@ -113,8 +127,26 @@ export const buildESQlTheme = (): monaco.editor.IStandaloneThemeData => ({
'src_line_comment',
'src_multiline_comment',
],
darkMode ? euiThemeVars.euiColorDarkestShade : euiThemeVars.euiColorMediumShade
euiThemeVars.euiColorDisabledText
),

// values
...buildRuleGroup(
['quoted_string', 'integer_literal', 'decimal_literal'],
euiThemeVars.euiColorSuccessText
),
],
colors: {},
colors: {
'editor.foreground': euiThemeVars.euiTextColor,
'editor.background': euiThemeVars.euiColorEmptyShade,
'editor.lineHighlightBackground': euiThemeVars.euiColorLightestShade,
'editor.lineHighlightBorder': euiThemeVars.euiColorLightestShade,
'editor.selectionHighlightBackground': euiThemeVars.euiColorLightestShade,
'editor.selectionHighlightBorder': euiThemeVars.euiColorLightShade,
'editorSuggestWidget.background': euiThemeVars.euiColorEmptyShade,
'editorSuggestWidget.border': euiThemeVars.euiColorEmptyShade,
'editorSuggestWidget.foreground': euiThemeVars.euiTextColor,
'editorSuggestWidget.selectedBackground': euiThemeVars.euiColorPrimary,
'editorSuggestWidget.selectedForeground': euiThemeVars.euiColorEmptyShade,
},
});
6 changes: 0 additions & 6 deletions packages/kbn-text-based-editor/src/editor_footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export const EditorFooter = memo(function EditorFooter({
queryHasChanged,
measuredContainerWidth,
}: EditorFooterProps) {
const { euiTheme } = useEuiTheme();
const [isErrorPopoverOpen, setIsErrorPopoverOpen] = useState(false);
const [isWarningPopoverOpen, setIsWarningPopoverOpen] = useState(false);
const onUpdateAndSubmit = useCallback(
Expand All @@ -162,18 +161,13 @@ export const EditorFooter = memo(function EditorFooter({
[runQuery, updateQuery]
);

const shadowStyle = isInCompactMode
? `inset 0 0px 0, inset 0 -1px 0 ${euiTheme.border.color}`
: 'none';

return (
<EuiFlexGroup
gutterSize="none"
responsive={false}
direction="column"
css={css`
width: 100%;
box-shadow: ${shadowStyle};
`}
>
<EuiFlexItem grow={false}>
Expand Down
66 changes: 42 additions & 24 deletions packages/kbn-text-based-editor/src/overwrite.scss
Original file line number Diff line number Diff line change
@@ -1,45 +1,63 @@
.TextBasedLangEditor .monaco-editor {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
/* Editor styles for any layout mode */
/* NOTE: Much of this is overriding Monaco styles so the specificity is intentional */

// Radius for both the main container and the margin (container for line numbers)
.TextBasedLangEditor .monaco-editor, .TextBasedLangEditor .monaco-editor .margin, .TextBasedLangEditor .monaco-editor .overflow-guard {
border-top-left-radius: $euiBorderRadius;
border-bottom-left-radius: $euiBorderRadius;
}

.TextBasedLangEditor .monaco-editor .monaco-hover {
display: none !important;
}

.TextBasedLangEditor--expanded .monaco-editor .monaco-hover {
display: block !important;
.TextBasedLangEditor .monaco-editor .margin-view-overlays .line-numbers {
color: $euiColorDisabledText;
}

.TextBasedLangEditor .monaco-editor .margin {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
// Currently focused line(s)
.TextBasedLangEditor .monaco-editor .current-line ~ .line-numbers {
color: $euiTextSubduedColor;
}

.TextBasedLangEditor--compact .monaco-editor {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
// Suggest (autocomplete) menu
.TextBasedLangEditor .monaco-editor .suggest-widget, .TextBasedLangEditor .monaco-editor .suggest-details-container {
@include euiBottomShadow;
border-radius: $euiBorderRadius;
}

.TextBasedLangEditor--compact .monaco-editor .margin {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
background-color: $euiColorLightestShade;
color: $euiColorDisabledText;
.TextBasedLangEditor .monaco-editor .suggest-details-container {
background-color: $euiColorEmptyShade;
line-height: 1.5rem;
}

.TextBasedLangEditor .monaco-editor .margin-view-overlays .line-numbers {
color: $euiColorDisabledText;
.TextBasedLangEditor_errorMessage {
@include euiTextBreakWord;
}

.TextBasedLangEditor .monaco-editor .current-line ~ .line-numbers {
color: $euiTextSubduedColor;
}
/* For compact mode */

// All scrollable containers (e.g. main container and suggest menu)
.TextBasedLangEditor--compact .monaco-editor .monaco-scrollable-element {
margin-left: 4px;
margin-left: $euiSizeS;
}

.TextBasedLangEditor_errorMessage {
@include euiTextBreakWord;
// Suggest menu in compact mode
.TextBasedLangEditor--compact .monaco-editor .monaco-list .monaco-scrollable-element {
margin-left: 0;

.monaco-list-row.focused {
border-radius: $euiBorderRadius;
}
}

/* For expanded mode */

.TextBasedLangEditor--expanded .monaco-editor .monaco-hover {
display: block !important;
}

.TextBasedLangEditor--expanded .monaco-editor, .TextBasedLangEditor--expanded .monaco-editor .margin, .TextBasedLangEditor--expanded .monaco-editor .overflow-guard {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
2 changes: 2 additions & 0 deletions packages/kbn-text-based-editor/src/query_history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ export function QueryHistory({
.euiTable th[data-test-subj='tableHeaderCell_duration_3'] span {
justify-content: flex-end;
}
border-bottom-left-radius: ${euiTheme.border.radius.medium};
border-top-left-radius: ${euiTheme.border.radius.medium};
max-height: ${isInCompactMode ? CONTAINER_MAX_HEIGHT_COMPACT : CONTAINER_MAX_HEIGHT_EXPANDED}px;
overflow-y: auto;
${scrollBarStyles}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const textBasedLanguageEditorStyles = (
},
historyContainer: {
border: euiTheme.border.thin,
borderTop: `2px solid ${euiTheme.colors.lightShade}`,
borderTop: 'none',
borderLeft: editorIsInline ? 'none' : euiTheme.border.thin,
borderRight: editorIsInline ? 'none' : euiTheme.border.thin,
backgroundColor: euiTheme.colors.lightestShade,
Expand All @@ -119,8 +119,8 @@ export const textBasedLanguageEditorStyles = (
borderTopLeftRadius: editorIsInline ? 0 : euiTheme.border.radius.medium,
borderTopRightRadius: editorIsInline ? 0 : euiTheme.border.radius.medium,
backgroundColor: euiTheme.colors.lightestShade,
paddingLeft: euiTheme.size.xs,
paddingRight: euiTheme.size.xs,
paddingLeft: euiTheme.size.s,
paddingRight: euiTheme.size.s,
paddingTop: showHeader ? euiTheme.size.s : euiTheme.size.xs,
paddingBottom: showHeader ? euiTheme.size.s : euiTheme.size.xs,
width: '100%',
Expand Down
56 changes: 30 additions & 26 deletions packages/kbn-text-based-editor/src/text_based_languages_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -667,41 +667,43 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
}, [language, documentationSections]);

const codeEditorOptions: CodeEditorProps['options'] = {
automaticLayout: true,
accessibilitySupport: 'off',
autoIndent: 'none',
automaticLayout: true,
fixedOverflowWidgets: true,
folding: false,
fontSize: 14,
padding: {
top: 8,
bottom: 8,
},
scrollBeyondLastLine: false,
quickSuggestions: true,
minimap: { enabled: false },
wordWrap: 'on',
lineNumbers: showLineNumbers ? 'on' : 'off',
theme: language === 'esql' ? ESQL_THEME_ID : isDark ? 'vs-dark' : 'vs',
lineDecorationsWidth: 12,
autoIndent: 'none',
wrappingIndent: 'none',
lineNumbersMinChars: 3,
overviewRulerLanes: 0,
hideCursorInOverviewRuler: true,
scrollbar: {
horizontal: 'hidden',
vertical: 'auto',
},
overviewRulerBorder: false,
// this becomes confusing with multiple markers, so quick fixes
// will be proposed only within the tooltip
lightbulb: {
enabled: false,
},
fixedOverflowWidgets: true,
lineDecorationsWidth: 12,
lineNumbers: showLineNumbers ? 'on' : 'off',
lineNumbersMinChars: 3,
minimap: { enabled: false },
overviewRulerLanes: 0,
overviewRulerBorder: false,
padding: {
top: 8,
bottom: 8,
},
quickSuggestions: true,
readOnly:
isLoading ||
isDisabled ||
Boolean(!isCompactFocused && codeOneLiner && codeOneLiner.includes('...')),
renderLineHighlight: !isCodeEditorExpanded ? 'none' : 'line',
renderLineHighlightOnlyWhenFocus: true,
scrollbar: {
horizontal: 'hidden',
vertical: 'auto',
},
scrollBeyondLastLine: false,
theme: language === 'esql' ? ESQL_THEME_ID : isDark ? 'vs-dark' : 'vs',
wordWrap: 'on',
wrappingIndent: 'none',
};

if (isCompactFocused) {
Expand Down Expand Up @@ -743,7 +745,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
<EuiButtonIcon
iconType={isWrappedInPipes ? 'pipeNoBreaks' : 'pipeBreaks'}
color="text"
size="s"
size="xs"
data-test-subj="TextBasedLangEditor-toggleWordWrap"
aria-label={
isWrappedInPipes
Expand Down Expand Up @@ -786,7 +788,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
}
buttonProps={{
color: 'text',
size: 's',
size: 'xs',
'data-test-subj': 'TextBasedLangEditor-documentation',
'aria-label': i18n.translate(
'textBasedEditor.query.textBasedLanguagesEditor.documentationLabel',
Expand All @@ -800,7 +802,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
)}
</EuiFlexItem>
{!Boolean(hideMinimizeButton) && (
<EuiFlexItem grow={false} style={{ marginRight: '8px' }}>
<EuiFlexItem grow={false}>
<EuiToolTip
position="top"
content={i18n.translate(
Expand All @@ -820,7 +822,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
}
)}
data-test-subj="TextBasedLangEditor-minimize"
size="s"
size="xs"
onClick={() => {
expandCodeEditor(false);
updateLinesFromModel = false;
Expand Down Expand Up @@ -1015,6 +1017,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
borderRadius: 0,
backgroundColor: isDark ? euiTheme.colors.lightestShade : '#e9edf3',
border: '1px solid rgb(17 43 134 / 10%) !important',
transform: 'none !important',
},
}}
/>
Expand Down Expand Up @@ -1044,6 +1047,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
backgroundColor: isDark ? euiTheme.colors.lightestShade : '#e9edf3',
border: '1px solid rgb(17 43 134 / 10%) !important',
borderLeft: 'transparent !important',
transform: 'none !important',
}}
/>
</EuiToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ export const QueryBarTopRow = React.memo(
: strings.getRefreshQueryLabel();
const buttonLabelRun = textBasedRunShortcut;

const iconDirty = Boolean(isQueryLangSelected) ? 'play' : 'kqlFunction';
const iconDirty = Boolean(isQueryLangSelected) ? 'playFilled' : 'kqlFunction';
const tooltipDirty = Boolean(isQueryLangSelected) ? buttonLabelRun : buttonLabelUpdate;

const isDirtyButtonLabel = Boolean(isQueryLangSelected)
Expand All @@ -588,7 +588,7 @@ export const QueryBarTopRow = React.memo(
onClick={onClickSubmitButton}
size={shouldShowDatePickerAsBadge() ? 's' : 'm'}
color={props.isDirty ? 'success' : 'primary'}
fill={props.isDirty}
fill={false}
needsUpdate={props.isDirty}
data-test-subj="querySubmitButton"
toolTipProps={{
Expand Down

0 comments on commit 1c7b595

Please sign in to comment.