Skip to content

Commit ed2bdb7

Browse files
authored
feat: convert theme presets to horizontally scrollable carousel on mobile (JhaSourav07#2187)
## Description This PR improves the mobile responsiveness of the Customization Studio by converting the Theme Preset section into a horizontally scrollable layout on smaller screens. ### Changes Made * Added horizontal scrolling support for Theme Presets on mobile devices. * Preserved the existing wrapped layout behavior on larger screens. * Reduced vertical space usage and improved theme browsing experience on narrow viewports. * Updated the related test assertions to match the new implementation. Fixes JhaSourav07#1886 ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview ### Before <img width="391" height="847" alt="Screenshot 2026-06-01 001208" src="https://github.com/user-attachments/assets/378de170-9362-49b8-b810-4902361aca5c" /> * Theme Presets were displayed in multiple rows on mobile screens, consuming excessive vertical space. ### After <img width="387" height="844" alt="Screenshot 2026-06-01 001255" src="https://github.com/user-attachments/assets/32555876-d659-4093-bade-18fa32fca5ee" /> * Theme Presets are displayed in a horizontally scrollable row on mobile screens, improving usability and reducing scrolling. ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). * [x] I have run `npm run format` and `npm run lint` locally and resolved all errors. * [ ] I have run `npm run test` and all tests pass locally. * [ ] I have run `npm run test:coverage` and branch coverage is at or above 70%. * [x] My commits follow the Conventional Commits format. * [ ] I have updated `README.md` if I added a new theme or URL parameter. (Not applicable) * [x] I have starred the repo. * [x] I have made sure that I have only one commit to merge in this PR. * [x] The changes maintain the existing UI quality and responsiveness standards. * [x] (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.
2 parents a0261cb + 128e402 commit ed2bdb7

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

app/customize/components/ThemeQuickPresets.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,28 @@
9292
border-radius: 50%;
9393
background: rgba(255, 255, 255, 0.85);
9494
}
95+
.theme-quick-presets {
96+
display: flex;
97+
flex-wrap: wrap;
98+
gap: 6px;
99+
width: 100%;
100+
max-width: 100%;
101+
}
102+
103+
@media (max-width: 640px) {
104+
.theme-quick-presets {
105+
flex-wrap: nowrap;
106+
overflow-x: auto;
107+
overflow-y: hidden;
108+
width: 100%;
109+
max-width: calc(100vw - 96px);
110+
padding-bottom: 8px;
111+
scroll-snap-type: x proximity;
112+
-webkit-overflow-scrolling: touch;
113+
}
114+
115+
.theme-quick-presets .tqp-btn {
116+
flex: 0 0 auto;
117+
scroll-snap-align: start;
118+
}
119+
}

app/customize/components/ThemeQuickPresets.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ describe('ThemeQuickPresets responsive rendering & high-contrast', () => {
133133
const grid = buttons.at(0)?.parentElement;
134134

135135
expect(grid).not.toBeNull();
136-
expect(grid?.style.display).toBe('flex');
137-
expect(grid?.style.flexWrap).toBe('wrap');
136+
expect(grid?.className).toContain('theme-quick-presets');
138137
});
139138

140139
it('check if each preset button has theme bg colour(inline)', () => {

app/customize/components/ThemeQuickPresets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ const ICON_MAP: Record<string, (c: IC) => ReactElement> = {
519519
export function ThemeQuickPresets({ theme, onThemeChange }: ThemeQuickPresetsProps): ReactElement {
520520
return (
521521
<>
522-
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}>
522+
<div className="theme-quick-presets">
523523
{THEME_KEYS.filter((key) => key !== 'auto' && key !== 'random').map((key) => {
524524
const t = themes[key as ThemeKey];
525525
if (!t) return null;

0 commit comments

Comments
 (0)