Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Convert EuiDataGrid toolbar control styles to Emotion (Part 2) #7997

Merged
merged 11 commits into from
Sep 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`useDataGridKeyboardShortcuts [React 16] returns a popover containing a
aria-describedby="generated-id"
aria-live="off"
aria-modal="true"
class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
Expand All @@ -66,7 +66,7 @@ exports[`useDataGridKeyboardShortcuts [React 16] returns a popover containing a
</p>
<div>
<div
class="euiPopoverTitle emotion-euiPopoverTitle-m-s"
class="euiPopoverTitle emotion-euiPopoverTitle-none-s"
>
<h2
id="generated-id"
Expand All @@ -75,13 +75,13 @@ exports[`useDataGridKeyboardShortcuts [React 16] returns a popover containing a
</h2>
</div>
<div
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs"
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs-euiDataGrid__keyboardShortcuts"
>
<dl
aria-labelledby="generated-id"
class="euiDescriptionList emotion-euiDescriptionList-column-center-s-s"
data-type="column"
style="grid-template-columns: 1fr 3fr;"
style="grid-template-columns: auto auto;"
>
<dt
class="euiDescriptionList__title emotion-euiDescriptionList__title-column-compressed-right"
Expand Down Expand Up @@ -294,7 +294,7 @@ exports[`useDataGridKeyboardShortcuts [React 17] returns a popover containing a
aria-describedby="generated-id"
aria-live="off"
aria-modal="true"
class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
Expand All @@ -315,7 +315,7 @@ exports[`useDataGridKeyboardShortcuts [React 17] returns a popover containing a
</p>
<div>
<div
class="euiPopoverTitle emotion-euiPopoverTitle-m-s"
class="euiPopoverTitle emotion-euiPopoverTitle-none-s"
>
<h2
id="generated-id"
Expand All @@ -324,13 +324,13 @@ exports[`useDataGridKeyboardShortcuts [React 17] returns a popover containing a
</h2>
</div>
<div
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs"
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs-euiDataGrid__keyboardShortcuts"
>
<dl
aria-labelledby="generated-id"
class="euiDescriptionList emotion-euiDescriptionList-column-center-s-s"
data-type="column"
style="grid-template-columns: 1fr 3fr;"
style="grid-template-columns: auto auto;"
>
<dt
class="euiDescriptionList__title emotion-euiDescriptionList__title-column-compressed-right"
Expand Down Expand Up @@ -544,7 +544,7 @@ exports[`useDataGridKeyboardShortcuts [React 18] returns a popover containing a
aria-describedby="generated-id"
aria-live="off"
aria-modal="true"
class="euiPanel euiPanel--plain euiPanel--paddingMedium euiPopover__panel emotion-euiPanel-grow-m-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-light-isOpen-hasTransform-bottom"
data-autofocus="true"
data-popover-open="true"
data-popover-panel="true"
Expand All @@ -565,7 +565,7 @@ exports[`useDataGridKeyboardShortcuts [React 18] returns a popover containing a
</p>
<div>
<div
class="euiPopoverTitle emotion-euiPopoverTitle-m-s"
class="euiPopoverTitle emotion-euiPopoverTitle-none-s"
>
<h2
id="generated-id"
Expand All @@ -574,13 +574,13 @@ exports[`useDataGridKeyboardShortcuts [React 18] returns a popover containing a
</h2>
</div>
<div
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs"
class="euiText euiDataGrid__keyboardShortcuts emotion-euiText-xs-euiDataGrid__keyboardShortcuts"
>
<dl
aria-labelledby="generated-id"
class="euiDescriptionList emotion-euiDescriptionList-column-center-s-s"
data-type="column"
style="grid-template-columns: 1fr 3fr;"
style="grid-template-columns: auto auto;"
>
<dt
class="euiDescriptionList__title emotion-euiDescriptionList__title-column-compressed-right"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +0,0 @@
.euiDataGrid__keyboardShortcuts {
display: block;
max-inline-size: $euiSizeXXL * 10;
max-block-size: 80vh;
overflow-y: auto;
overflow-block: auto;

.euiDescriptionList {
row-gap: 0; // Row spacing handled by default EuiText dd/dt styles
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { css } from '@emotion/react';

import { UseEuiTheme } from '../../../services';
import { euiYScroll, logicalCSS, mathWithUnits } from '../../../global_styling';

export const euiDataGridKeyboardShortcutsStyles = (
euiThemeContext: UseEuiTheme
) => {
const { euiTheme } = euiThemeContext;

return {
euiDataGrid__keyboardShortcuts: css`
${logicalCSS('max-height', '80vh')}
${logicalCSS(
'max-width',
mathWithUnits(euiTheme.size.xxl, (x) => x * 10)
)}
padding: ${euiTheme.size.m};
${euiYScroll(euiThemeContext)}

.euiDescriptionList {
row-gap: 0; /* Row spacing handled by default EuiText dd/dt styles */
}
`,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

import React, { useState, useMemo, ReactNode } from 'react';

import { useGeneratedHtmlId } from '../../../services';
import { useGeneratedHtmlId, useEuiMemoizedStyles } from '../../../services';
import { EuiButtonIcon } from '../../button';
import { EuiToolTip } from '../../tool_tip';
import { EuiPopover, EuiPopoverTitle } from '../../popover';
import { EuiDescriptionList } from '../../description_list';
import { EuiText } from '../../text';
import { useEuiI18n, EuiI18n } from '../../i18n';

import { euiDataGridKeyboardShortcutsStyles } from './keyboard_shortcuts.styles';

export const useDataGridKeyboardShortcuts = (): {
keyboardShortcuts: ReactNode;
} => {
Expand All @@ -24,13 +26,16 @@ export const useDataGridKeyboardShortcuts = (): {
const title = useEuiI18n('euiKeyboardShortcuts.title', 'Keyboard shortcuts');
const titleId = useGeneratedHtmlId();

const styles = useEuiMemoizedStyles(euiDataGridKeyboardShortcutsStyles);

const keyboardShortcuts = useMemo(
() => (
<EuiPopover
data-test-subj="dataGridKeyboardShortcutsPopover"
isOpen={isOpen}
closePopover={() => setIsOpen(false)}
anchorPosition="downRight"
panelPaddingSize="none"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change of padding placement caused a slight visual regression but I think it's a) a correct change and b) not a big visual impact.

Screen.Recording.2024-09-05.at.09.36.42.mov
Screen.Recording.2024-09-05.at.09.38.04.mov

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's an intentional change! 🎉 Thanks as always for your eagle eyes Lene!

button={
<EuiToolTip content={title} delay="long">
<EuiButtonIcon
Expand All @@ -47,11 +52,15 @@ export const useDataGridKeyboardShortcuts = (): {
<EuiPopoverTitle paddingSize="s">
<h2 id={titleId}>{title}</h2>
</EuiPopoverTitle>
<EuiText className="euiDataGrid__keyboardShortcuts" size="xs">
<EuiText
css={styles.euiDataGrid__keyboardShortcuts}
className="euiDataGrid__keyboardShortcuts"
size="xs"
>
<EuiDescriptionList
aria-labelledby={titleId}
type="column"
columnWidths={[1, 3]}
columnWidths={['auto', 'auto']}
align="center"
compressed
listItems={[
Expand Down Expand Up @@ -268,7 +277,7 @@ export const useDataGridKeyboardShortcuts = (): {
</EuiText>
</EuiPopover>
),
[isOpen, title, titleId]
[isOpen, title, titleId, styles]
);

return { keyboardShortcuts };
Expand Down