diff --git a/app/models/katalyst/content/aside.rb b/app/models/katalyst/content/aside.rb index 95c787c..598c0a6 100644 --- a/app/models/katalyst/content/aside.rb +++ b/app/models/katalyst/content/aside.rb @@ -3,6 +3,13 @@ module Katalyst module Content class Aside < Layout + style_attributes do + attribute :reverse, :boolean, default: false + end + + def self.permitted_params + super + %i[reverse] + end end end end diff --git a/app/views/katalyst/content/asides/_aside.html+form.erb b/app/views/katalyst/content/asides/_aside.html+form.erb index 45b9e76..fef76e0 100644 --- a/app/views/katalyst/content/asides/_aside.html+form.erb +++ b/app/views/katalyst/content/asides/_aside.html+form.erb @@ -22,6 +22,11 @@ <%= form.check_box :visible %> +
+ <%= form.label :reverse %> + <%= form.check_box :reverse %> +
+ <%= form.submit "Done" %> <%= link_to "Discard", :back %> <% end %> diff --git a/app/views/katalyst/content/asides/_aside.html.erb b/app/views/katalyst/content/asides/_aside.html.erb index f97e39b..3982df0 100644 --- a/app/views/katalyst/content/asides/_aside.html.erb +++ b/app/views/katalyst/content/asides/_aside.html.erb @@ -4,7 +4,7 @@ <% if aside.children.any? %> <% items = aside.children.select(&:visible?) %> <% last = items.pop %> -
+
>
<%= render_content_items items %>
diff --git a/spec/models/katalyst/content/aside_spec.rb b/spec/models/katalyst/content/aside_spec.rb index 9c56170..8494bf5 100644 --- a/spec/models/katalyst/content/aside_spec.rb +++ b/spec/models/katalyst/content/aside_spec.rb @@ -4,7 +4,7 @@ require_relative "item_examples" RSpec.describe Katalyst::Content::Aside do - subject(:aside) { build(:katalyst_content_section, container: page) } + subject(:aside) { build(:katalyst_content_aside, container: page) } let(:page) { create(:page) } @@ -12,11 +12,16 @@ let(:item) { aside } end + it "can round trip style attributes" do + aside = create(:katalyst_content_aside, container: page, reverse: true) + expect(aside.reload).to have_attributes(reverse: true) + end + describe "#to_plain_text" do it { is_expected.to have_attributes(to_plain_text: aside.heading) } context "when heading is hidden" do - subject(:aside) { build(:katalyst_content_section, heading_style: "none", container: page) } + subject(:aside) { build(:katalyst_content_aside, heading_style: "none", container: page) } it { is_expected.to have_attributes(to_plain_text: nil) } end