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 EuiFacetButton and EuiFacetGroup #5878

Merged
merged 49 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3aaf346
Convert `EuiFacetButton` and `EuiFacetGroup` to emotion
miukimiu May 5, 2022
8be0805
Deleting `.scss` files
miukimiu May 5, 2022
265fc72
Moving buttons mixins to functions
miukimiu May 5, 2022
322793f
Removed unused mixin. Adding CL. Improving gutter size func.
miukimiu May 6, 2022
f4784a1
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 6, 2022
b8f9133
Improving example
miukimiu May 6, 2022
1ddd2cd
Better code for calling `euiTheme`
miukimiu May 6, 2022
cd2f2ec
Renaming `contentElementStyles` to `contentElementsStyles`
miukimiu May 6, 2022
e29df48
Fix typo. CL.
miukimiu May 6, 2022
54172b4
Better gap styles
miukimiu May 6, 2022
a8a4eec
Adding `euiCanAnimate` for transitions
miukimiu May 6, 2022
9db464c
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 9, 2022
781f93b
Moving button functions and using `euiLinkFocusCSS`
miukimiu May 9, 2022
80a149b
Typo
miukimiu May 9, 2022
2452e51
Adding `logicalCSS`
miukimiu May 12, 2022
bbfff1c
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 12, 2022
45c412a
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 18, 2022
a037373
Adding new EuiButtonDisplay
miukimiu May 19, 2022
e02cb0c
Adding `logicalTextAlignCSS`
miukimiu May 19, 2022
4f0d7d8
Removing `EuiFlexGroup`
miukimiu May 19, 2022
90572aa
Better styles
miukimiu May 20, 2022
4fd0f89
Better `isDisabled` styles
miukimiu May 20, 2022
eaa0c90
Text`isSelected` style
miukimiu May 20, 2022
7f60484
Identantion
miukimiu May 20, 2022
955a32b
CL
miukimiu May 20, 2022
5adff69
Improving regex in render_custom_styles
miukimiu May 24, 2022
cd757e4
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 24, 2022
9c669da
Deprecating EuiButtonDisplay and EuiButtonContent components
miukimiu May 25, 2022
755774f
Adding `euiLoadingSpinnerBorderColorsCSS` mixin
miukimiu May 25, 2022
8bf188a
Adding `_buttonSize()` and renaming files to contain `_deprecated`
miukimiu May 26, 2022
3cd0483
Keeping `EuiButtonDisplay_Deprecated` in button file
miukimiu May 26, 2022
c62946f
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu May 26, 2022
024de57
Improving text
miukimiu Jun 1, 2022
b0d2012
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu Jun 1, 2022
d72e521
Fixing error due to `euiFontSize` being updated in main
miukimiu Jun 1, 2022
7505bea
Preventing test to get `EuiButtonDisplay_Deprecated`
miukimiu Jun 1, 2022
3f51ca0
Renaming deprecated components
miukimiu Jun 3, 2022
e5a1d1c
Addressing PR review
miukimiu Jun 3, 2022
a522250
Added new `color` prop to `EuiLoadingSpinner`
miukimiu Jun 3, 2022
51eec20
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu Jun 3, 2022
fe6cbc9
Removing unnecessary prop comment
miukimiu Jun 3, 2022
533fa71
Making `EuiLoadingSpinnerProps['color']` show in props table
miukimiu Jun 3, 2022
be920ca
Better props table for `EuiLoadingSpinnerColor`
miukimiu Jun 3, 2022
1555212
Update src/components/loading/loading_spinner.tsx
miukimiu Jun 8, 2022
8668a50
Update src/components/loading/loading_spinner.tsx
miukimiu Jun 8, 2022
344a8f0
Update upcoming_changelogs/5878.md
miukimiu Jun 8, 2022
9327062
Update src/components/button/button_display/_button_display.tsx
miukimiu Jun 8, 2022
2bc4cb9
Moving CL entry out of `CSS-in-JS`
miukimiu Jun 8, 2022
daf148d
Merge remote-tracking branch 'upstream/main' into emotion-facet-conve…
miukimiu Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch

</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