Skip to content

Commit 58dd250

Browse files
authored
RI-7774 Fix navigation icons alignment on the Databases page (#5267)
* fix(ui): align Coplit and Insights icons on Databases page References: #RI-7774
1 parent 4905099 commit 58dd250

File tree

4 files changed

+122
-54
lines changed

4 files changed

+122
-54
lines changed

.ai/rules/frontend.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,85 @@ export const Wrapper = styled(FlexGroup)`
122122
`
123123
```
124124

125+
### Use Gap Prop Instead of Custom Margins
126+
127+
**Prefer `gap` prop on layout components** instead of custom margins for spacing between elements:
128+
129+
```typescript
130+
// ✅ GOOD: Use gap prop
131+
<Row align="center" justify="between" gap="l">
132+
<FlexItem>Item 1</FlexItem>
133+
<FlexItem>Item 2</FlexItem>
134+
</Row>
135+
```
136+
137+
### Use Theme Spacing Instead of Magic Numbers
138+
139+
**Always use theme spacing values** instead of hardcoded pixel values:
140+
141+
```typescript
142+
// ✅ GOOD: Use theme spacing
143+
export const Container = styled(Row)`
144+
height: ${({ theme }) => theme.core.space.space500};
145+
padding: 0 ${({ theme }) => theme.core.space.space200};
146+
margin-bottom: ${({ theme }) => theme.core.space.space200};
147+
`;
148+
149+
// ❌ BAD: Using magic numbers
150+
export const Container = styled(Row)`
151+
height: 64px;
152+
padding: 0 16px;
153+
margin-bottom: 16px;
154+
`;
155+
```
156+
157+
### Use Semantic Colors from Theme
158+
159+
**Always use semantic colors** from the theme instead of CSS variables or hardcoded colors:
160+
161+
```typescript
162+
// ✅ GOOD: Use semantic colors
163+
export const Header = styled(Row)`
164+
background-color: ${({ theme }) =>
165+
theme.semantic.color.background.neutral100};
166+
border-bottom: 1px solid
167+
${({ theme }) => theme.semantic.color.border.neutral500};
168+
`;
169+
170+
// ❌ BAD: Using deprecated EUI CSS variables
171+
export const Header = styled(Row)`
172+
background-color: var(--euiColorEmptyShade);
173+
border-bottom: 1px solid var(--separatorColor);
174+
`;
175+
```
176+
177+
### Use Layout Components (Row/Col/FlexGroup) Instead of div
178+
179+
**Prefer layout components** from the layout system instead of regular `div` elements:
180+
181+
```typescript
182+
// ✅ GOOD: Use Row component
183+
import { Row } from 'uiSrc/components/base/layout/flex'
184+
185+
export const PageHeader = styled(Row)`
186+
height: ${({ theme }) => theme.core.space.space500};
187+
background-color: ${({ theme }) =>
188+
theme.semantic.color.background.neutral100};
189+
`
190+
191+
<PageHeader align="center" justify="between" gap="l">
192+
{children}
193+
</PageHeader>
194+
195+
// ❌ BAD: Using div with flex properties
196+
export const PageHeader = styled.div`
197+
display: flex;
198+
align-items: center;
199+
justify-content: space-between;
200+
height: 64px;
201+
`
202+
```
203+
125204
### Conditional Styling
126205

127206
Use `$` prefix for transient props that shouldn't pass to DOM:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import styled from 'styled-components'
2+
import { Row } from 'uiSrc/components/base/layout/flex'
3+
import { type Theme } from 'uiSrc/components/base/theme/types'
4+
5+
export const PageDefaultHeader = styled(Row)`
6+
height: ${({ theme }: { theme: Theme }) => theme.core.space.space800};
7+
background-color: ${({ theme }: { theme: Theme }) =>
8+
theme.semantic.color.background.neutral100};
9+
border-bottom: 1px solid
10+
${({ theme }: { theme: Theme }) => theme.semantic.color.border.neutral500};
11+
padding: 0 ${({ theme }: { theme: Theme }) => theme.core.space.space200};
12+
margin-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space200};
13+
`
14+
15+
export const PageWrapper = styled.div`
16+
height: calc(
17+
100% - ${({ theme }: { theme: Theme }) => theme.core.space.space800} -
18+
${({ theme }: { theme: Theme }) => theme.core.space.space200}
19+
);
20+
overflow: hidden;
21+
`
22+
23+
export const ExplorePanelWrapper = styled.div`
24+
padding-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space200};
25+
`

redisinsight/ui/src/templates/home-page-template/HomePageTemplate.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ import { OAuthSocialSource } from 'uiSrc/slices/interfaces'
1111
import { CopilotTrigger, InsightsTrigger } from 'uiSrc/components/triggers'
1212

1313
import { FlexGroup, FlexItem } from 'uiSrc/components/base/layout/flex'
14-
import styles from './styles.module.scss'
1514
import { ProgressBarLoader } from 'uiSrc/components/base/display'
15+
import {
16+
ExplorePanelWrapper,
17+
PageDefaultHeader,
18+
PageWrapper,
19+
} from './HomePageTemplate.styles'
1620
import { instancesSelector as databaseInstancesSelector } from 'uiSrc/slices/instances/instances'
1721
import { instancesSelector as rdiInstancesSelector } from 'uiSrc/slices/rdi/instances'
1822

@@ -40,11 +44,15 @@ const HomePageTemplate = (props: Props) => {
4044
return (
4145
<>
4246
{loading && (
43-
<ProgressBarLoader color="primary" data-testid="progress-key-stream" absolute />
47+
<ProgressBarLoader
48+
color="primary"
49+
data-testid="progress-key-stream"
50+
absolute
51+
/>
4452
)}
45-
<div className={styles.pageDefaultHeader}>
53+
<PageDefaultHeader align="center" justify="between" gap="l">
4654
<HomeTabs />
47-
<FlexGroup gap="l">
55+
<FlexGroup align="center" justify="end" gap="l">
4856
{isAnyChatAvailable && (
4957
<FlexItem>
5058
<CopilotTrigger />
@@ -61,12 +69,12 @@ const HomePageTemplate = (props: Props) => {
6169
</FlexItem>
6270
</FeatureFlagComponent>
6371
</FlexGroup>
64-
</div>
65-
<div className={styles.pageWrapper}>
66-
<ExplorePanelTemplate panelClassName={styles.explorePanel}>
67-
{children}
68-
</ExplorePanelTemplate>
69-
</div>
72+
</PageDefaultHeader>
73+
<PageWrapper>
74+
<ExplorePanelWrapper>
75+
<ExplorePanelTemplate>{children}</ExplorePanelTemplate>
76+
</ExplorePanelWrapper>
77+
</PageWrapper>
7078
</>
7179
)
7280
}

redisinsight/ui/src/templates/home-page-template/styles.module.scss

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)