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

[Fleet][Eui Visual Refresh] Update text color tokens #204537

Merged
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
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const FleetTopNav = memo(

const readOnlyBtnClass = React.useMemo(() => {
return css`
color: ${euiTheme.colors.text};
color: ${euiTheme.colors.textParagraph};
`;
}, [euiTheme]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const IntegrationsHeader = ({
const { euiTheme } = useEuiTheme();
const readOnlyBtnClass = React.useMemo(() => {
return css`
color: ${euiTheme.colors.text};
color: ${euiTheme.colors.textParagraph};
`;
}, [euiTheme]);
const isReadOnly = useIsReadOnly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
* 2.0.
*/

import styled from 'styled-components';
import { EuiContextMenuItem } from '@elastic/eui';
import React from 'react';
import { css } from '@emotion/react';
import type { EuiContextMenuItemProps } from '@elastic/eui';
import { EuiContextMenuItem, useEuiTheme } from '@elastic/eui';

export const DangerEuiContextMenuItem = styled(EuiContextMenuItem)`
color: ${(props) => props.theme.eui.euiColorDangerText};
`;
export const DangerEuiContextMenuItem = (props: EuiContextMenuItemProps) => {
const theme = useEuiTheme();
return (
<EuiContextMenuItem
{...props}
css={css`
color: ${theme.euiTheme.colors.textDanger};
Copy link
Contributor

@mgadewoll mgadewoll Dec 17, 2024

Choose a reason for hiding this comment

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

Non blocking cleanup suggestion:
This is perfectly fine, but you can also use the object notation, which removes the need for importing css and using useEuiTheme specifically (since it's only used for this one case).

css={({ euiTheme }) => ({
  color: euiTheme.colors.textDanger,
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @mgadewoll thanks - I had tried that but ran into

TypeError: Cannot read properties of undefined (reading 'colors')

Here's the full component:

import React from 'react';
import type { EuiContextMenuItemProps } from '@elastic/eui';
import { EuiContextMenuItem } from '@elastic/eui';

export const DangerEuiContextMenuItem = (props: EuiContextMenuItemProps) => {
  return (
    <EuiContextMenuItem
      {...props}
      css={({ euiTheme }) => ({
        color: euiTheme.colors.textDanger,
      })}
    />
  );
};

Did I miss anything?

I found a similar occurrence with a note that an error is expected, leading to elastic/eui#8123. This comment suggests that the issue should be resolved though.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jillguyonnet Ah right, then your plugin doesn't have the required type set up yet.
You'll need to add types for your plugin to support this. (emotion docs)

Here an example of the required module.
And this then should be included in your tsconfig.json (example).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this! I'm capturing some frontend cleanup for Fleet UI in a dedicated task, I will add this in order to make getting the last EUI visual refresh PR over the line a priority.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, that makes perfect sense. It wasn't blocking for this PR 👍

`}
/>
);
};
Loading