-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve look of section navigation cards when at least one section has an image #2302
Conversation
54c54cb
to
b5b73de
Compare
@@ -1,7 +1,17 @@ | |||
<div class="grid grid-cols-1 gap-5 sm:gap-6 sm:grid-cols-2 lg:grid-cols-4"> | |||
<% has_section_images = section_navigation.rooms.any? { |r| r.hero_image.present? } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love seeing this type of logic in templates because I like to swing toward logic-less templates generally, but...I also wouldn't elevate it to the model since it's quite view specific. Of course a ViewComponent class would be a nice place for this. (Just thinking out loud.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other "Rails-y" place for this is a method in a helper -- we could start a SectionNavigationHelper
and add this as a predicate there.
My feeling is that this probably wants to become a ViewComponent
sooner rather than later, and in that case this will make sense as a method in there.
I generally avoid having complex logic in a view, but I also think that most views in the real world will have some kind of logic in them, so I'm not religious about it. In this case I feel like this is simple enough and enough of an area that we are likely still iterate on that this is ok for now.
<% policy_scope(section_navigation.rooms).each do |room| %> | ||
<%= link_to polymorphic_path(room.location), id: dom_id(room, :link_to), class: "group no-underline" do %> | ||
<%= render CardComponent.new(media: room.hero_image, classes: "flex flex-col justify-between h-full") do |card| %> | ||
<% if has_section_images && room.hero_image.blank? %> | ||
<% card.with_header do %> | ||
<div class="text-6xl tracking-wider h-36 bg-amber-50 text-amber-600/25 p-4 rounded-md text-clip overflow-hidden flex"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tailwind is...flexible. 🤣
@anaulin nice use of clamping! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm sold on the amber (it makes it look a bit like a caution sign, maybe grey?) and it feels like the text is a bit large... (text-4xl perhaps is the right size?)
Anyway, I think it's fine as-is; and we can polish it up later.
b5b73de
to
af963ab
Compare
Hmm, yeah, I sort of don't love this. I was envisioning something more "pictorial" that could be auto-generated as stand-ins for missing pictures, but my result looks more like A VERY LARGE TITLE THAT SOMETIMES DOESN'T FIT. @zspencer @rosschapman would something like this be better? Or do you like it more with the text? This version randomizes the background color for a more placeholder-y look, and removes the text: (The height of the bottom row needs to be adjusted to match the top row with the description, but that's a different issue.) |
ooo, I like that quite a bit! The pastels are lovely! |
@anaulin looks good. Will passing the |
@rosschapman removing that margin is one of several remaining TO-DOs in this PR (see the PR description for my full list so far) |
…to the other cards. When one of the section cards has a description, make sure that all cards have uniform heights, even if that particular card does not have a description.
af963ab
to
4592429
Compare
@zspencer @rosschapman I've gone back and cleaned up the implementation, and updated the screenshots in the PR description. Please have a final look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌈
bg-rose-100 bg-sky-100 bg-teal-100 | ||
].freeze | ||
def image_placeholder_div | ||
content_tag(:div, "", class: "h-36 #{BG_COLORS.sample} m-0 p-0 rounded-t-lg w-full") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So cool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very neat!
Gizmo
:SectionNavigation
#1988This PR refines the look of the section navigation component:
Before
After