smart_navigation 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f1a3527ad5902208d2e5c0e2cd50812011c1f1d
4
- data.tar.gz: d37bc43de96cf264600d03ce06ab94122eea0966
3
+ metadata.gz: 996a81e56bb9faf73440df7a823e7b03835dcf72
4
+ data.tar.gz: a1e1117851effcccef0856527a46d2179c289012
5
5
  SHA512:
6
- metadata.gz: 53129e06fb2130c77f0ebe85d334de74a593b42b6c701eda7562e8148e3b4ff9e06d345186337b58fb7ff71885e4b741353baaa9dfff0003af17d16e3dbc0bd1
7
- data.tar.gz: de9fd18096ba9895a97cf5493ea1bc5329044429578e17905efbd09106480816c8b8f9460d99215385eff5ec4b06cbc8d6be2463bcd91aed0d38bfae6dbbc697
6
+ metadata.gz: d4ca51e4c127ae1da7fe4255982da51defb8132293dacda0183c51bf4f68d6ca6fa5483fd06b02196a6cf35a7ceb4354124017797fe99e4832a1f7f007b749f2
7
+ data.tar.gz: cd5fc22b7391a718974b7b80e291d278bcfc7ced41015c74d3dd3bb1165b2211f2c0b670e7a8ffb2c473274e067522b67d73536bfe78ed8acf88170ca24cfc06
data/README.md CHANGED
@@ -76,6 +76,7 @@ There are a number of options you can use to customize the navigation. The defau
76
76
  options = {
77
77
  menu_class: 'menu',
78
78
  menu_html: {},
79
+ menu_icons: true,
79
80
  separator_class: 'separator',
80
81
  submenu_parent_class: 'has-submenu',
81
82
  submenu_class: 'submenu',
@@ -84,7 +85,9 @@ options = {
84
85
  submenu_icons: false,
85
86
  submenu_toggle: nil,
86
87
  icon_prefix: 'icon icon-',
87
- icon_position: 'left'
88
+ icon_default: 'missing',
89
+ icon_position: 'left',
90
+ keep_defaults: true
88
91
  }
89
92
 
90
93
  smart_navigation_for(@items, options)
@@ -104,4 +107,4 @@ The gem is available as open source under the terms of the [MIT License](http://
104
107
 
105
108
  ## Code of Conduct
106
109
 
107
- Everyone interacting in the ActiveContent project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hardpixel/smart-navigation/blob/master/CODE_OF_CONDUCT.md).
110
+ Everyone interacting in the SmartNavigation project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hardpixel/smart-navigation/blob/master/CODE_OF_CONDUCT.md).
@@ -4,12 +4,12 @@ module SmartNavigation
4
4
  def initialize(view_context, items, options={})
5
5
  @context = view_context
6
6
  @items = sort_items items
7
- @options = default_options.merge(options)
7
+ @options = merge_options options
8
8
  end
9
9
 
10
10
  # Render menu
11
11
  def render
12
- menu_tag @items.map { |k, v| item_tag(v, true) }.join
12
+ menu_tag @items.map { |k, v| item_tag(v, @options[:menu_icons]) }.join
13
13
  end
14
14
 
15
15
  private
@@ -19,6 +19,7 @@ module SmartNavigation
19
19
  {
20
20
  menu_class: 'menu',
21
21
  menu_html: {},
22
+ menu_icons: true,
22
23
  separator_class: 'separator',
23
24
  submenu_parent_class: 'has-submenu',
24
25
  submenu_class: 'submenu',
@@ -27,10 +28,21 @@ module SmartNavigation
27
28
  submenu_icons: false,
28
29
  submenu_toggle: nil,
29
30
  icon_prefix: 'icon icon-',
30
- icon_position: 'left'
31
+ icon_default: 'missing',
32
+ icon_position: 'left',
33
+ keep_defaults: true
31
34
  }
32
35
  end
33
36
 
37
+ # Get merged options
38
+ def merge_options(options)
39
+ if @options[:keep_defaults].present?
40
+ default_options.merge(options)
41
+ else
42
+ options
43
+ end
44
+ end
45
+
34
46
  # Sort items by order
35
47
  def sort_items(items)
36
48
  items.sort_by { |_k, v| v[:order] }.to_h
@@ -77,7 +89,7 @@ module SmartNavigation
77
89
 
78
90
  # Create menu icon
79
91
  def icon_tag(name, label=nil)
80
- icon = tag :i, nil, class: "#{@options[:icon_prefix]}#{name}"
92
+ icon = tag :i, nil, class: "#{@options[:icon_prefix]}#{name || @options[:icon_default]}"
81
93
 
82
94
  if @options[:icon_position] == 'left'
83
95
  "#{icon}#{label}".html_safe
@@ -1,3 +1,3 @@
1
1
  module SmartNavigation
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-25 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview