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

Conversation

ek-so
Copy link
Contributor

@ek-so ek-so commented Jan 27, 2025

Summary

This PR fixes an issue mentioned in issue #158. Based on the discussion there and also on Borealis new color token rules, the changes include:

  • Remapping of the colors that are supported both in Amsterdam and Borealis;
  • Conditionally adding different interactive states to Borealis only (Amsterdam remains the same).

Changes made for Borealis include:

  • Removed jumping animation on hover
  • Added background on hover in addition to underline
  • Used a hovered background for the item on click, when it's not selected yet
  • Removed shadow entirely

Showcasing:

Amsterdam
CleanShot 2025-01-27 at 10 27 04

Borealis
CleanShot 2025-01-27 at 10 35 07

QA:

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
    • If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist
    • If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)

@ek-so ek-so changed the base branch from main to eui-theme/borealis January 27, 2025 09:18
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

@ek-so ek-so marked this pull request as ready for review January 27, 2025 09:48
@ek-so ek-so requested a review from a team as a code owner January 27, 2025 09:48
@tkajtoch tkajtoch self-requested a review January 29, 2025 13:13
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};
`


${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.

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}`}

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};
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
        : ''};

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
          : ''};


.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%)' : ''};

@@ -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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants