Moved sidebar_pop to styles.

This commit is contained in:
Yaroslav Kuznietsov 2021-11-30 11:56:53 +02:00
parent 3fde5ff6a4
commit 23037f2600
4 changed files with 44 additions and 27 deletions

View file

@ -7,7 +7,7 @@
import React, { FunctionComponent } from 'react'; import React, { FunctionComponent } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { EuiTabbedContent } from '@elastic/eui'; import { useEuiTheme, EuiTabbedContent } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
// @ts-expect-error unconverted component // @ts-expect-error unconverted component
@ -15,6 +15,7 @@ import { Datasource } from '../../datasource';
// @ts-expect-error unconverted component // @ts-expect-error unconverted component
import { FunctionFormList } from '../../function_form_list'; import { FunctionFormList } from '../../function_form_list';
import { PositionedElement } from '../../../../types'; import { PositionedElement } from '../../../../types';
import { sidebarPopStylesFactory } from '../sidebar_pop.styles';
const strings = { const strings = {
getDataTabLabel: () => getDataTabLabel: () =>
@ -39,15 +40,14 @@ interface Props {
} }
export const ElementSettings: FunctionComponent<Props> = ({ element }) => { export const ElementSettings: FunctionComponent<Props> = ({ element }) => {
const { euiTheme } = useEuiTheme();
const tabs = [ const tabs = [
{ {
id: 'edit', id: 'edit',
name: strings.getDisplayTabLabel(), name: strings.getDisplayTabLabel(),
content: ( content: (
<div className="canvasSidebar__pop"> <div css={sidebarPopStylesFactory(euiTheme)}>
<div className="canvasSidebar--args"> <FunctionFormList element={element} />
<FunctionFormList element={element} />
</div>
</div> </div>
), ),
}, },
@ -55,7 +55,7 @@ export const ElementSettings: FunctionComponent<Props> = ({ element }) => {
id: 'data', id: 'data',
name: strings.getDataTabLabel(), name: strings.getDataTabLabel(),
content: ( content: (
<div className="canvasSidebar__pop"> <div css={sidebarPopStylesFactory(euiTheme)}>
<Datasource /> <Datasource />
</div> </div>
), ),

View file

@ -6,10 +6,11 @@
*/ */
import React, { Fragment, FC } from 'react'; import React, { Fragment, FC } from 'react';
import { EuiTabbedContent, EuiTitle, EuiSpacer } from '@elastic/eui'; import { useEuiTheme, EuiTabbedContent, EuiTitle, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { GeneralConfig } from './general_config'; import { GeneralConfig } from './general_config';
import { FilterConfig } from './filter_config'; import { FilterConfig } from './filter_config';
import { sidebarPopStylesFactory } from '../sidebar_pop.styles';
const strings = { const strings = {
getTitle: () => getTitle: () =>
@ -27,12 +28,14 @@ const strings = {
}; };
export const GlobalConfig: FC = () => { export const GlobalConfig: FC = () => {
const { euiTheme } = useEuiTheme();
const tabs = [ const tabs = [
{ {
id: 'general', id: 'general',
name: strings.getGeneralLabel(), name: strings.getGeneralLabel(),
content: ( content: (
<div className="canvasSidebar__pop"> <div css={sidebarPopStylesFactory(euiTheme)}>
<EuiSpacer size="m" /> <EuiSpacer size="m" />
<GeneralConfig /> <GeneralConfig />
</div> </div>
@ -42,7 +45,7 @@ export const GlobalConfig: FC = () => {
id: 'filter', id: 'filter',
name: strings.getFilterLabel(), name: strings.getFilterLabel(),
content: ( content: (
<div className="canvasSidebar__pop"> <div css={sidebarPopStylesFactory(euiTheme)}>
<FilterConfig /> <FilterConfig />
</div> </div>
), ),

View file

@ -9,21 +9,3 @@
top: 0; top: 0;
bottom: 0; bottom: 0;
} }
.canvasSidebar__pop {
animation: sidebarPop $euiAnimSpeedFast $euiAnimSlightResistance;
}
@keyframes sidebarPop {
0% {
opacity: 0;
}
1% {
opacity: 0;
}
100% {
opacity: 1;
}
}

View file

@ -0,0 +1,32 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { EuiThemeComputed } from '@elastic/eui';
import { css, keyframes } from '@emotion/react';
export const sidebarPanelClassName = 'canvasSidebar__panel';
export const sidebarAccordionClassName = 'canvasSidebar__accordion';
export const sidebarExpandableClassName = 'canvasSidebar__expandable';
export const sidebarFiltersClassName = 'filtersSidebar__accordion';
const sidebarPopKeyFrames = keyframes`
0% {
opacity: 0;
}
1% {
opacity: 0;
}
100% {
opacity: 1;
}
`;
export const sidebarPopStylesFactory = (theme: EuiThemeComputed) => css`
animation: ${sidebarPopKeyFrames} ${theme.animation.fast} ${theme.animation.resistance};
`;