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
5 changes: 4 additions & 1 deletion components/GoalsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ export function GoalsList({
{initialGoals.length === 0 ? (
<p className="text-sm text-muted">No savings goals yet. Add one above.</p>
) : (
<div className="grid gap-4 md:grid-cols-2">
// Two to a row only from lg: below about 1000px, half the column is too narrow for a card's
// Saved row, which pushed the page sideways (#208). grid-cols-1 lets a card be narrower than
// its goal's name, which then truncates, rather than widen the page on a phone.
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
{initialGoals.map((g) => (
<GoalCard
key={g.id}
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/goals-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ describe('GoalsList', () => {
expect(bars.length).toBeGreaterThan(0)
})

// Two goals across from md, where the app switches between its phone and desktop layouts (#123),
// and one below it. At sm, 640-767px got two goals across beside the phone layout around them.
it('puts the goals two across from md up and one across below it', () => {
// Two goals across only from lg, and one below it. From md, two across left each card too narrow
// for its Saved row beside the sidebar, up to about 1000px, so the page scrolled sideways (#208).
// grid-cols-1, not a bare grid: a bare grid's one column grows to fit a long goal name, which then
// widened the page on a phone instead of truncating.
it('puts the goals two across from lg up and one across below it', () => {
const { container } = render(<GoalsList {...props} />)
expect(container.querySelector('[data-goal-card]')!.parentElement!.className).toBe('grid gap-4 md:grid-cols-2')
expect(container.querySelector('[data-goal-card]')!.parentElement!.className).toBe('grid grid-cols-1 gap-4 lg:grid-cols-2')
})

// Stacking must not cost the form any of its fields, nor the list any of its goals.
Expand Down
Loading