Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .ai/rules/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,85 @@ export const Wrapper = styled(FlexGroup)`
`
```

### Use Gap Prop Instead of Custom Margins

**Prefer `gap` prop on layout components** instead of custom margins for spacing between elements:

```typescript
// ✅ GOOD: Use gap prop
<Row align="center" justify="between" gap="l">
<FlexItem>Item 1</FlexItem>
<FlexItem>Item 2</FlexItem>
</Row>
```

### Use Theme Spacing Instead of Magic Numbers

**Always use theme spacing values** instead of hardcoded pixel values:

```typescript
// ✅ GOOD: Use theme spacing
export const Container = styled(Row)`
height: ${({ theme }) => theme.core.space.space500};
padding: 0 ${({ theme }) => theme.core.space.space200};
margin-bottom: ${({ theme }) => theme.core.space.space200};
`;

// ❌ BAD: Using magic numbers
export const Container = styled(Row)`
height: 64px;
padding: 0 16px;
margin-bottom: 16px;
`;
```

### Use Semantic Colors from Theme

**Always use semantic colors** from the theme instead of CSS variables or hardcoded colors:

```typescript
// ✅ GOOD: Use semantic colors
export const Header = styled(Row)`
background-color: ${({ theme }) =>
theme.semantic.color.background.neutral100};
border-bottom: 1px solid
${({ theme }) => theme.semantic.color.border.neutral500};
`;

// ❌ BAD: Using deprecated EUI CSS variables
export const Header = styled(Row)`
background-color: var(--euiColorEmptyShade);
border-bottom: 1px solid var(--separatorColor);
`;
```

### Use Layout Components (Row/Col/FlexGroup) Instead of div

**Prefer layout components** from the layout system instead of regular `div` elements:

```typescript
// ✅ GOOD: Use Row component
import { Row } from 'uiSrc/components/base/layout/flex'

export const PageHeader = styled(Row)`
height: ${({ theme }) => theme.core.space.space500};
background-color: ${({ theme }) =>
theme.semantic.color.background.neutral100};
`

<PageHeader align="center" justify="between" gap="l">
{children}
</PageHeader>

// ❌ BAD: Using div with flex properties
export const PageHeader = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
height: 64px;
`
```

### Conditional Styling

Use `$` prefix for transient props that shouldn't pass to DOM:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled from 'styled-components'
import { Row } from 'uiSrc/components/base/layout/flex'
import { type Theme } from 'uiSrc/components/base/theme/types'

export const PageDefaultHeader = styled(Row)`
height: ${({ theme }: { theme: Theme }) => theme.core.space.space800};
background-color: ${({ theme }: { theme: Theme }) =>
theme.semantic.color.background.neutral100};
border-bottom: 1px solid
${({ theme }: { theme: Theme }) => theme.semantic.color.border.neutral500};
padding: 0 ${({ theme }: { theme: Theme }) => theme.core.space.space200};
margin-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space200};
`

export const PageWrapper = styled.div`
height: calc(
100% - ${({ theme }: { theme: Theme }) => theme.core.space.space800} -
${({ theme }: { theme: Theme }) => theme.core.space.space200}
);
overflow: hidden;
`

export const ExplorePanelWrapper = styled.div`
padding-bottom: ${({ theme }: { theme: Theme }) => theme.core.space.space200};
`
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import { OAuthSocialSource } from 'uiSrc/slices/interfaces'
import { CopilotTrigger, InsightsTrigger } from 'uiSrc/components/triggers'

import { FlexGroup, FlexItem } from 'uiSrc/components/base/layout/flex'
import styles from './styles.module.scss'
import { ProgressBarLoader } from 'uiSrc/components/base/display'
import {
ExplorePanelWrapper,
PageDefaultHeader,
PageWrapper,
} from './HomePageTemplate.styles'
import { instancesSelector as databaseInstancesSelector } from 'uiSrc/slices/instances/instances'
import { instancesSelector as rdiInstancesSelector } from 'uiSrc/slices/rdi/instances'

Expand Down Expand Up @@ -40,11 +44,15 @@ const HomePageTemplate = (props: Props) => {
return (
<>
{loading && (
<ProgressBarLoader color="primary" data-testid="progress-key-stream" absolute />
<ProgressBarLoader
color="primary"
data-testid="progress-key-stream"
absolute
/>
)}
<div className={styles.pageDefaultHeader}>
<PageDefaultHeader align="center" justify="between" gap="l">
<HomeTabs />
<FlexGroup gap="l">
<FlexGroup align="center" justify="end" gap="l">
{isAnyChatAvailable && (
<FlexItem>
<CopilotTrigger />
Expand All @@ -61,12 +69,12 @@ const HomePageTemplate = (props: Props) => {
</FlexItem>
</FeatureFlagComponent>
</FlexGroup>
</div>
<div className={styles.pageWrapper}>
<ExplorePanelTemplate panelClassName={styles.explorePanel}>
{children}
</ExplorePanelTemplate>
</div>
</PageDefaultHeader>
<PageWrapper>
<ExplorePanelWrapper>
<ExplorePanelTemplate>{children}</ExplorePanelTemplate>
</ExplorePanelWrapper>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Side panel padding applied to wrong element

The panelClassName prop that previously passed padding-bottom: 16px styling to ExplorePanelTemplate (and through it to SidePanelsStyledSidePanel) has been removed. Instead, ExplorePanelWrapper now applies padding-bottom to a wrapper around the entire template. This changes where the padding is applied - from the side panel component itself to an outer container, which has different visual behavior. The SidePanels component uses panelClassName to style the StyledSidePanel element directly, so the side panels will no longer receive the intended padding-bottom styling.

Additional Locations (1)

Fix in Cursor Fix in Web

</PageWrapper>
</>
)
}
Expand Down

This file was deleted.

Loading