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

Fixing styles for euiKeyPadMenu #8294

Open
wants to merge 6 commits into
base: eui-theme/borealis
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions packages/eui/changelogs/upcoming/8294.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Updates styles for keypad menu in Borealis
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't add changelogs to changes on eui-theme/borealis as it's a feature branch.
You can add the 'skip-chagelog` label.

We'll add a changelog when merging Borealis to main for any relevant changes.


**Accessibility**

- Made keypad menu items in Dark mode visible on hover
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this actually done? I don't see any dark mode specific changes 🤔


Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,95 @@ import { euiKeyPadMenuVariables } from './key_pad_menu.styles';
export const euiKeyPadMenuItemStyles = (euiThemeContext: UseEuiTheme) => {
const { euiTheme } = euiThemeContext;
const { euiKeyPadMenuSize } = euiKeyPadMenuVariables(euiThemeContext);
const hasVisColorAdjustment = euiTheme.flags?.hasVisColorAdjustment;

return {
euiKeyPadMenuItem: css`
display: block;
padding: ${euiTheme.size.xs};
${logicalSizeCSS(euiKeyPadMenuSize)}
border-radius: ${euiTheme.border.radius.medium};
color: ${euiTheme.colors.text}; /* Override possible link color */
color: ${euiTheme.colors
.textParagraph}; /* Override possible link color */

${euiCanAnimate} {
transition: background-color ${euiTheme.animation.fast} ease-in,
box-shadow ${euiTheme.animation.fast} ease-in;
}
`,
enabled: css`
/* stylelint-disable no-extra-semicolons */
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this comment by rewriting the styles a bit. Generally assuring the style rule is set and only values are condition seems to work better in those cases.
I'll add suggestions per line.

&:hover,
&:focus,
&:focus-within {
cursor: pointer;
text-decoration: underline;
${euiShadow(euiThemeContext, 's')}

${euiCanAnimate} {
.euiKeyPadMenuItem__icon {
transform: translateY(0);
}
}
${hasVisColorAdjustment
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we can prevent the Emotion-related semicolon lint error by separating multiline styles into a standalone variable.

const focusTransformStyles = `
    ${euiShadow(euiThemeContext, 's')};

    ${euiCanAnimate} {
      .euiKeyPadMenuItem__icon {
        transform: translateY(0);
      }
    }
  `;
  
// usage
 ${hasVisColorAdjustment
  ? focusTransformStyles
  : `background-color: ${euiTheme.colors.backgroundBaseInteractiveHover}`}

? `
${euiShadow(euiThemeContext, 's')}

${euiCanAnimate} {
.euiKeyPadMenuItem__icon {
transform: translateY(0);
}
}`
: `
background-color: ${euiTheme.colors.backgroundBaseInteractiveHover};
`}
}

&:focus {
background-color: ${euiTheme.focus.backgroundColor};
box-shadow: none;

${hasVisColorAdjustment
Copy link
Contributor

Choose a reason for hiding this comment

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

We can prevent the lint error by using it this way:

background-color: ${
   hasVisColorAdjustment
     ? euiTheme.focus.backgroundColor
     : euiTheme.colors.backgroundBaseInteractiveHover
};

? `
background-color: ${euiTheme.focus.backgroundColor};
`
: `
background-color: ${euiTheme.colors.backgroundBaseInteractiveHover};
`}
}
`,
selected: css`
color: ${euiTheme.colors.title};
background-color: ${euiTheme.focus.backgroundColor};
color: ${euiTheme.colors.textHeading};

${hasVisColorAdjustment
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update to this to prevent the lint error:

background-color: ${hasVisColorAdjustment
        ? euiTheme.focus.backgroundColor
        : ''};

? `
background-color: ${euiTheme.focus.backgroundColor};
`
: ``}

&,
&:hover,
&:focus,
&:focus-within {
color: ${euiTheme.colors.primaryText};
color: ${euiTheme.colors.textPrimary};

${hasVisColorAdjustment
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update to this to prevent the lint error:

background-color: ${!hasVisColorAdjustment
          ? euiTheme.colors.backgroundBaseInteractiveSelect
          : ''};

? ``
: `background-color: ${euiTheme.colors.backgroundBaseInteractiveSelect};`}
}
`,
disabled: {
disabled: css`
cursor: not-allowed;
color: ${euiTheme.colors.disabledText};
color: ${euiTheme.colors.textDisabled};

.euiKeyPadMenuItem__icon {
filter: grayscale(100%);

${hasVisColorAdjustment ? `filter: grayscale(100%);` : ``}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can update to:

filter: ${hasVisColorAdjustment ? 'grayscale(100%)' : ''};

svg * {
fill: ${euiTheme.colors.disabledText};
fill: ${euiTheme.colors.textDisabled};
}
}
`,
selected: css`
background-color: ${euiTheme.components
.keyPadMenuItemBackgroundDisabledSelect};
selected: hasVisColorAdjustment
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update this to ensure that all styles are part of the Emotion css, prevent the lint error and we can also simplify as it's the same style rule:

selected: css`
  background-color: ${hasVisColorAdjustment
    ? euiTheme.components.keyPadMenuItemBackgroundDisabledSelect
    : euiTheme.colors.backgroundBaseDisabled};
`

? css`
background-color: ${euiTheme.components
.keyPadMenuItemBackgroundDisabledSelect};
`
: `
background-color: ${euiTheme.colors.backgroundBaseDisabled};
`,
},
};
Expand Down