Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
@apply ms-0 col-start-2;
}
}

select {
@apply text-foreground bg-background border-tertiary;
}
}

.loading-spinner {
Expand Down
11 changes: 11 additions & 0 deletions app/assets/stylesheets/css/components/ui/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@
.card__header {
@apply flex flex-col items-start self-stretch py-3 px-4;

&:has(select),
&:has(.button) {
@apply pe-0;
}

/* `sm` size buttons make the header too tall. This will compensate for it. */
.button {
@apply -my-1;
}
}

.card--compact-header {
.card__header {
@apply py-1 px-2;
}
}

/* Card title - Copy/14/500 from Figma */
.card__title {
@apply text-content font-medium leading-6 text-sm;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/css/components/ui/panel_header.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.header {
@apply flex flex-col gap-2 items-start justify-center pe-0 py-0 px-1;
@apply flex flex-col gap-2 items-start justify-center pe-0 py-0;
}

.header__main {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.main {
--sidebar-width: --spacing(64);
--sidebar-offset-size: 0rem;
--content-width: calc(100% - var(--sidebar-offset-size) - var(--spacing)*2);
--content-width: calc(100% - var(--sidebar-offset-size) - var(--spacing) * 2);

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

.scrollable-wrapper {
@apply overflow-y-auto h-full flex-1 flex flex-col;
@apply overflow-y-auto h-full flex-1 flex flex-col px-2;
}
.avo-container {
@apply flex flex-1 flex-col justify-between;
Expand Down
4 changes: 2 additions & 2 deletions app/components/avo/turbo_frame_wrapper_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% if @name.present? %>
<turbo-frame id="<%= @name %>">
<%= turbo_frame_tag @name, class: @class do %>
<%= flash_content %>
<%= content %>
</turbo-frame>
<% end %>
<% else %>
<%= flash_content %>
<%= content %>
Expand Down
1 change: 1 addition & 0 deletions app/components/avo/turbo_frame_wrapper_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class Avo::TurboFrameWrapperComponent < Avo::BaseComponent
prop :name, kind: :positional
prop :class, kind: :positional

# When rendering the frames the flashed content gets lost.
# We're appending it back if it's a turbo_frame_request.
Expand Down
6 changes: 3 additions & 3 deletions app/components/avo/u_i/card_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= tag.div class: class_names("card", @class), data: {**@data, item_index: @index} do %>
<div class="card__wrapper">
<%= tag.div class: class_names("card__wrapper", @wrapper_class) do %>
<% if header? %>
<div class="card__header"><%= header %></div>
<% else %>
Expand All @@ -17,13 +17,13 @@
<% end %>

<% if body? %>
<div class="card__body"><%= body %></div>
<%= body %>
<% elsif content? %>
<div class="card__body"><%= content %></div>
<% end %>

<% if footer? %>
<div class="card__footer"><%= footer %></div>
<% end %>
</div>
<% end %>
<% end %>
13 changes: 12 additions & 1 deletion app/components/avo/u_i/card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@ class Avo::UI::CardComponent < Avo::BaseComponent
prop :title
prop :description
prop :class
prop :wrapper_class
prop :with_padding, default: -> { true }
prop :variant, default: -> { :default }
prop :options, kind: :**
prop :data, default: -> { {}.freeze }
prop :index

renders_one :header
renders_one :body
renders_one :body, "BodyComponent"
renders_one :footer

class BodyComponent < Avo::BaseComponent
prop :class

def call
tag.div class: class_names("card__body", @class), data: {**@data, item_index: @index} do
content
end
end
end

private

# def panel_classes
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/avo/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ def wrap_in_modal(content)
end
end

def editor_url(path)
Avo.configuration.default_editor_url.gsub("%{path}", path)
end

private

def avo_field(type = nil, id = nil, as: nil, view: :show, form: nil, component_options: {}, **args, &block)
Expand Down
9 changes: 9 additions & 0 deletions lib/avo/concerns/has_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module HasDescription

class_methods do
attr_accessor :description
attr_accessor :discreet_description
end

def description(additional_attributes = {})
Expand All @@ -16,6 +17,14 @@ def description(additional_attributes = {})
).handle
end

def discreet_description(additional_attributes = {})
Avo::ExecutionContext.new(
target: @discreet_description || self.class.discreet_description,
**description_attributes,
**additional_attributes
).handle
end

private

# Override this method to add custom attributes to the description execution context.
Expand Down
4 changes: 3 additions & 1 deletion lib/avo/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Configuration
attr_accessor :model_generator_hook
attr_accessor :send_metadata
attr_accessor :use_stacked_fields
attr_accessor :default_editor_url

def initialize
@root_path = "/avo"
Expand Down Expand Up @@ -118,7 +119,7 @@ def initialize
@turbo = default_turbo
@default_url_options = []
@pagination = {}
@click_row_to_view_record = false
@click_row_to_view_record = true
@alert_dismiss_time = 5000
@is_admin_method = :is_admin?
@is_developer_method = :is_developer?
Expand All @@ -136,6 +137,7 @@ def initialize
@model_generator_hook = true
@send_metadata = true
@use_stacked_fields = false
@default_editor_url = "cursor://file/%{path}"
end

unless defined?(RESOURCE_ROW_CONTROLS_CONFIG_DEFAULTS)
Expand Down
Loading