-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
app/components/avo/fields/common/heading_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<div class="flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs"> | ||
<%= content_tag :div, class: "flex items-start py-1 leading-tight bg-gray-100 text-gray-500 text-xs", data: @data do %> | ||
<div class="py-2 px-6 h-full w-full"> | ||
<% if as_html %> | ||
<%= sanitize value %> | ||
<% if @field.as_html %> | ||
<%= sanitize @field.value %> | ||
<% else %> | ||
<div class="font-semibold uppercase"><%= value %></div> | ||
<div class="font-semibold uppercase"><%= @field.value %></div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class Avo::Fields::Common::HeadingComponent < ViewComponent::Base | ||
attr_reader :value | ||
attr_reader :as_html | ||
include Avo::Concerns::HasResourceStimulusControllers | ||
|
||
def initialize(value:, as_html:) | ||
@value = value | ||
@as_html = as_html | ||
def initialize(field:) | ||
@field = field | ||
@view = field.resource.view | ||
|
||
@data = stimulus_data_attributes | ||
add_stimulus_attributes_for(field.resource, @data) | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/components/avo/fields/heading_field/edit_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>"> | ||
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.value, as_html: @field.as_html %> | ||
<%= render Avo::Fields::Common::HeadingComponent.new field: @field %> | ||
</div> |
2 changes: 1 addition & 1 deletion
2
app/components/avo/fields/heading_field/show_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div <% if @index == 0 %> class="overflow-hidden rounded-t" <% end %> data-field-id="<%= @field.id %>"> | ||
<%= render Avo::Fields::Common::HeadingComponent.new value: @field.value, as_html: @field.as_html %> | ||
<%= render Avo::Fields::Common::HeadingComponent.new field: @field %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters