Skip to content

Commit 4fc1cee

Browse files
committed
feat(ui/ux): improve the assets library based on a designer's feedbacks
1 parent a8d4ce7 commit 4fc1cee

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

app/components/maglev/uikit/image_library/card_component.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<div class="absolute inset-0 h-full w-full rounded">
44
<img
55
src="<%= image_url %>"
6-
class="h-full w-full object-contain <%= 'cursor-pointer' if picker_attributes %>"
7-
<% if picker_attributes %>
6+
class="h-full w-full object-contain <%= 'cursor-pointer' if picker_mode? %>"
7+
<% if picker_mode? %>
88
data-controller="dispatcher"
99
data-action="click->dispatcher#trigger click->uikit-modal#close:self"
1010
data-dispatcher-event-name-value="<%= picker_event_name %>"
@@ -35,7 +35,7 @@
3535
</div>
3636
<div class="mt-1 text-xs font-bold text-gray-900 truncate" title="<%= filename %>"><%= filename %></div>
3737
<div class="mb-1 flex items-center text-xs justify-between text-gray-700">
38-
<span><%= width %>x<%= height %></span>
39-
<span><%= number_to_human_size(byte_size) %></span>
38+
<span><% if width_and_height? %><%= width %>x<%= height %><% end %></span>
39+
<span><% if byte_size.present? %><%= number_to_human_size(byte_size) %><% end %></span>
4040
</div>
4141
</div>

app/components/maglev/uikit/image_library/card_component.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def initialize(image:, delete_path:, picker_attributes: nil)
1717
@picker_attributes = picker_attributes
1818
end
1919

20+
def picker_mode?
21+
picker_attributes.present? && picker_attributes[:picker].present?
22+
end
23+
2024
def picker_event_payload
2125
{
2226
source: picker_attributes[:source],
@@ -38,6 +42,10 @@ def picker_event_image_payload
3842
def picker_event_name
3943
"image-selected-#{picker_attributes[:source]}"
4044
end
45+
46+
def width_and_height?
47+
width.present? && height.present?
48+
end
4149
end
4250
end
4351
end

app/views/maglev/editor/assets/index.html.erb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
<div class="space-y-5">
77
<div class="flex items-center">
88
<div>
9-
<%= render Maglev::Uikit::ImageLibrary::UploaderComponent.new(
10-
create_path: editor_assets_path,
11-
refresh_path: editor_assets_path(query_params)
12-
) %>
13-
</div>
14-
<div class="ml-auto">
159
<%= render Maglev::Uikit::Form::SearchFormComponent.new(
1610
name: 'query',
1711
value: params[:query],
@@ -20,6 +14,13 @@
2014
placeholder: t('maglev.editor.image_library.search_placeholder'),
2115
data: { turbo_frame: 'asset-search-results' }
2216
}) %>
17+
18+
</div>
19+
<div class="ml-auto">
20+
<%= render Maglev::Uikit::ImageLibrary::UploaderComponent.new(
21+
create_path: editor_assets_path,
22+
refresh_path: editor_assets_path(query_params)
23+
) %>
2324
</div>
2425
</div>
2526

spec/components/previews/maglev/uikit/image_library/card_component_preview.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ def with_very_long_filename
3333
)
3434
end
3535

36+
def with_missing_width_and_height
37+
render_with_template(
38+
template: 'maglev/uikit/image_library/card_component_preview/default',
39+
locals: { image: build_image(1).merge(width: nil, height: nil) }
40+
)
41+
end
42+
3643
# @!endgroup
3744

3845
private

0 commit comments

Comments
 (0)