katalyst-navigation 1.0.0 → 1.0.3

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: '0149b9c1ba7f7a1ecfcc1e085fbe33b2b0eb11d0d5372b743f05d0261daf88e3'
4
- data.tar.gz: 2648b6258ac7a7f2b4800f0b1371687cba043d9d4a647f5753076bc8a1b04327
3
+ metadata.gz: 94de0bbf95ab99d4893ec9decb52fa6c1a7231f1d58d17b1263e63124baaf10a
4
+ data.tar.gz: 3ec009c2845a80e4371aca788ac2b06de9a602cc468afecbbb5666d5a50fcb07
5
5
  SHA512:
6
- metadata.gz: d31db0f384749242de03b5bc04da8a0d3137092c702a3c4eda5769bf53fe1f764bb457bd672af5a60c1f3ef1daa22a7d2830e4f53b78b0f2161bdc2db675b54a
7
- data.tar.gz: 615fd376052d6b4e48351ef2d0d144a8bd66bfbe615d01b65eed57eb90a1679f4eae630abddbfe82d3aff9f1a47baa09987f4c3a536625f5ea00849612109805
6
+ metadata.gz: 043ce598613d8f99b98d777be94b0805d1504989eab5dba1e651a8d7fa2a2d8d4f89135530e300e65d37fea900237cba0e2a30caa7e95e81ab17000639bba5bb
7
+ data.tar.gz: c0795c1f30ed8ecea198e90d90097bcb6728bcbe2e7116ecd106e0c21c6e97e9c68a4ff981586bfa9436a22a7e63adf8c33da00f593541b17e77d316675fe4bb
@@ -1,4 +1,4 @@
1
- import Item from "./item";
1
+ import Item from "utils/navigation/editor/item";
2
2
 
