-
Notifications
You must be signed in to change notification settings - Fork 407
RI-7059: Replace EUI Link with Redis Link #4620
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
Merged
dantovska
merged 13 commits into
fe/feature/RI-7039-replace-eui
from
feature/RI-7059-replace-eui-link
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bbfa4e0
replace in workbench settings
dantovska 1302453
replace in database list wrapper
dantovska 3d1b94d
replace link everywhere
dantovska 7a34057
fix profile badge styling
dantovska 2cbbfac
WIP: add color prop to the link and remove global link styles.
dantovska dc54baf
fixing Link.tsx typescript error
pd-redis cdf9be8
finalize link styles
dantovska 6d858de
refactor
dantovska 99b3603
create use profile link component and replace
dantovska 4598f44
remove custom styles; fix profile link styling
dantovska 1fa1a0a
remove links import
dantovska b604c0d
Remove not needed file
dantovska 4dfaae6
replace Link with EmptyButton
dantovska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import React from 'react' | ||
import { Link as RedisUiLink } from '@redis-ui/components' | ||
import { LinkProps } from '@redis-ui/components' | ||
import { StyledLink } from 'uiSrc/components/base/link/link.styles' | ||
|
||
export type LinkProps = React.ComponentProps<typeof RedisUiLink> | ||
export const Link = (props: LinkProps) => <RedisUiLink {...props} /> | ||
export const Link = ({ color, ...props }: LinkProps) => ( | ||
<StyledLink {...props} $color={color} /> | ||
) |
28 changes: 28 additions & 0 deletions
28
redisinsight/ui/src/components/base/link/UserProfileLink.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import styled from "styled-components" | ||
import { useTheme } from "@redis-ui/styles" | ||
import { Link } from "./Link" | ||
|
||
export const UserProfileLink = styled(Link)` | ||
padding: 8px 12px !important; | ||
width: 100%; | ||
color: ${({ theme }: { theme: ReturnType<typeof useTheme> }) => | ||
theme.semantic.color.text.informative400} !important; | ||
text-decoration: none !important; | ||
|
||
&:not(:last-child) { | ||
border-bottom: 1px solid | ||
${({ theme }: { theme: ReturnType<typeof useTheme> }) => | ||
theme.color.gray400}; | ||
} | ||
|
||
span { | ||
width: 100%; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
|
||
text-decoration: none !important; | ||
cursor: pointer; | ||
} | ||
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import styled, { css } from 'styled-components' | ||
import { Link as RedisUiLink, LinkProps } from '@redis-ui/components' | ||
import { useTheme } from '@redis-ui/styles' | ||
|
||
// TODO [DA]: Export the color functionality and use both for Link and Text | ||
export type EuiColorNames = | ||
| 'inherit' | ||
| 'default' | ||
| 'primary' | ||
| 'text' | ||
| 'subdued' | ||
| 'danger' | ||
| 'ghost' | ||
| 'accent' | ||
| 'warning' | ||
| 'success' | ||
|
||
export type ColorType = LinkProps['color'] | EuiColorNames | (string & {}) | ||
|
||
export type RiLinkProps = Omit<LinkProps, 'color'> & { | ||
color?: ColorType | ||
} | ||
|
||
export interface MapProps extends RiLinkProps { | ||
$color?: ColorType | ||
} | ||
|
||
export const useColorTextStyles = ({ $color }: MapProps = {}) => { | ||
const theme = useTheme() | ||
const colors = theme.semantic.color | ||
|
||
const getColorValue = (color?: ColorType) => { | ||
if (!color) { | ||
return colors.text.primary500 | ||
} | ||
switch (color) { | ||
case 'inherit': | ||
return 'inherit' | ||
case 'default': | ||
case 'primary': | ||
return colors.text.primary500 | ||
case 'text': | ||
return colors.text.neutral700 | ||
case 'subdued': | ||
return colors.text.informative400 | ||
case 'danger': | ||
return colors.text.danger600 | ||
case 'ghost': | ||
return colors.text.neutral600 | ||
case 'accent': | ||
return colors.text.notice600 | ||
case 'warning': | ||
return colors.text.attention600 | ||
case 'success': | ||
return colors.text.success600 | ||
default: | ||
return color // any supported color value e.g #fff | ||
} | ||
Comment on lines
+32
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I like the map syntax for such features: const colorMap: Record<string, string> = {
inherit: 'inherit',
default: colors.text.primary500,
primary: colors.text.primary500,
text: colors.text.neutral700,
subdued: colors.text.informative400,
danger: colors.text.danger600,
ghost: colors.text.neutral600,
accent: colors.text.notice600,
warning: colors.text.attention600,
success: colors.text.success600,
}
const getColorValue = (color?: ColorType) => {
if (!color) {
return colors.text.primary500
}
return colorMap[color] ?? color
} IMO its less verbose. We can define it outside |
||
} | ||
|
||
return css` | ||
color: ${getColorValue($color)}; | ||
` | ||
} | ||
|
||
export const StyledLink = styled(RedisUiLink)<MapProps>` | ||
${useColorTextStyles}; | ||
|
||
text-decoration: underline !important; | ||
|
||
&:hover { | ||
text-decoration: none !important; | ||
} | ||
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: do we still need these
!important
statements?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we do in this case... I tried removing it but there are some inherited styles that break it.