Skip to content

Commit 60756dd

Browse files
drusepthclaude
andcommitted
Improve card grid layout with CSS Grid for consistent heights
- Replaced flexbox approach with CSS Grid for better card consistency - Removed force-stretched content elements while maintaining grid structure - Implemented grid-template-rows for proper content alignment - Added responsive breakpoints to handle different screen sizes - Removed unnecessary flex constraints from card elements - Preserved natural content flow while achieving consistent card heights 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b403232 commit 60756dd

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

app/views/browse/tag.html.erb

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@
114114
<div class="row js-content-cards-list">
115115
<% content_group[:content].each do |content| %>
116116
<div class="col s12 m6 l4 xl3 js-content-card-container">
117-
<div class="hoverable card sticky-action z-depth-1" style="margin-bottom: 20px; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; height: 450px;">
117+
<div class="hoverable card sticky-action z-depth-1" style="margin-bottom: 20px; border-radius: 8px; overflow: hidden;">
118118
<!-- Color indicator bar at top of card -->
119119
<div style="height: 4px; background-color: <%= content_group[:color] == 'grey' ? '#9e9e9e' : "var(--#{content_group[:color]})" %>;"></div>
120120

121-
<div class="card-image waves-effect waves-block waves-light" style="flex: 0 0 auto;">
121+
<div class="card-image waves-effect waves-block waves-light">
122122
<%
123123
# Find image for this content
124124
content_image = @random_image_pool_cache.fetch([content.class.name, content.id], [])
@@ -146,7 +146,7 @@
146146
</div>
147147

148148
<!-- Improved card actions -->
149-
<div class="card-content" style="padding: 16px; border-bottom: 1px solid #f0f0f0; flex: 1 0 auto; display: flex; flex-direction: column;">
149+
<div class="card-content" style="padding: 16px; border-bottom: 1px solid #f0f0f0;">
150150
<!-- Creator info with avatar -->
151151
<% user = @users_cache[content.user_id] %>
152152
<% if user %>
@@ -166,7 +166,7 @@
166166

167167
<!-- Tags as pills -->
168168
<% if content.respond_to?(:page_tags) && content.page_tags.any? %>
169-
<div class="tags-container" style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; flex: 1 0 auto;">
169+
<div class="tags-container" style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;">
170170
<% content.page_tags.each do |tag| %>
171171
<% if tag.tag == @tag %>
172172
<span class="tag-pill" style="padding: 4px 10px; background-color: <%= content_group[:color] == 'grey' ? '#9e9e9e' : "var(--#{content_group[:color]}-lighten-1)" %>; color: white; border-radius: 20px; font-size: 12px;">
@@ -182,7 +182,7 @@
182182
<% end %>
183183
</div>
184184

185-
<div class="card-action" style="display: flex; justify-content: space-between; background-color: #fafafa; padding: 12px 16px; flex: 0 0 auto;">
185+
<div class="card-action" style="display: flex; justify-content: space-between; background-color: #fafafa; padding: 12px 16px;">
186186
<% if content.is_a?(Document) %>
187187
<%= link_to content, class: "#{content_group[:color]}-text", style: "font-weight: 500; display: flex; align-items: center;", target: '_blank' do %>
188188
<i class="material-icons left" style="font-size: 18px; margin-right: 6px;">visibility</i> View
@@ -372,25 +372,41 @@
372372
--orange-lighten-5: #fff3e0;
373373
}
374374

375-
/* Equal height card grid */
375+
/* Card grid layout */
376376
.js-content-cards-list {
377-
display: flex;
378-
flex-wrap: wrap;
377+
display: block;
379378
}
380379

381-
.js-content-card-container {
382-
display: flex;
383-
margin-bottom: 20px;
384-
}
385-
386-
/* Responsive adjustments */
387-
@media only screen and (max-width: 993px) {
380+
/* Card height consistency using CSS Grid */
381+
@media only screen and (min-width: 601px) {
382+
.js-content-cards-list {
383+
display: grid;
384+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
385+
grid-gap: 20px;
386+
}
387+
388388
.js-content-card-container {
389-
height: auto;
389+
margin-bottom: 0;
390+
}
391+
392+
.js-content-card-container .card {
393+
height: 100%;
394+
margin-bottom: 0;
395+
display: grid;
396+
grid-template-rows: auto 1fr auto;
397+
}
398+
399+
.card .card-image {
400+
grid-row: 1;
401+
}
402+
403+
.card .card-content {
404+
grid-row: 2;
390405
}
391406

392-
.card.sticky-action {
393-
height: auto !important;
407+
.card .card-action {
408+
grid-row: 3;
409+
align-self: end;
394410
}
395411
}
396412

0 commit comments

Comments
 (0)