Skip to content

Commit 0270c01

Browse files
authored
chore: dashboards improvements (#4269)
* chore: dashboards improvements * fix bad data * more file paths
1 parent 7d12fb5 commit 0270c01

File tree

13 files changed

+72
-11
lines changed

13 files changed

+72
-11
lines changed

app/assets/stylesheets/application.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@
207207
@apply ms-0 col-start-2;
208208
}
209209
}
210+
211+
select {
212+
@apply text-foreground bg-background border-tertiary;
213+
}
210214
}
211215

212216
.loading-spinner {

app/assets/stylesheets/css/components/ui/card.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,23 @@
3535
.card__header {
3636
@apply flex flex-col items-start self-stretch py-3 px-4;
3737

38+
&:has(select),
39+
&:has(.button) {
40+
@apply pe-0;
41+
}
42+
3843
/* `sm` size buttons make the header too tall. This will compensate for it. */
3944
.button {
4045
@apply -my-1;
4146
}
4247
}
4348

49+
.card--compact-header {
50+
.card__header {
51+
@apply py-1 px-2;
52+
}
53+
}
54+
4455
/* Card title - Copy/14/500 from Figma */
4556
.card__title {
4657
@apply text-content font-medium leading-6 text-sm;

app/assets/stylesheets/css/components/ui/panel_header.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.header {
2-
@apply flex flex-col gap-2 items-start justify-center pe-0 py-0 px-1;
2+
@apply flex flex-col gap-2 items-start justify-center pe-0 py-0;
33
}
44

55
.header__main {

app/assets/stylesheets/css/layout.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
.main {
1212
--sidebar-width: --spacing(64);
1313
--sidebar-offset-size: 0rem;
14-
--content-width: calc(100% - var(--sidebar-offset-size) - var(--spacing)*2);
14+
--content-width: calc(100% - var(--sidebar-offset-size) - var(--spacing) * 2);
1515

1616
@media (min-width: theme(--breakpoint-lg)) {
1717
&.sidebar-open {
@@ -29,7 +29,7 @@
2929
height: calc(100dvh - var(--spacing) - var(--top-navbar-height));
3030

3131
.scrollable-wrapper {
32-
@apply overflow-y-auto h-full flex-1 flex flex-col;
32+
@apply overflow-y-auto h-full flex-1 flex flex-col px-2;
3333
}
3434
.avo-container {
3535
@apply flex flex-1 flex-col justify-between;

app/components/avo/items/switcher_component.html.erb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<% end %>
4949
<% end %>
5050

51-
<% if @resource.get_external_link.present? || @resource.discreet_information.items.any? %>
51+
<% if @resource.get_external_link.present? || @resource.discreet_information.items.any? || Rails.env.development? %>
5252
<% header.with_discreet_information do %>
5353
<% if @resource.get_external_link.present? %>
5454
<%= render Avo::DiscreetInformationComponent.new(
@@ -60,6 +60,15 @@
6060
) %>
6161
<% end %>
6262

63+
<% if Rails.env.development? %>
64+
<%= render Avo::DiscreetInformationComponent.new(
65+
as: :icon,
66+
title: "Open in your editor",
67+
url: helpers.editor_file_path(@resource),
68+
icon: "tabler/outline/code"
69+
) %>
70+
<% end %>
71+
6372
<% @resource.discreet_information.items.each do |item| %>
6473
<%= render Avo::DiscreetInformationComponent.new(**item) %>
6574
<% end %>

app/components/avo/turbo_frame_wrapper_component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<% if @name.present? %>
2-
<turbo-frame id="<%= @name %>">
2+
<%= turbo_frame_tag @name, class: @class do %>
33
<%= flash_content %>
44
<%= content %>
5-
</turbo-frame>
5+
<% end %>
66
<% else %>
77
<%= flash_content %>
88
<%= content %>

app/components/avo/turbo_frame_wrapper_component.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
class Avo::TurboFrameWrapperComponent < Avo::BaseComponent
44
prop :name, kind: :positional
5+
prop :class, kind: :positional
56

67
# When rendering the frames the flashed content gets lost.
78
# We're appending it back if it's a turbo_frame_request.

app/components/avo/u_i/card_component.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%= tag.div class: class_names("card", @class), data: {**@data, item_index: @index} do %>
2-
<div class="card__wrapper">
2+
<%= tag.div class: class_names("card__wrapper", @wrapper_class) do %>
33
<% if header? %>
44
<div class="card__header"><%= header %></div>
55
<% else %>
@@ -17,13 +17,13 @@
1717
<% end %>
1818

1919
<% if body? %>
20-
<div class="card__body"><%= body %></div>
20+
<%= body %>
2121
<% elsif content? %>
2222
<div class="card__body"><%= content %></div>
2323
<% end %>
2424

2525
<% if footer? %>
2626
<div class="card__footer"><%= footer %></div>
2727
<% end %>
28-
</div>
28+
<% end %>
2929
<% end %>

app/components/avo/u_i/card_component.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ class Avo::UI::CardComponent < Avo::BaseComponent
44
prop :title
55
prop :description
66
prop :class
7+
prop :wrapper_class
78
prop :with_padding, default: -> { true }
89
prop :variant, default: -> { :default }
910
prop :options, kind: :**
1011
prop :data, default: -> { {}.freeze }
1112
prop :index
1213

1314
renders_one :header
14-
renders_one :body
15+
renders_one :body, "BodyComponent"
1516
renders_one :footer
1617

18+
class BodyComponent < Avo::BaseComponent
19+
prop :class
20+
prop :data, default: -> { {}.freeze }
21+
22+
def call
23+
tag.div class: class_names("card__body", @class), data: {**@data, item_index: @index} do
24+
content
25+
end
26+
end
27+
end
28+
1729
private
1830

1931
# def panel_classes

app/helpers/avo/application_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ def wrap_in_modal(content)
192192
end
193193
end
194194

195+
def editor_file_path(path)
196+
editor_url(Object.const_source_location(path.class.to_s)&.first)
197+
end
198+
199+
def editor_url(path)
200+
Avo.configuration.default_editor_url.gsub("%{path}", path)
201+
end
202+
195203
private
196204

197205
def avo_field(type = nil, id = nil, as: nil, view: :show, form: nil, component_options: {}, **args, &block)

0 commit comments

Comments
 (0)