3
3
  /**
4
4
  * @param nodes {NodeList}
@@ -7,7 +7,6 @@ export default class RulesEngine {
7
7
  "denyRemove",
8
8
  "denyDrag",
9
9
  "denyEdit",
10
- "invalidDepth",
11
10
  ];
12
11
 
13
12
  /**
@@ -19,8 +18,12 @@ export default class RulesEngine {
19
18
  update(item) {
20
19
  this.rules = {};
21
20
 
21
+ // structural rules enforce a valid tree structure
22
22
  this.firstItemDepthZero(item);
23
23
  this.depthMustBeSet(item);
24
+ this.itemCannotHaveInvalidDepth(item);
25
+
26
+ // behavioural rules define what the user is allowed to do
24
27
  this.parentsCannotDeNest(item);
25
28
  this.rootsCannotDeNest(item);
26
29
  this.nestingNeedsParent(item);
@@ -28,7 +31,6 @@ export default class RulesEngine {
28
31
  this.needHiddenItemsToExpand(item);
29
32
  this.parentsCannotBeDeleted(item);
30
33
  this.parentsCannotBeDragged(item);
31
- this.itemCannotHaveInvalidDepth(item);
32
34
 
33
35
  RulesEngine.rules.forEach((rule) => {
34
36
  item.toggleRule(rule, !!this.rules[rule]);
@@ -55,6 +57,18 @@ export default class RulesEngine {
55
57
  }
56
58
  }
57
59
 
60
+ /**
61
+ * Depth must increase stepwise.
62
+ *
63
+ * @param {Item} item
64
+ */
65
+ itemCannotHaveInvalidDepth(item) {
66
+ const previous = item.previousItem;
67
+ if (previous && previous.depth < item.depth - 1) {
68
+ item.depth = previous.depth + 1;
69
+ }
70
+ }
71
+
58
72
  /**
59
73
  * De-nesting an item would create a gap of 2 between itself and its children
60
74
  *
@@ -119,16 +133,6 @@ export default class RulesEngine {
119
133
  if (item.hasExpandedDescendants()) this.#deny("denyDrag");
120
134
  }
121
135
 
122
- /**
123
- * Depth must increase stepwise.
124
- *
125
- * @param {Item} item
126
- */
127
- itemCannotHaveInvalidDepth(item) {
128
- const previous = item.previousItem;
129
- if (previous && previous.depth < item.depth - 1) this.#deny("invalidDepth");
130
- }
131
-
132
136
  /**
133
137
  * Record a deny.
134
138
  *
@@ -80,7 +80,7 @@ $status-dirty-color: #aaa !default;
80
80
 
81
81
  // Dragged visuals
82
82
  &[data-dragging] {
83
- border: 2px dashed;
83
+ box-shadow: inset 0 0 0 2px var(--icon-passive-color);
84
84
 
85
85
  > * {
86
86
  visibility: hidden;
@@ -31,6 +31,7 @@
31
31
  border-radius: 2px;
32
32
  background: var(--icon-active-color);
33
33
  margin-right: 0.5rem;
34
+ flex-shrink: 0;
34
35
 
35
36
  [data-invisible="true"] & {
36
37
  background: var(--icon-passive-color);
@@ -16,9 +16,4 @@
16
16
  display: none !important;
17
17
  pointer-events: none;
18
18
  }
19
-
20
- [data-invalid-depth] {
21
- border-color: red;
22
- background-color: indianred;
23
- }
24
19
  }
@@ -3,7 +3,7 @@
3
3
  .navigation--editor--new-items {
4
4
  display: grid;
5
5
  grid-template-columns: repeat(3, 1fr);
6
- gap: 0.25rem;
6
+ gap: 0.5rem;
7
7
 
8
8
  [role="listitem"] {
9
9
  display: flex;
@@ -12,11 +12,28 @@
12
12
  align-items: center;
13
13
  transform: translate3d(0, 0, 0);
14
14
  cursor: grab;
15
+ background: white;
16
+ box-shadow: rgb(0 0 0 / 25%) 0 1px 1px, rgb(0 0 0 / 31%) 0 0 2px;
17
+ min-height: 5rem;
18
+ padding: 1.5rem;
19
+
20
+ &:hover {
21
+ box-shadow: rgb(0 0 0 / 25%) 0 1px 2px, rgb(0 0 0 / 31%) 0 0 5px;
22
+ }
15
23
 
16
24
  &::before {
17
25
  @extend %icon;
26
+ width: 2.5rem;
27
+ height: 2.5rem;
18
28
  position: unset;
19
- background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M16 3.66667V13.3333C16 14.8 14.6909 16 13.0909 16H7.78182C6.99636 16 6.25455 15.7133 5.70909 15.2067L0 9.88667C0 9.88667 0.916364 9.06667 0.945455 9.05333C1.10545 8.92667 1.30182 8.86 1.52 8.86C1.68 8.86 1.82545 8.9 1.95636 8.96667C1.98545 8.97333 5.09091 10.6067 5.09091 10.6067V2.66667C5.09091 2.11333 5.57818 1.66667 6.18182 1.66667C6.78545 1.66667 7.27273 2.11333 7.27273 2.66667V7.33333H8V1C8 0.446667 8.48727 0 9.09091 0C9.69455 0 10.1818 0.446667 10.1818 1V7.33333H10.9091V1.66667C10.9091 1.11333 11.3964 0.666667 12 0.666667C12.6036 0.666667 13.0909 1.11333 13.0909 1.66667V7.33333H13.8182V3.66667C13.8182 3.11333 14.3055 2.66667 14.9091 2.66667C15.5127 2.66667 16 3.11333 16 3.66667Z' fill='white'/%3E%3C/svg%3E");
29
+ }
30
+
31
+ &[data-item-type="link"]:before {
32
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1273)'%3E%3Cpath d='M16 22H32V26H16V22ZM40.2 24H44C44 18.48 39.52 14 34 14H26V17.8H34C37.42 17.8 40.2 20.58 40.2 24ZM7.8 24C7.8 20.58 10.58 17.8 14 17.8H22V14H14C8.48 14 4 18.48 4 24C4 29.52 8.48 34 14 34H22V30.2H14C10.58 30.2 7.8 27.42 7.8 24ZM38 24H34V30H28V34H34V40H38V34H44V30H38V24Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1273'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
33
+ }
34
+
35
+ &[data-item-type="button"]:before {
36
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1276)'%3E%3Cpath d='M44 18V30C44 32.2 42.2 34 40 34H38V30H40V18H8V30H20V34H8C5.8 34 4 32.2 4 30V18C4 15.8 5.8 14 8 14H40C42.2 14 44 15.8 44 18ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1276'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
20
37
  }
21
38
  }
22
39
  }
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Katalyst
4
+ module Navigation
5
+ module HasNavigation
6
+ extend ActiveSupport::Concern
7
+
8
+ module NavigationHelper
9
+ def navigation_menu_for(slug)
10
+ @navigation_menus[slug.to_s]
11
+ end
12
+ end
13
+
14
+ included do
15
+ helper Katalyst::Navigation::FrontendHelper
16
+ helper NavigationHelper
17
+
18
+ before_action :set_navigation_menus
19
+ end
20
+
21
+ protected
22
+
23
+ def set_navigation_menus
24
+ @navigation_menus = Katalyst::Navigation::Menu.includes(:published_version).index_by(&:slug)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -62,7 +62,7 @@ module Katalyst
62
62
 
63
63
  menu.destroy!
64
64
 
65
- redirect_to action: :index
65
+ redirect_to action: :index, status: :see_other
66
66
  end
67
67
 
68
68
  private
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
 
10
10
  <div class="url">
11
- <%= link_to item.url || "", item.url || "" %>
11
+ <%= link_to item.url || "", item.url || "", data: { turbo: false } %>
12
12
  </div>
13
13
 
14
14
  <%= builder.item_actions %>
@@ -11,5 +11,10 @@
11
11
  <%= form.text_field :slug %>
12
12
  </div>
13
13
 
14
- <%= form.submit :save %>
14
+ <div class="button-row">
15
+ <%= form.submit :save %>
16
+ <%= link_to "Delete", url_for(action: :show),
17
+ class: "button button-secondary",
18
+ data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %>
19
+ </div>
15
20
  <% end %>
@@ -11,7 +11,4 @@
11
11
  <%= link_to cell.value, menu %>
12
12
  <% end %>
13
13
  <%= row.cell :slug %>
14
- <%= row.cell :actions do |cell| %>
15
- <%= button_to "Delete", menu, method: :delete, class: "button button--text" %>
16
- <% end %>
17
14
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Navigation
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,7 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - CHANGELOG.md
21
20
  - LICENSE.txt
22
21
  - README.md
23
22
  - app/assets/config/katalyst-navigation.js
@@ -35,6 +34,7 @@ files:
35
34
  - app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss
36
35
  - app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss
37
36
  - app/assets/stylesheets/katalyst/navigation/editor/_status-bar.scss
37
+ - app/controllers/concerns/katalyst/navigation/has_navigation.rb
38
38
  - app/controllers/katalyst/navigation/base_controller.rb
39
39
  - app/controllers/katalyst/navigation/items_controller.rb
40
40
  - app/controllers/katalyst/navigation/menus_controller.rb
@@ -83,9 +83,6 @@ homepage: https://github.com/katalyst/navigation
83
83
  licenses:
84
84
  - MIT
85
85
  metadata:
86
- homepage_uri: https://github.com/katalyst/navigation
87
- source_code_uri: https://github.com/katalyst/navigation
88
- changelog_uri: https://github.com/katalyst/navigation/blob/main/CHANGELOG.md
89
86
  rubygems_mfa_required: 'true'
90
87
  post_install_message:
91
88
  rdoc_options: []
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [1.0.0] - 2022-09-05
4
-
5
- - Initial release