katalyst-content 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 433c0f1ad7f53e425f5feaeacde9ad27ec1303062aeda91dcae10e8ef326679c
4
- data.tar.gz: f49acc4f588d226dddca67f181604605b44f353d67e0a38c5d7a578e1c835c9a
3
+ metadata.gz: 9add66f2ceddd578d133b679abf018fc4af299b100ab60b12c93e701e0681c3f
4
+ data.tar.gz: 6432a682a93e61c38b3bbaecc3dc392c9be03070838094cbd195646e6a0bcdcf
5
5
  SHA512:
6
- metadata.gz: bd55fbd95ac4e58a8e6860b3f278f4b17fd1752ec777b4ce1cbfc7fe9998155ff5c7b8cbc409e60d4cd33ed824390e3d5f9efe5d098d332e41965502e3095724
7
- data.tar.gz: a0c9151ed9800288dd8a8b56ed121e523a9cca2bcc64c73ff58368ce2c32c87738539fad679816bdfb3c431eaf90b9f8c098057f83e0b60c92590b4af528fe54
6
+ metadata.gz: 74ef81a842d28873e577a245a84a97649814d2fdd1387e25cb2fcb273fca7edf4c5fee147bcfcddf3c556a66d11bb9d58705b73e9daae383271fd1ab93ed0362
7
+ data.tar.gz: 1a8dd6463ff2146bf80ffaecb05adc76e866d956d89544c3257dc2a38be4f8f38d3c86090e464a2571d37108cf3a5d8ceb8e9ffa0223d83cdee435791cd5c7c6
@@ -26,7 +26,7 @@ module Katalyst
26
26
  end
27
27
 
28
28
  def self.permitted_params
29
- super - %i[show_heading] + %i[image caption]
29
+ super - %i[heading_style] + %i[image caption]
30
30
  end
31
31
 
32
32
  alias_attribute :alt, :heading
@@ -8,12 +8,16 @@ module Katalyst
8
8
  Katalyst::Content.config
9
9
  end
10
10
 
11
+ enum heading_style: config.heading_styles, _prefix: :heading
12
+
11
13
  belongs_to :container, polymorphic: true
12
14
 
13
15
  validates :heading, presence: true
16
+ validates :heading_style, inclusion: { in: config.heading_styles }
14
17
  validates :background, presence: true, inclusion: { in: config.backgrounds }, if: :validate_background?
15
18
 
16
19
  after_initialize :initialize_tree
20
+ before_validation :set_defaults
17
21
 
18
22
  attr_accessor :parent, :children, :index, :depth
19
23
 
@@ -23,7 +27,7 @@ module Katalyst
23
27
  container_id
24
28
  type
25
29
  heading
26
- show_heading
30
+ heading_style
27
31
  background
28
32
  visible
29
33
  ]
@@ -33,6 +37,14 @@ module Katalyst
33
37
  heading if show_heading? && visible?
34
38
  end
35
39
 
40
+ def show_heading?
41
+ !heading_none?
42
+ end
43
+
44
+ def heading_style_class
45
+ heading_style unless heading_default?
46
+ end
47
+
36
48
  def layout?
37
49
  is_a? Layout
38
50
  end
@@ -44,6 +56,10 @@ module Katalyst
44
56
  self.children ||= []
45
57
  end
46
58
 
59
+ def set_defaults
60
+ self.heading_style = "none" if heading_style.blank?
61
+ end
62
+
47
63
  def validate_background?
48
64
  true
49
65
  end
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag aside do %>
2
- <%= tag.h3 aside.heading if aside.show_heading? %>
2
+ <%= tag.h3 aside.heading, class: aside.heading_style_class if aside.show_heading? %>
3
3
 
4
4
  <% items = aside.children.select(&:visible?) %>
5
5
  <% last = items.pop %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,14 +1,18 @@
1
1
  <%= content_item_tag column do %>
2
- <%= tag.h3 column.heading if column.show_heading? %>
2
+ <%= tag.h3 column.heading, class: column.heading_style_class if column.show_heading? %>
3
3
 
4
4
  <% items = column.children.select(&:visible?) %>
5
5
  <% last = items.pop %>
6
6
  <div class="columns-container">
7
7
  <div class="column">
8
- <%= render_content_items items %>
8
+ <% if items.any? %>
9
+ <%= render_content_items items %>
10
+ <% elsif last %>
11
+ <%= render_content_items [last] %>
12
+ <% end %>
9
13
  </div>
10
14
  <div class="column">
11
- <%= render_content_items [last] if last %>
15
+ <%= render_content_items [last] if last && items.any? %>
12
16
  </div>
13
17
  </div>
14
18
  <% end %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag content do %>
2
- <%= tag.h3 content.heading if content.show_heading? %>
2
+ <%= tag.h3 content.heading, class: content.heading_style_class if content.show_heading? %>
3
3
 
4
4
  <%= content.content %>
5
5
  <% end %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag group do %>
2
- <%= tag.h3 group.heading if group.show_heading? %>
2
+ <%= tag.h3 group.heading, class: group.heading_style_class if group.show_heading? %>
3
3
 
4
4
  <div>
5
5
  <%= render_content_items group.children %>
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -8,8 +8,8 @@
8
8
  </div>
9
9
 
10
10
  <div class="field">
11
- <%= form.label :show_heading %>
12
- <%= form.check_box :show_heading %>
11
+ <%= form.label :heading_style %>
12
+ <%= form.collection_radio_buttons :heading_style, Katalyst::Content.config.heading_styles, :itself, :itself %>
13
13
  </div>
14
14
 
15
15
  <div class="field">
@@ -1,5 +1,5 @@
1
1
  <%= content_item_tag section do %>
2
- <%= tag.h2 section.heading if section.show_heading? %>
2
+ <%= tag.h2 section.heading, class: section.heading_style_class if section.show_heading? %>
3
3
 
4
4
  <div>
5
5
  <%= render_content_items section.children %>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeKatalystContentItemsShowHeadingColumn < ActiveRecord::Migration[7.0]
4
+ def up
5
+ add_column :katalyst_content_items, :heading_style, :integer, null: false, default: 0
6
+ Katalyst::Content::Item.where(show_heading: true).update_all(heading_style: 1)
7
+ remove_column :katalyst_content_items, :show_heading, :boolean
8
+ end
9
+
10
+ def down
11
+ raise ActiveRecord::IrreversibleMigration
12
+ end
13
+ end
@@ -8,6 +8,7 @@ module Katalyst
8
8
  include ActiveSupport::Configurable
9
9
 
10
10
  config_accessor(:backgrounds) { %w[light dark] }
11
+ config_accessor(:heading_styles) { %w[none default] }
11
12
  config_accessor(:items) do
12
13
  %w[
13
14
  Katalyst::Content::Content
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Content
5
- VERSION = "1.0.2"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  FactoryBot.define do
4
4
  trait :content_item_defaults do
5
5
  heading { Faker::Lorem.word }
6
- show_heading { true }
6
+ heading_style { "default" }
7
7
  background { Katalyst::Content.config.backgrounds.sample }
8
8
  depth { 0 }
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-15 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_storage_validations
@@ -108,6 +108,7 @@ files:
108
108
  - config/routes.rb
109
109
  - db/migrate/20220913003839_create_katalyst_content_items.rb
110
110
  - db/migrate/20220926061535_add_fields_for_figure_to_katalyst_content_items.rb
111
+ - db/migrate/20230515151440_change_katalyst_content_items_show_heading_column.rb
111
112
  - lib/katalyst/content.rb
112
113
  - lib/katalyst/content/config.rb
113
114
  - lib/katalyst/content/engine.rb