Skip to content
Open
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
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Only add comments for non-obvious logic, business context, or to help other engi
- ❌ `/** Tooltip content displayed on hover */ title: ReactNode`
- ❌ `/** Icon size */ size?: IconSize`

## Component & Icon Changes

When adding new icons, components, or promoting component status, ALWAYS update the corresponding documentation page (e.g., homepage `componentCategories.json`, docs pages, icon index files) as part of the same change. Do not consider the task complete until docs are updated.

## Adding Icons

### Rokt/Untitled UI Icons
Expand Down
64 changes: 51 additions & 13 deletions docs/About/Introduction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import React, { useState, useMemo } from 'react'
import categoriesData from './componentCategories.json'
import { Card, Flex, Icon, Typography } from '../../src/components'
import { Card, Empty, Flex, Icon, Input, Typography } from '../../src/components'
import { ColorBgLayout, PaddingXxs, Margin, MarginSm, MarginXl, PaddingXs, PaddingSm } from 'src/styles/style'

interface ComponentEntry {
Expand Down Expand Up @@ -194,17 +194,34 @@ function CategorySection({ category }: { category: Category }) {
}

export default function Introduction() {
const filtered = (categoriesData?.categories || []).filter(
cat => cat.name !== 'Navigation' && cat.components?.length > 0,
)
const categories = [...filtered].sort((a, b) => {
const i = CATEGORY_ORDER.indexOf(a.name)
const j = CATEGORY_ORDER.indexOf(b.name)
if (i !== -1 && j !== -1) return i - j
if (i !== -1) return -1
if (j !== -1) return 1
return a.name.localeCompare(b.name)
})
const [searchQuery, setSearchQuery] = useState('')

const allCategories = useMemo(() => {
const filtered = (categoriesData?.categories || []).filter(
cat => cat.name !== 'Navigation' && cat.components?.length > 0,
)
return [...filtered].sort((a, b) => {
const i = CATEGORY_ORDER.indexOf(a.name)
const j = CATEGORY_ORDER.indexOf(b.name)
if (i !== -1 && j !== -1) return i - j
if (i !== -1) return -1
if (j !== -1) return 1
return a.name.localeCompare(b.name)
})
}, [])

const categories = useMemo(() => {
if (!searchQuery.trim()) return allCategories
const query = searchQuery.toLowerCase()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Search query not trimmed before filtering components

Low Severity

The empty-guard on line 214 uses searchQuery.trim() to decide whether to filter, but the actual filtering query on line 215 uses searchQuery.toLowerCase() without trimming. A search like " radio " (with accidental leading/trailing whitespace) passes the guard but fails to match any component name because the spaces are included in the .includes() check. The query variable needs to also be trimmed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c6b903c. Configure here.

return allCategories
.map(cat => ({
...cat,
components: cat.components?.filter(c => c.name.toLowerCase().includes(query)),
}))
.filter(cat => cat.components && cat.components.length > 0)
}, [allCategories, searchQuery])

const totalComponents = allCategories.reduce((sum, cat) => sum + (cat.components?.length || 0), 0)

return (
<Flex vertical>
Expand All @@ -213,6 +230,27 @@ export default function Introduction() {
Designed for developers, designers, and product managers, this library makes it easy to create intuitive,
interactive interfaces for <strong>Rokt applications</strong>.
</Typography.Paragraph>
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
columnGap: Margin,
marginBottom: MarginXl,
}}>
<Input
prefix={<Icon name="search" size="sm" />}
placeholder={`Search ${totalComponents} components...`}
allowClear
onChange={e => setSearchQuery(e.target.value)}
value={searchQuery}
style={{ gridColumn: 'span 2' }}
/>
</div>
{categories.length === 0 && searchQuery.trim() && (
<Flex align="center" justify="center" style={{ minHeight: 300 }}>
<Empty title="No components found" description={`Nothing matches "${searchQuery}"`} />
</Flex>
)}
{categories.map(category => (
<CategorySection key={category.name} category={category} />
))}
Expand Down
Loading