Skip to content

Commit

Permalink
Revert "Revert "[Emotion] Convert EuiFacetButton and EuiFacetGroup (
Browse files Browse the repository at this point in the history
#5878)""

This reverts commit 469cee1, re-adding #5878 to the main branch.
  • Loading branch information
chandlerprall committed Jun 13, 2022
1 parent 99e3ede commit 42c82b6
Show file tree
Hide file tree
Showing 49 changed files with 768 additions and 304 deletions.
22 changes: 3 additions & 19 deletions src-docs/src/views/facet/facet_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
EuiFacetGroup,
EuiIcon,
EuiAvatar,
EuiTitle,
EuiSpacer,
} from '../../../../src/components';

import { euiPaletteColorBlind } from '../../../../src/services';
Expand Down Expand Up @@ -146,22 +144,8 @@ export default () => {
};

return (
<div>
<EuiTitle size="s">
<h3>Vertical</h3>
</EuiTitle>
<EuiFacetGroup style={{ maxWidth: 200 }}>
{facets('Vertical')}
</EuiFacetGroup>

<EuiSpacer />

<EuiTitle size="s">
<h3>Horizontal and large gutter</h3>
</EuiTitle>
<EuiFacetGroup layout="horizontal" gutterSize="l">
{facets('Horizontal')}
</EuiFacetGroup>
</div>
<EuiFacetGroup style={{ maxWidth: 200 }}>
{facets('Vertical')}
</EuiFacetGroup>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import React, { FunctionComponent } from 'react';
import { Link } from 'react-router-dom';

// @ts-ignore Importing from JS
import { GuideSectionTypes } from '../../components';

import {
Expand All @@ -12,14 +12,22 @@ import {
EuiLoadingChart,
EuiLoadingContent,
} from '../../../../src/components';

import {
loadingElasticConfig,
loadingChartConfig,
loadingLogoConfig,
loadingSpinnerConfig,
loadingContentConfig,
// @ts-ignore Importing from JS
} from './playground';

import { EuiLoadingSpinnerColor as EuiLoadingSpinnerColorProps } from '../../../../src/components/loading/loading_spinner';

export const EuiLoadingSpinnerColor: FunctionComponent<EuiLoadingSpinnerColorProps> = () => (
<div />
);

import LoadingLogo from './loading_kibana';
const loadingLogoSource = require('!!raw-loader!./loading_kibana');

Expand Down Expand Up @@ -129,7 +137,7 @@ export const LoadingExample = {
loading contexts.
</p>
),
props: { EuiLoadingSpinner },
props: { EuiLoadingSpinner, EuiLoadingSpinnerColor },
demo: <LoadingSpinner />,
snippet: '<EuiLoadingSpinner size="m" />',
playground: loadingSpinnerConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ exports[`EuiAccordion props isLoading is rendered 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner css-155ohbx-euiLoadingSpinner-m"
class="euiLoadingSpinner css-192zz00-euiLoadingSpinner-m"
role="progressbar"
/>
</div>
Expand Down Expand Up @@ -921,7 +921,7 @@ exports[`EuiAccordion props isLoadingMessage is rendered 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner css-155ohbx-euiLoadingSpinner-m"
class="euiLoadingSpinner css-192zz00-euiLoadingSpinner-m"
role="progressbar"
/>
</div>
Expand All @@ -939,7 +939,7 @@ exports[`EuiAccordion props isLoadingMessage is rendered 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner euiAccordion__spinner css-1v1n0rh-euiLoadingSpinner-m-euiAccordion__spinner"
class="euiLoadingSpinner euiAccordion__spinner css-1fekohn-euiLoadingSpinner-m-euiAccordion__spinner"
role="progressbar"
/>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/__snapshots__/button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ exports[`EuiButton props isLoading is rendered 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner euiButtonContent__spinner css-155ohbx-euiLoadingSpinner-m"
class="euiLoadingSpinner euiButtonContent__spinner css-192zz00-euiLoadingSpinner-m"
role="progressbar"
/>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports[`EuiButtonContent props isLoading is rendered 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner euiButtonContent__spinner css-155ohbx-euiLoadingSpinner-m"
class="euiLoadingSpinner euiButtonContent__spinner css-192zz00-euiLoadingSpinner-m"
role="progressbar"
/>
<span />
Expand All @@ -65,7 +65,7 @@ exports[`EuiButtonContent props isLoading replaces iconType with spinner 1`] = `
>
<span
aria-label="Loading"
class="euiLoadingSpinner euiButtonContent__spinner css-155ohbx-euiLoadingSpinner-m"
class="euiLoadingSpinner euiButtonContent__spinner css-192zz00-euiLoadingSpinner-m"
role="progressbar"
/>
<span />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ export const ICON_SIDES = keysOf(iconSideToClassNameMap);
export type EuiButtonContentType = HTMLAttributes<HTMLSpanElement>;

/**
* *INTERNAL ONLY*
* *INTERNAL ONLY / DEPRECATED*
* This component is simply a helper component for reuse within other button components
* This component has been deprecated in favor of the new EuiButtonDisplayContent
* that can be found in `src/components/button/button_display/_button_display_content.tsx`.
*/
export interface EuiButtonContentProps extends CommonProps {
/**
Expand All @@ -40,7 +42,8 @@ export interface EuiButtonContentProps extends CommonProps {
iconSide?: ButtonContentIconSide;
isLoading?: boolean;
/**
* Object of props passed to the <span/> wrapping the content's text/children only (not icon)
* Object of props passed to the <span/> wrapping the content's text (only if the children is a `string`)
* It doesn't apply to the icon.
*/
textProps?: HTMLAttributes<HTMLSpanElement> &
CommonProps & {
Expand All @@ -50,7 +53,7 @@ export interface EuiButtonContentProps extends CommonProps {
iconSize?: 's' | 'm';
}

export const EuiButtonContent: FunctionComponent<
export const EuiButtonContentDeprecated: FunctionComponent<
EuiButtonContentType & EuiButtonContentProps
> = ({
children,
Expand Down
3 changes: 2 additions & 1 deletion src/components/button/button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { render, mount } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiButton, COLORS, SIZES } from './button';
import { ICON_SIDES } from './button_content';

import { ICON_SIDES } from './_button_content_deprecated';

describe('EuiButton', () => {
test('is rendered', () => {
Expand Down
17 changes: 12 additions & 5 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import { getSecureRelForTarget } from '../../services';
import {
EuiButtonContentProps,
EuiButtonContentType,
EuiButtonContent,
} from './button_content';
EuiButtonContentDeprecated as EuiButtonContent,
} from './_button_content_deprecated';
import { validateHref } from '../../services/security/href_validator';

export type ButtonColor =
Expand Down Expand Up @@ -174,7 +174,8 @@ export const EuiButton: FunctionComponent<Props> = ({
}

return (
<EuiButtonDisplay
// eslint-disable-next-line react/jsx-pascal-case
<EuiButtonDisplayDeprecated
element={element}
baseClassName="euiButton"
ref={buttonRef}
Expand All @@ -199,13 +200,19 @@ export type EuiButtonDisplayProps = EuiButtonProps &
};

/**
* *DEPRECATED*
* EuiButtonDisplay is an internal-only component used for displaying
* any element as a button.
* NOTE: This component *must* be below EuiButton in the file and
* EuiButton must also set a displayName for react-docgen-typescript
* to correctly set EuiButton's docgenInfo and display a props table.
* This component has been deprecated in favor of the new EuiButtonDisplay
* that can be found in `src/components/button/button_display/_button_display.tsx`
*/
export const EuiButtonDisplay = forwardRef<HTMLElement, EuiButtonDisplayProps>(
export const EuiButtonDisplayDeprecated = forwardRef<
HTMLElement,
EuiButtonDisplayProps
>(
(
{
element = 'button',
Expand Down Expand Up @@ -295,4 +302,4 @@ export const EuiButtonDisplay = forwardRef<HTMLElement, EuiButtonDisplayProps>(
);
}
);
EuiButtonDisplay.displayName = 'EuiButtonDisplay';
EuiButtonDisplayDeprecated.displayName = 'EuiButtonDisplay';
2 changes: 1 addition & 1 deletion src/components/button/button_content.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test/required_props';

import { EuiButtonContent } from './button_content';
import { EuiButtonContentDeprecated as EuiButtonContent } from './_button_content_deprecated';

describe('EuiButtonContent', () => {
test('is rendered', () => {
Expand Down
63 changes: 63 additions & 0 deletions src/components/button/button_display/_button_display.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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 {
euiFontSize,
logicalCSS,
logicalTextAlignStyle,
} from '../../../global_styling';

// Provides a solid reset and base for handling sizing layout
// Does not include any visual styles
export const euiButtonBaseCSS = () => {
return `
display: inline-block;
appearance: none;
cursor: pointer;
${logicalTextAlignStyle('center')};
white-space: nowrap;
${logicalCSS('max-width', '100%')};
vertical-align: middle;
`;
};

const _buttonSize = (size: string) => {
return `
${logicalCSS('height', size)};
// prevents descenders from getting cut off
line-height: ${size};
`;
};

export const euiButtonDisplayStyles = (
euiThemeContext: UseEuiTheme,
minWidth: string
) => {
const { euiTheme } = euiThemeContext;

return {
// Base
euiButtonDisplay: css`
${euiButtonBaseCSS()};
${minWidth && logicalCSS('min-width', minWidth)};
`,
// States
isDisabled: css`
cursor: not-allowed;
`,
fullWidth: css`
display: block;
width: 100%;
`,
// Sizes
xs: css(_buttonSize(euiTheme.size.l), euiFontSize(euiThemeContext, 'xs')),
s: css(_buttonSize(euiTheme.size.xl), euiFontSize(euiThemeContext, 's')),
m: css(_buttonSize(euiTheme.size.xxl), euiFontSize(euiThemeContext, 's')),
};
};
Loading

0 comments on commit 42c82b6

Please sign in to comment.