Skip to content

Commit d7d690c

Browse files
authored
[Discover] SCSS to Emotions migration part 2/4 (#214729)
1 parent 42a6613 commit d7d690c

File tree

32 files changed

+181
-279
lines changed

32 files changed

+181
-279
lines changed

src/core/packages/application/common/src/global_app_style.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ export const GlobalAppStyle = () => {
158158
return (
159159
<Global
160160
styles={css`
161-
${bannerStyles(euiTheme)} ${chromeStyles(euiTheme)} ${renderingOverrides(euiTheme)}
161+
${bannerStyles(euiTheme)}
162+
${chromeStyles(euiTheme)}
163+
${renderingOverrides(euiTheme)}
162164
`}
163165
/>
164166
);

src/core/public/cssUtils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
// This file replaces scss core/public/_mixins.scss
11+
12+
import { css } from '@emotion/react';
13+
14+
// The `--kbnAppHeadersOffset` CSS variable is automatically updated by
15+
// styles/rendering/_base.scss, based on whether the Kibana chrome has a
16+
// header banner, app menu, and is visible or hidden
17+
export const kibanaFullBodyHeightCss = (additionalOffset = 0) => css`
18+
height: calc(
19+
100vh - var(--kbnAppHeadersOffset, var(--euiFixedHeadersOffset, 0)) - ${additionalOffset}px
20+
);
21+
`;

src/core/public/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,5 @@ export type { CoreSetup, CoreStart, StartServicesAccessor } from '@kbn/core-life
308308
export type { CoreSystem } from '@kbn/core-root-browser-internal';
309309

310310
export { __kbnBootstrap__ } from '@kbn/core-root-browser-internal';
311+
312+
export { kibanaFullBodyHeightCss } from './cssUtils';

src/platform/plugins/shared/discover/public/application/context/components/action_bar/_action_bar.scss

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/platform/plugins/shared/discover/public/application/context/components/action_bar/action_bar.test.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { mountWithIntl } from '@kbn/test-jest-helpers';
1212
import type { ActionBarProps } from './action_bar';
1313
import { ActionBar } from './action_bar';
1414
import { findTestSubject } from '@elastic/eui/lib/test';
15+
import { EuiThemeProvider } from '@elastic/eui';
1516
import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../services/constants';
1617
import { SurrDocType } from '../../services/context';
1718

@@ -27,7 +28,11 @@ describe('Test Discover Context ActionBar for successor | predecessor records',
2728
onChangeCount,
2829
type,
2930
} as ActionBarProps;
30-
const wrapper = mountWithIntl(<ActionBar {...props} />);
31+
const wrapper = mountWithIntl(
32+
<EuiThemeProvider>
33+
<ActionBar {...props} />
34+
</EuiThemeProvider>
35+
);
3136

3237
const input = findTestSubject(wrapper, `${type}CountPicker`);
3338
const btn = findTestSubject(wrapper, `${type}LoadMoreButton`);
@@ -83,7 +88,11 @@ describe('Test Discover Context ActionBar for successor | predecessor records',
8388
});
8489

8590
test(`${type}: Load button disabled when defaultStepSize is 0`, () => {
86-
const wrapperWhenZeroStep = mountWithIntl(<ActionBar {...props} defaultStepSize={0} />);
91+
const wrapperWhenZeroStep = mountWithIntl(
92+
<EuiThemeProvider>
93+
<ActionBar {...props} defaultStepSize={0} />
94+
</EuiThemeProvider>
95+
);
8796
const inputWhenZeroStep = findTestSubject(wrapperWhenZeroStep, `${type}CountPicker`);
8897
const btnWhenZeroStep = findTestSubject(wrapperWhenZeroStep, `${type}LoadMoreButton`);
8998
expect(btnWhenZeroStep.props().disabled).toBe(true);

src/platform/plugins/shared/discover/public/application/context/components/action_bar/action_bar.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import './_action_bar.scss';
1110
import React, { useState, useEffect } from 'react';
11+
import { css } from '@emotion/react';
1212
import { i18n } from '@kbn/i18n';
1313
import { FormattedMessage } from '@kbn/i18n-react';
1414
import {
@@ -18,6 +18,7 @@ import {
1818
EuiFlexItem,
1919
EuiFormRow,
2020
EuiSpacer,
21+
type UseEuiTheme,
2122
} from '@elastic/eui';
2223
import { ActionBarWarning } from './action_bar_warning';
2324
import { SurrDocType } from '../../services/context';
@@ -121,7 +122,7 @@ export function ActionBar({
121122
})
122123
}
123124
compressed
124-
className="cxtSizePicker"
125+
css={cxtSizePickerCss}
125126
data-test-subj={`${type}CountPicker`}
126127
disabled={isDisabled}
127128
min={MIN_CONTEXT_SIZE}
@@ -161,3 +162,14 @@ export function ActionBar({
161162
</form>
162163
);
163164
}
165+
166+
const cxtSizePickerCss = ({ euiTheme }: UseEuiTheme) => css`
167+
text-align: center;
168+
width: calc(${euiTheme.size.base} * 5);
169+
170+
&::-webkit-outer-spin-button,
171+
&::-webkit-inner-spin-button {
172+
appearance: none; // Hide increment and decrement buttons for type="number" input.
173+
margin: 0;
174+
}
175+
`;

src/platform/plugins/shared/discover/public/application/context/context_app.scss

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/platform/plugins/shared/discover/public/application/context/context_app.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React from 'react';
1111
import { waitFor } from '@testing-library/react';
1212
import { mountWithIntl } from '@kbn/test-jest-helpers';
1313
import { createFilterManagerMock } from '@kbn/data-plugin/public/query/filter_manager/filter_manager.mock';
14+
import { EuiThemeProvider } from '@elastic/eui';
1415
import { mockTopNavMenu } from './__mocks__/top_nav_menu';
1516
import { ContextAppContent } from './context_app_content';
1617
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
@@ -96,7 +97,9 @@ describe('ContextApp test', () => {
9697
const mountComponent = () => {
9798
return mountWithIntl(
9899
<KibanaContextProvider services={services}>
99-
<ContextApp {...defaultProps} />
100+
<EuiThemeProvider>
101+
<ContextApp {...defaultProps} />
102+
</EuiThemeProvider>
100103
</KibanaContextProvider>
101104
);
102105
};

src/platform/plugins/shared/discover/public/application/context/context_app.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
import React, { Fragment, memo, useEffect, useRef, useMemo, useCallback } from 'react';
11-
import './context_app.scss';
1211
import { FormattedMessage } from '@kbn/i18n-react';
1312
import { EuiText, EuiPage, EuiPageBody, EuiSpacer, useEuiPaddingSize } from '@elastic/eui';
1413
import { css } from '@emotion/react';
@@ -23,6 +22,7 @@ import type { UseColumnsProps } from '@kbn/unified-data-table';
2322
import { popularizeField, useColumns } from '@kbn/unified-data-table';
2423
import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
2524
import type { DiscoverGridSettings } from '@kbn/saved-search-plugin/common';
25+
import { kibanaFullBodyHeightCss } from '@kbn/core/public';
2626
import { ContextErrorMessage } from './components/context_error_message';
2727
import { LoadingStatus } from './services/context_query_state';
2828
import type { AppState, GlobalState } from './services/context_state';
@@ -257,11 +257,11 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) =>
257257
})}
258258
</h1>
259259
<TopNavMenu {...getNavBarProps()} />
260-
<EuiPage className="dscDocsPage">
260+
<EuiPage css={dscDocsPageCss}>
261261
<EuiPageBody
262262
panelled
263263
paddingSize="none"
264-
className="dscDocsContent"
264+
css={dscDocsContentCss}
265265
panelProps={{ role: 'main' }}
266266
>
267267
<EuiText
@@ -305,3 +305,13 @@ export const ContextApp = ({ dataView, anchorId, referrer }: ContextAppProps) =>
305305
</Fragment>
306306
);
307307
};
308+
309+
const dscDocsPageCss = css`
310+
${kibanaFullBodyHeightCss(54)}; // 54px is the action bar height
311+
`;
312+
313+
const dscDocsContentCss = css`
314+
display: flex;
315+
flex-direction: column;
316+
height: 100%;
317+
`;

src/platform/plugins/shared/discover/public/application/context/context_app_content.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export function ContextAppContent({
204204
isDisabled={isAnchorLoading}
205205
/>
206206
</WrapperWithPadding>
207-
<div className="dscDocsGrid">
207+
<div css={dscDocsGridCss}>
208208
<CellActionsProvider getTriggerCompatibleActions={uiActions.getTriggerCompatibleActions}>
209209
<DiscoverGridMemoized
210210
ariaLabelledBy="surDocumentsAriaLabel"
@@ -266,3 +266,8 @@ const WrapperWithPadding: FC<React.PropsWithChildren<{}>> = ({ children }) => {
266266
</div>
267267
);
268268
};
269+
270+
const dscDocsGridCss = css`
271+
flex: 1 1 100%;
272+
overflow: auto;
273+
`;

0 commit comments

Comments
 (0)