Skip to content

Commit 288931c

Browse files
authored
fix: link color in simple menu (#1965)
<!-- Hello 👋 Thank you for submitting a pull request. To help us merge your PR, make sure to follow the instructions below: - Create or update the tests - Create or update the documentation at https://github.com/strapi/documentation - Refer to the issue you are closing in the PR description: Fix #issue - Specify if the PR is ready to be merged or work in progress (by opening a draft PR) Please ensure you read the Contributing Guide: https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md --> ### What does it do? Fixes the link color (text and icon) in simple menu by adding color and active color props (default to the existing color) to the Link component. No breaking changes. ### Why is it needed? #1934 (comment) ### How to test it? Provide information about the environment and the path to verify the behaviour. ### Related issue(s)/PR(s) Let us know if this is related to any issue/pull request <img width="627" height="730" alt="Screenshot 2025-10-13 at 15 40 05" src="https://github.com/user-attachments/assets/c92f1a36-9ca0-4bac-80a0-5e504c0aa1d4" />
2 parents c7c6f6a + 48566b3 commit 288931c

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

.changeset/tricky-dolphins-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': minor
3+
---
4+
5+
fix: link color (icon + text) in simple menu

docs/stories/SimpleMenu.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const WithLinks = {
5050
<MenuItem href="/" isLink>
5151
Home
5252
</MenuItem>
53-
<MenuItem href="/accounts" isLink>
53+
<MenuItem href="/accounts" startIcon={<Bell />} isLink disabled>
5454
Accounts
5555
</MenuItem>
5656
<MenuItem href="https://strapi.io/" isExternal>

packages/design-system/src/components/Link/Link.tsx

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22

33
import { ExternalLink } from '@strapi/icons';
4-
import { styled } from 'styled-components';
4+
import { styled, type DefaultTheme } from 'styled-components';
55

66
import { Typography } from '../../primitives/Typography';
77
import { focus } from '../../styles/buttons';
@@ -16,27 +16,56 @@ type LinkProps<C extends React.ElementType = 'a'> = BaseLinkProps<C> & {
1616
* @default false
1717
*/
1818
isExternal?: boolean;
19+
/**
20+
* @default primary600
21+
*/
22+
color?: keyof DefaultTheme['colors'];
23+
/**
24+
* @default primary700
25+
*/
26+
activeColor?: keyof DefaultTheme['colors'];
1927
};
2028

2129
const Link = forwardRef(
2230
<C extends React.ElementType = 'a'>(
23-
{ children, href, disabled = false, startIcon, endIcon, isExternal = false, ...props }: LinkProps<C>,
31+
{
32+
children,
33+
href,
34+
disabled = false,
35+
startIcon,
36+
endIcon,
37+
isExternal = false,
38+
color = 'primary600',
39+
activeColor = 'primary700',
40+
...props
41+
}: LinkProps<C>,
2442
ref: PolymorphicRef<C>,
2543
) => {
2644
return (
27-
<LinkWrapper ref={ref} href={href} disabled={disabled} isExternal={isExternal} {...props}>
45+
<LinkWrapper
46+
ref={ref}
47+
href={href}
48+
disabled={disabled}
49+
isExternal={isExternal}
50+
$activeColor={activeColor}
51+
$color={color}
52+
{...props}
53+
>
2854
{startIcon}
29-
<Typography textColor={disabled ? 'neutral600' : 'primary600'}>{children}</Typography>
55+
<Typography textColor={disabled ? 'neutral600' : color}>{children}</Typography>
3056
{endIcon}
31-
{href && !endIcon && isExternal && <ExternalLink />}
57+
{href && !endIcon && isExternal && <ExternalLink fill={color} />}
3258
</LinkWrapper>
3359
);
3460
},
3561
);
3662

3763
type LinkComponent<C extends React.ElementType = 'a'> = (props: LinkProps<C>) => React.ReactNode;
3864

39-
const LinkWrapper = styled<BaseLinkComponent>(BaseLink)`
65+
const LinkWrapper = styled<BaseLinkComponent>(BaseLink)<{
66+
$color?: keyof DefaultTheme['colors'];
67+
$activeColor?: keyof DefaultTheme['colors'];
68+
}>`
4069
display: inline-flex;
4170
align-items: center;
4271
text-decoration: none;
@@ -47,22 +76,23 @@ const LinkWrapper = styled<BaseLinkComponent>(BaseLink)`
4776
font-size: 1rem;
4877
4978
path {
50-
fill: ${({ disabled, theme }) => (disabled ? theme.colors.neutral600 : theme.colors.primary600)};
79+
fill: ${({ disabled, $color, theme }) =>
80+
disabled ? theme.colors.neutral600 : theme.colors[$color || 'primary600']};
5181
}
5282
}
5383
5484
&:hover {
5585
& > span {
56-
color: ${({ theme }) => theme.colors.primary500};
86+
color: ${({ theme, $color }) => theme.colors[$color || 'primary600']};
5787
}
5888
5989
svg path {
60-
fill: ${({ theme }) => theme.colors.primary500};
90+
fill: ${({ theme, $color }) => theme.colors[$color || 'primary600']};
6191
}
6292
}
6393
6494
&:active {
65-
color: ${({ theme }) => theme.colors.primary700};
95+
color: ${({ theme, $activeColor }) => theme.colors[$activeColor || 'primary700']};
6696
}
6797
6898
${focus};

packages/design-system/src/components/SimpleMenu/Menu.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ const getOptionStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: It
252252
content: none;
253253
}
254254
}
255+
256+
color: ${theme.colors[getTextColor($variant, false)]};
255257
`;
256258

257259
const OptionButton = styled<FlexComponent<'button' | 'a'>>(Flex)<{ $variant: ItemVariant }>`
@@ -265,12 +267,26 @@ const OptionLink = styled(Link)<{ $variant: ItemVariant }>`
265267
266268
&:hover {
267269
color: unset;
270+
271+
> svg {
272+
path {
273+
fill: ${({ theme, $variant }) => theme.colors[getIconColor($variant, false)]};
274+
}
275+
}
268276
}
277+
> svg {
278+
path {
279+
fill: ${({ theme, $variant }) => theme.colors[getIconColor($variant, false)]};
280+
}
281+
}
282+
&[aria-disabled='true'] {
283+
pointer-events: none;
269284
270-
/* TODO: do we need this? */
271-
svg > path,
272-
&:focus-visible svg > path {
273-
fill: currentColor;
285+
> svg {
286+
path {
287+
fill: ${({ theme, $variant }) => theme.colors[getIconColor($variant, true)]};
288+
}
289+
}
274290
}
275291
276292
${({ theme, $variant }) => getOptionStyle({ theme, $variant })}

0 commit comments

Comments
 (0)