Skip to content

Commit 60a37b4

Browse files
fix(global-header): Adjust the global header Stared Items icon color and visibility (#1340)
* fix(global-header): Adjust the global header starred items icon color and visibility - Changed star icon color from orange to gold (#F3BA37) for better visibility - Star icon now only appears on hover instead of being always visible - Maintains consistent styling with table view starred items across the application * fix(theme): Update API report for starred items color theme changes --------- Co-authored-by: Mitesh Kumar <itsmiteshkumar98@gmail.com>
1 parent ede7cb3 commit 60a37b4

7 files changed

Lines changed: 78 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-global-header': patch
3+
---
4+
5+
Fixes the global header starred items icon color and visibility:
6+
7+
- Changed star icon color to use theme.rhdh.general.starredItemsColor for better visibility and customization
8+
- Star icon now only appears on hover instead of being always visible
9+
- Maintains consistent styling with table view starred items across the application

workspaces/global-header/plugins/global-header/src/components/HeaderDropdownComponent/StarredDropdown.test.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,54 @@ describe('StarredDropdown', () => {
122122
fireEvent.click(screen.getByRole('button'));
123123
expect(handleOpen).toHaveBeenCalled();
124124
});
125+
126+
it('shows star icon only on hover via CSS', async () => {
127+
(useStarredEntities as jest.Mock).mockReturnValue({
128+
starredEntities: new Set(['component:default/my-entity']),
129+
toggleStarredEntity: jest.fn(),
130+
isStarredEntity: jest.fn(),
131+
});
132+
133+
(useDropdownManager as jest.Mock).mockReturnValue({
134+
anchorEl: document.createElement('div'), // Simulate open dropdown
135+
handleOpen: jest.fn(),
136+
handleClose: jest.fn(),
137+
});
138+
139+
await renderInTestApp(<StarredDropdown />);
140+
141+
const starButton = screen.getByLabelText('Remove from list');
142+
143+
// Star should be hidden initially
144+
expect(starButton).toHaveStyle('visibility: hidden');
145+
146+
// Star should have the star-icon class for CSS targeting
147+
expect(starButton).toHaveClass('star-icon');
148+
});
149+
150+
it('calls toggleStarredEntity when star icon is clicked', async () => {
151+
const toggleStarredEntity = jest.fn();
152+
(useStarredEntities as jest.Mock).mockReturnValue({
153+
starredEntities: new Set(['component:default/my-entity']),
154+
toggleStarredEntity,
155+
isStarredEntity: jest.fn(),
156+
});
157+
158+
(useDropdownManager as jest.Mock).mockReturnValue({
159+
anchorEl: document.createElement('div'), // Simulate open dropdown
160+
handleOpen: jest.fn(),
161+
handleClose: jest.fn(),
162+
});
163+
164+
await renderInTestApp(<StarredDropdown />);
165+
166+
// Star is always available for clicking, just hidden visually
167+
168+
const starButton = screen.getByLabelText('Remove from list');
169+
fireEvent.click(starButton);
170+
171+
expect(toggleStarredEntity).toHaveBeenCalledWith(
172+
'component:default/my-entity',
173+
);
174+
});
125175
});

workspaces/global-header/plugins/global-header/src/components/HeaderDropdownComponent/StarredDropdown.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const StarredItem: FC<SectionComponentProps> = ({
6464
const { name, kind, namespace } = parseEntityRef(entityRef as string);
6565
const theme = useTheme();
6666
const { t } = useTranslation();
67+
const rhdhPalette = (theme.palette as any).rhdh;
6768

6869
return (
6970
<MenuItem
@@ -72,6 +73,11 @@ const StarredItem: FC<SectionComponentProps> = ({
7273
onClick={handleClose}
7374
disableRipple
7475
disableTouchRipple
76+
sx={{
77+
'&:hover .star-icon, &:focus-visible .star-icon': {
78+
visibility: 'visible',
79+
},
80+
}}
7581
>
7682
{Icon && (
7783
<ListItemIcon sx={{ minWidth: 36 }}>
@@ -90,13 +96,18 @@ const StarredItem: FC<SectionComponentProps> = ({
9096
/>
9197
<Tooltip title={t('starred.removeTooltip')}>
9298
<IconButton
99+
className="star-icon"
93100
onClick={e => {
94101
e.preventDefault();
95102
e.stopPropagation();
96103
toggleStarredEntity(entityRef);
97104
}}
105+
sx={{
106+
visibility: 'hidden',
107+
color: rhdhPalette?.general?.starredItemsColor ?? '#F3BA37',
108+
}}
98109
>
99-
<Star color="warning" />
110+
<Star />
100111
</IconButton>
101112
</Tooltip>
102113
</MenuItem>

workspaces/theme/plugins/theme/report.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface RHDHThemePalette {
8787
appBarBackgroundColor: string;
8888
appBarForegroundColor: string;
8989
appBarBackgroundImage: string;
90+
starredItemsColor: string;
9091
};
9192
// (undocumented)
9293
primary: {

workspaces/theme/plugins/theme/src/darkTheme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export const darkThemeOverrides: Partial<ThemeConfigPalette> = {
8585
appBarBackgroundColor: '#151515',
8686
appBarForegroundColor: '#ffffff',
8787
appBarBackgroundImage: 'none',
88+
89+
starredItemsColor: '#F3BA37',
8890
},
8991
primary: {
9092
main: '#92c5f9',

workspaces/theme/plugins/theme/src/lightTheme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export const lightThemeOverrides: Partial<ThemeConfigPalette> = {
8585
appBarBackgroundColor: '#f2f2f2',
8686
appBarForegroundColor: '#1f1f1f',
8787
appBarBackgroundImage: 'none',
88+
89+
starredItemsColor: '#F3BA37',
8890
},
8991
primary: {
9092
main: '#0066CC',

workspaces/theme/plugins/theme/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export interface RHDHThemePalette {
5555
appBarBackgroundColor: string;
5656
appBarForegroundColor: string;
5757
appBarBackgroundImage: string;
58+
59+
starredItemsColor: string;
5860
};
5961

6062
primary: {

0 commit comments

Comments
 (0)