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

[EuiButton] Fix multiple issues around internal EuiButtonDisplay components #6332

Merged
merged 9 commits into from
Oct 31, 2022
15 changes: 8 additions & 7 deletions src/components/button/__snapshots__/button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ exports[`EuiButton props iconSide left is rendered 1`] = `
type="button"
>
<span
class="emotion-euiButtonDisplayContent-left"
class="emotion-euiButtonDisplayContent"
>
<span
class="emotion-euiButtonDisplayContent__icon-m"
Expand All @@ -178,18 +178,18 @@ exports[`EuiButton props iconSide right is rendered 1`] = `
type="button"
>
<span
class="emotion-euiButtonDisplayContent-right"
class="emotion-euiButtonDisplayContent"
>
<span
class="emotion-euiButtonDisplayContent__icon-m"
color="inherit"
data-euiicon-type="user"
/>
<span
class="eui-textTruncate"
>
Content
</span>
<span
class="emotion-euiButtonDisplayContent__icon-m"
color="inherit"
data-euiicon-type="user"
/>
</span>
</button>
`;
Expand Down Expand Up @@ -336,6 +336,7 @@ exports[`EuiButton props isSelected is rendered as true 1`] = `
exports[`EuiButton props minWidth is rendered 1`] = `
<button
class="euiButton emotion-euiButtonDisplay-m-m-base-primary"
style="min-inline-size:0"
type="button"
>
<span
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/button_display/_button_display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const EuiButtonDisplay = forwardRef<HTMLElement, EuiButtonDisplayProps>(
{
children,
iconType,
iconSide,
iconSide = 'left',
iconSize,
size = 'm',
isDisabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ export const euiButtonDisplayContentStyles = ({ euiTheme }: UseEuiTheme) => ({
vertical-align: middle;
gap: ${euiTheme.size.s};
`,
// Icon side
left: css``,
right: css`
flex-direction: row-reverse;
`,
euiButtonDisplayContent__spinner: css`
flex-shrink: 0;
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ export const EuiButtonDisplayContent: FunctionComponent<
const theme = useEuiTheme();
const styles = euiButtonDisplayContentStyles(theme);

const cssStyles = [
styles.euiButtonDisplayContent,
iconSide && styles[iconSide],
];
const cssStyles = [styles.euiButtonDisplayContent];
const cssSpinnerStyles = [styles.euiButtonDisplayContent__spinner];
const cssIconStyles = [
styles.euiButtonDisplayContent__icon,
Expand Down Expand Up @@ -110,7 +107,7 @@ export const EuiButtonDisplayContent: FunctionComponent<

return (
<span css={cssStyles} {...contentProps}>
{icon}
{iconSide === 'left' && icon}
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 makes a lot of sense! I like it. From what I can see in Kibana, the only things referencing the the side in the icon class name are snapshots, so I believe we're safe to move forward with this.

{isText || textProps ? (
<span
{...textProps}
Expand All @@ -121,6 +118,7 @@ export const EuiButtonDisplayContent: FunctionComponent<
) : (
children
)}
{iconSide === 'right' && icon}
</span>
);
};