Skip to content

Commit 30dc067

Browse files
authored
RI-7681: refactor the connectivity option section (#5145)
1 parent 965856d commit 30dc067

File tree

4 files changed

+73
-96
lines changed

4 files changed

+73
-96
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import styled from 'styled-components'
2+
import { RiBadge } from 'uiSrc/components/base/display/badge/RiBadge'
3+
import { RiIcon } from 'uiSrc/components/base/icons'
4+
5+
import { Link } from 'uiSrc/components/base/link/Link'
6+
7+
export const StyledConnectivityLink = styled(Link)`
8+
min-width: 150px;
9+
padding: 10px;
10+
11+
display: flex;
12+
align-items: center;
13+
justify-content: center;
14+
15+
border-radius: 5px;
16+
border: 1px solid ${({ theme }) => theme.semantic.color.border.neutral700};
17+
color: ${({ theme }) => theme.semantic.color.text.neutral800};
18+
19+
// adding position relative to allow possible elements
20+
// inside the link to be positioned absolutely
21+
position: relative;
22+
23+
&:hover {
24+
text-decoration: none !important;
25+
background: none;
26+
color: ${({ theme }) => theme.semantic.color.text.neutral800};
27+
opacity: 0.8;
28+
transform: translateY(-1px);
29+
box-shadow: none;
30+
}
31+
`
32+
33+
export const StyledBadge = styled(RiBadge)`
34+
position: absolute;
35+
top: 10px;
36+
left: 10px;
37+
`
38+
39+
// This style is needed as the max built in size of the icon is not sufficient in this case
40+
export const StyledIcon = styled(RiIcon)`
41+
width: 30px;
42+
height: 30px;
43+
`

redisinsight/ui/src/pages/home/components/add-database-screen/components/connectivity-options/ConnectivityOptions.tsx

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,53 @@
11
import React from 'react'
2-
import styled from 'styled-components'
32

43
import { AddDbType } from 'uiSrc/pages/home/constants'
54
import { FeatureFlagComponent, OAuthSsoHandlerDialog } from 'uiSrc/components'
65
import { getUtmExternalLink } from 'uiSrc/utils/links'
76
import { EXTERNAL_LINKS, UTM_CAMPAINGS } from 'uiSrc/constants/links'
87
import { FeatureFlags } from 'uiSrc/constants'
98
import { OAuthSocialAction, OAuthSocialSource } from 'uiSrc/slices/interfaces'
10-
11-
// to be replaced with cloud icon from @redis-ui/icons once redis-ui bumped
12-
import CloudIcon from 'uiSrc/assets/img/oauth/cloud_centered.svg?react'
13-
import { RocketIcon } from 'uiSrc/components/base/icons'
14-
15-
import { Col, FlexItem, Grid } from 'uiSrc/components/base/layout/flex'
9+
import { Col, FlexItem, Grid, Row } from 'uiSrc/components/base/layout/flex'
1610
import { Spacer } from 'uiSrc/components/base/layout/spacer'
17-
import { SecondaryButton } from 'uiSrc/components/base/forms/buttons'
18-
import { RiBadge } from 'uiSrc/components/base/display/badge/RiBadge'
1911
import { Text } from 'uiSrc/components/base/text/Text'
20-
import { Link } from 'uiSrc/components/base/link/Link'
12+
import { RiIcon } from 'uiSrc/components/base/icons'
2113
import { CONNECTIVITY_OPTIONS } from '../../constants'
2214

23-
import styles from './styles.module.scss'
15+
import {
16+
StyledBadge,
17+
StyledConnectivityLink,
18+
StyledIcon,
19+
} from './ConnectivityOptions.styles'
2420

2521
export interface Props {
2622
onClickOption: (type: AddDbType) => void
2723
onClose?: () => void
2824
}
2925

30-
const NewCloudLink = styled(Link)`
31-
min-width: 160px;
32-
display: flex;
33-
align-items: center;
34-
justify-content: center;
35-
text-decoration: none !important;
36-
& * {
37-
text-decoration: none !important;
38-
}
39-
position: relative;
40-
width: 100%;
41-
height: 84px !important;
42-
padding: 0 12px;
43-
border: 1px solid ${({ theme }) => theme.semantic.color.border.primary500};
44-
border-radius: 5px;
45-
46-
& .freeBadge {
47-
position: absolute;
48-
top: 10px;
49-
left: 10px;
50-
51-
text-transform: uppercase;
52-
border-radius: 3px;
53-
}
54-
55-
& .btnIcon {
56-
margin-bottom: 8px;
57-
width: 30px;
58-
height: 30px;
59-
}
60-
`
61-
6226
const ConnectivityOptions = (props: Props) => {
6327
const { onClickOption, onClose } = props
6428

6529
return (
6630
<>
67-
<section className={styles.cloudSection}>
31+
<section>
6832
<Text color="primary">Get started with Redis Cloud account</Text>
6933
<Spacer />
7034
<Grid gap="l" columns={3} responsive>
7135
<FlexItem>
72-
<SecondaryButton
73-
className={styles.typeBtn}
36+
<StyledConnectivityLink
7437
onClick={() => onClickOption(AddDbType.cloud)}
7538
data-testid="discover-cloud-btn"
7639
>
77-
<Col align="center">
78-
<CloudIcon />
79-
Add databases
40+
<Col align="center" gap="s">
41+
<StyledIcon type="CloudIcon" size="xl" />
42+
<Text color="primary">Add databases</Text>
8043
</Col>
81-
</SecondaryButton>
44+
</StyledConnectivityLink>
8245
</FlexItem>
8346
<FeatureFlagComponent name={FeatureFlags.cloudAds}>
8447
<FlexItem>
8548
<OAuthSsoHandlerDialog>
8649
{(ssoCloudHandlerClick, isSSOEnabled) => (
87-
<NewCloudLink
50+
<StyledConnectivityLink
8851
data-testid="create-free-db-btn"
8952
color="primary"
9053
onClick={(e: React.MouseEvent) => {
@@ -99,17 +62,16 @@ const ConnectivityOptions = (props: Props) => {
9962
})}
10063
target="_blank"
10164
>
102-
<RiBadge className="freeBadge" label="Free" variant="notice" />
103-
<Col align="center">
104-
<RocketIcon className="btnIcon" />
105-
New database
65+
<StyledBadge label="FREE" variant="notice" />
66+
<Col align="center" gap="s">
67+
<StyledIcon type="RocketIcon" size="xl" />
68+
<Text color="primary">New database</Text>
10669
</Col>
107-
</NewCloudLink>
70+
</StyledConnectivityLink>
10871
)}
10972
</OAuthSsoHandlerDialog>
11073
</FlexItem>
11174
</FeatureFlagComponent>
112-
<FlexItem grow />
11375
</Grid>
11476
</section>
11577
<Spacer size="xxl" />
@@ -119,14 +81,15 @@ const ConnectivityOptions = (props: Props) => {
11981
<Grid gap="l" responsive columns={3}>
12082
{CONNECTIVITY_OPTIONS.map(({ id, type, title, icon }) => (
12183
<FlexItem key={id}>
122-
<SecondaryButton
123-
icon={icon}
84+
<StyledConnectivityLink
12485
onClick={() => onClickOption(type)}
12586
data-testid={`option-btn-${id}`}
126-
size="large"
12787
>
128-
{title}
129-
</SecondaryButton>
88+
<Row gap="s" align="center" justify="center">
89+
<RiIcon type={icon} size="xl" />
90+
<Text color="primary">{title}</Text>
91+
</Row>
92+
</StyledConnectivityLink>
13093
</FlexItem>
13194
))}
13295
</Grid>

redisinsight/ui/src/pages/home/components/add-database-screen/components/connectivity-options/styles.module.scss

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { AllIconsType } from 'uiSrc/components/base/icons'
12
import { AddDbType } from 'uiSrc/pages/home/constants'
2-
import { DownloadIcon, IconType, RedisSoftwareIcon, ShieldIcon } from 'uiSrc/components/base/icons'
33

44
export interface Values {
55
connectionURL: string
@@ -9,26 +9,26 @@ export interface ConnectivityOption {
99
id: string
1010
title: string
1111
type: AddDbType
12-
icon: IconType
12+
icon: AllIconsType
1313
}
1414

1515
export const CONNECTIVITY_OPTIONS: ConnectivityOption[] = [
1616
{
1717
id: 'sentinel',
1818
title: 'Redis Sentinel',
1919
type: AddDbType.sentinel,
20-
icon: ShieldIcon,
20+
icon: "ShieldIcon",
2121
},
2222
{
2323
id: 'software',
2424
title: 'Redis Software',
2525
type: AddDbType.software,
26-
icon: RedisSoftwareIcon,
26+
icon: "RedisSoftwareIcon",
2727
},
2828
{
2929
id: 'import',
3030
title: 'Import from file',
3131
type: AddDbType.import,
32-
icon: DownloadIcon,
32+
icon: "DownloadIcon",
3333
},
3434
]

0 commit comments

Comments
 (0)