Skip to content

Commit 2b1218d

Browse files
committed
fix style issue on mobile
1 parent b7d6a1c commit 2b1218d

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

src/components/ChangelogFilters/ChangelogFilters.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import styles from "./styles.module.css"
22
import type { ChangelogItem } from "~/components/ChangelogSnippet/types.ts"
33
import { DesktopFilters } from "./DesktopFilters.tsx"
44
import { MobileFilters } from "./MobileFilters.tsx"
5+
import { useState } from "react"
6+
import { clsx } from "~/lib/clsx/clsx.ts"
57

68
export interface ChangelogFiltersProps {
79
products: string[]
@@ -11,13 +13,22 @@ export interface ChangelogFiltersProps {
1113
}
1214

1315
export const ChangelogFilters = ({ products, networks, types, items }: ChangelogFiltersProps) => {
16+
const [searchExpanded, setSearchExpanded] = useState(false)
17+
1418
return (
15-
<div className={styles.wrapper}>
19+
<div className={clsx(styles.wrapper, searchExpanded && styles.searchExpanded)}>
1620
<div className={styles.desktopFilters}>
1721
<DesktopFilters products={products} networks={networks} types={types} items={items} />
1822
</div>
1923
<div className={styles.mobileFilters}>
20-
<MobileFilters products={products} networks={networks} types={types} items={items} />
24+
<MobileFilters
25+
products={products}
26+
networks={networks}
27+
types={types}
28+
items={items}
29+
searchExpanded={searchExpanded}
30+
onSearchExpandedChange={setSearchExpanded}
31+
/>
2132
</div>
2233
</div>
2334
)

src/components/ChangelogFilters/MobileFilters.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,27 @@ interface MobileFiltersProps {
252252
networks: string[]
253253
types: string[]
254254
items: ChangelogItem[]
255+
searchExpanded: boolean
256+
onSearchExpandedChange: (expanded: boolean) => void
255257
}
256258

257-
export const MobileFilters = ({ products, networks, types, items }: MobileFiltersProps) => {
259+
export const MobileFilters = ({
260+
products,
261+
networks,
262+
types,
263+
items,
264+
searchExpanded,
265+
onSearchExpandedChange,
266+
}: MobileFiltersProps) => {
258267
const [isMobileFiltersOpen, setIsMobileFiltersOpen] = useState(false)
259268
const [expandedSection, setExpandedSection] = useState<FilterType>(null)
260269

261270
const {
262-
searchExpanded,
263271
searchTerm,
264272
selectedProducts,
265273
selectedNetworks,
266274
selectedTypes,
267275
handleSearchChange,
268-
handleSearchToggle,
269276
toggleSelection,
270277
clearProductFilters,
271278
clearNetworkFilters,
@@ -314,11 +321,11 @@ export const MobileFilters = ({ products, networks, types, items }: MobileFilter
314321

315322
return (
316323
<>
317-
<div className={styles.content}>
324+
<div className={clsx(styles.content, searchExpanded && styles.searchExpanded)}>
318325
<MobileFiltersButton totalCount={totalFilterCount} onClick={() => setIsMobileFiltersOpen(true)} />
319326
<SearchInput
320327
isExpanded={searchExpanded}
321-
onClick={handleSearchToggle}
328+
onClick={onSearchExpandedChange}
322329
value={searchTerm}
323330
onChange={handleSearchChange}
324331
/>

src/components/ChangelogFilters/styles.module.css

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,19 +376,38 @@
376376

377377
.mobileFilters {
378378
display: block;
379+
width: 100%;
379380
}
380381

381382
.wrapper {
382-
min-width: auto;
383383
max-width: calc(100% - var(--space-4x));
384384
padding: var(--space-2x);
385+
min-width: unset;
386+
}
387+
388+
.wrapper.searchExpanded {
389+
width: 100%;
390+
max-width: 100%;
385391
}
386392

387393
.content {
388394
grid-template-columns: auto 1fr;
389395
gap: var(--space-2x);
390396
}
391397

398+
/* When search is expanded on mobile, keep both elements inline */
399+
.content.searchExpanded {
400+
grid-template-columns: auto 1fr;
401+
gap: var(--space-3x);
402+
width: 100%;
403+
}
404+
405+
/* Override desktop expanded behavior for mobile */
406+
.searchInputWrapper.expanded {
407+
width: auto;
408+
grid-column-end: auto;
409+
}
410+
392411
.searchInputWrapper {
393412
padding: var(--space-2x);
394413
}

0 commit comments

Comments
 (0)