mtl 1.1.4 → 1.1.5

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
  SHA1:
3
- metadata.gz: 44b92a6793c60cb944ae9c28cd6f9150822fd50a
4
- data.tar.gz: f3835d1ab87ff6bfa760afbb412968199d8fab2c
3
+ metadata.gz: b9187be6ff3dc7c7f070adf654ab5c397f121e4c
4
+ data.tar.gz: 2eb50dbbe841ba2fe5b87b79afb4273db0c6b7d6
5
5
  SHA512:
6
- metadata.gz: 64d0e8d7462b7047f29674d0cdfd5983e7a86e7191d1cd2f26bd2f212721b14b5391f5b23617a90e0e123590ce0273d6285dda6e8a086c8501a2f54bd210b403
7
- data.tar.gz: 8525dc5946545f84f4dd750b24f5b59b8397acbeefe3ebd71f8f95a085224d1d42778690387bcaf130f0618c1091cceb4b1b195a8bd2b35c85668270e705865a
6
+ metadata.gz: 7139d663f45aeede5fbc95b4907dfacfdbca58fc9fc2abfd681a26d1adb2fc73ba2288b9ceecd79ea741f218eef033e7f485aa72f1b09e6b2baa174e4cc03452
7
+ data.tar.gz: f4ff6660f74eb92fabce331534e4b4f5418bbe976e065c4fd997c4a994f67919ab882b2e8627cee14314ffbd41568354912a7330b7f4721a76a5cab7a79f35f5
@@ -13,6 +13,7 @@
13
13
  @import './extend/grid';
14
14
 
15
15
  @import 'materialize/navbar';
16
+ @import './extend/navbar';
16
17
 
17
18
  // @import 'materialize/roboto';
18
19
  @import './extend/roboto-rails'; // using asset_url's
@@ -98,3 +98,10 @@
98
98
  }
99
99
  }
100
100
  }
101
+
102
+ .input-field.switch {
103
+ label {
104
+ position: static;
105
+ }
106
+ }
107
+
@@ -0,0 +1,3 @@
1
+ .navbar-fixed.navbar-fixed-extended {
2
+ height: 112px;
3
+ }
@@ -1,5 +1,5 @@
1
1
  <header class="<%= mtl_class %>">
2
- <%= mtl_navbar fixed: mtl_fixed do |nav| %>
2
+ <%= mtl_nav.render fixed: mtl_fixed do |nav| %>
3
3
  <%- if mtl_back %>
4
4
  <%= link_to mtl_back, class: 'mtl-layout-default-header-back left' do %>
5
5
  <i class="material-icons">arrow_back</i>
@@ -17,7 +17,7 @@
17
17
  <%- end %>
18
18
 
19
19
  <%- if mtl_content %>
20
- <%= capture(nav, &mtl_content) %>
20
+ <%= mtl_content %>
21
21
  <%- end %>
22
22
  <%- end %>
23
23
  </header>
@@ -1,4 +1,5 @@
1
1
  require 'mtl/simple_form/suffix'
2
+ require 'mtl/simple_form/switch_input'
2
3
 
3
4
  # Copyright 2016 Patrick Lindsay
4
5
  # https://github.com/patricklindsay/simple_form-materialize
@@ -24,22 +25,6 @@ require 'mtl/simple_form/suffix'
24
25
  #
25
26
  # Use this setup block to configure all options available in SimpleForm.
26
27
  SimpleForm.setup do |config|
27
- # Wrappers are used by the form builder to generate a
28
- # complete input. You can remove any component from the
29
- # wrapper, change the order or even add your own to the
30
- # stack. The options given below are used to wrap the
31
- # whole input.
32
- config.wrappers :material_checkbox,
33
- hint_class: :field_with_hint, error_class: 'has-error' do |b|
34
- b.use :input
35
- b.use :label
36
-
37
- b.use :hint, wrap_with: { tag: :span, class: 'help-block' }
38
- b.use :error, wrap_with: { tag: :span, class: 'error-block' }
39
-
40
- b.use :html5
41
- end
42
-
43
28
  config.wrappers :disabled_form do |b|
44
29
  b.use :label
45
30
  b.use :input, disabled: true, readonly: true
@@ -173,9 +158,7 @@ SimpleForm.setup do |config|
173
158
 
174
159
  # Custom wrappers for input types. This should be a hash containing an input
175
160
  # type as key and the wrapper that will be used for all inputs with specified type.
176
- config.wrapper_mappings = {
177
- switch: :material_checkbox
178
- }
161
+ # config.wrapper_mappings = {}
179
162
 
180
163
  # Namespaces where SimpleForm should look for custom input classes that
181
164
  # override default inputs.
@@ -13,16 +13,16 @@ module Mtl
13
13
 
14
14
  def render(options = {}, &block)
15
15
  nav = view.content_tag :nav, view.safe_join([render_main(options, &block),
16
- render_extended(@extended_options, &@extended_block)].compact),
16
+ render_extended(@extended_block, @extended_options)].compact),
17
17
  class: @extended_block ? 'nav-extended' : nil
18
18
 
19
- nav = view.content_tag :div, nav, class: 'navbar-fixed' if options[:fixed]
20
- nav
19
+ return nav unless options[:fixed]
20
+ view.content_tag :div, nav, class: ['navbar-fixed', @extended_block ? 'navbar-fixed-extended' : nil]
21
21
  end
22
22
 
23
23
  def extended(options = {}, &block)
24
24
  @extended_options = options
25
- @extended_block = block
25
+ @extended_block = view.capture(&block)
26
26
  nil
27
27
  end
28
28
 
@@ -32,9 +32,9 @@ module Mtl
32
32
  view.content_tag(:div, view.capture(self, &block), class: [options[:class], 'nav-wrapper'].flatten.compact)
33
33
  end
34
34
 
35
- def render_extended(options = {}, &block)
36
- return unless block_given?
37
- view.content_tag(:div, view.capture(&block), class: [options[:class], 'nav-content'].flatten.compact)
35
+ def render_extended(content, options = {})
36
+ return unless content.presence
37
+ view.content_tag(:div, content, class: [options[:class], 'nav-content'].flatten.compact)
38
38
  end
39
39
  end
40
40
  end
@@ -362,15 +362,12 @@ module Mtl
362
362
  # @return [String] HTML safe string
363
363
  def mtl_header(title = translate('.title', default: 'Menu'), **options, &block)
364
364
  mtl_class = ['mtl-layout-default-header', options[:class]].compact.flatten.join(' ')
365
-
366
- render file: 'mtl/header', locals: {
367
- mtl_content: block,
368
- mtl_title: title.presence,
369
- mtl_back: options.fetch(:back, false),
370
- mtl_menu: options.fetch(:menu, 'nav-menu'),
371
- mtl_fixed: options.fetch(:fixed, false),
372
- mtl_class: mtl_class
373
- }
365
+ mtl_nav = NavbarPresenter.new(self)
366
+ mtl_content = block_given? ? capture(mtl_nav, &block) : nil
367
+ render file: 'mtl/header', locals: { mtl_title: title.presence, mtl_back: options.fetch(:back, false),
368
+ mtl_menu: options.fetch(:menu, 'nav-menu'),
369
+ mtl_fixed: options.fetch(:fixed, false), mtl_class: mtl_class,
370
+ mtl_nav: mtl_nav, mtl_content: mtl_content }
374
371
  end
375
372
 
376
373
  # Renders an avatar link, for the given url with the name's initials
@@ -0,0 +1,29 @@
1
+ require 'simple_form'
2
+
3
+ # :nodoc:
4
+ module SimpleForm
5
+ # :nodoc:
6
+ module Inputs
7
+ # :nodoc:
8
+ class SwitchInput < ::SimpleForm::Inputs::BooleanInput
9
+ def input(_wrapper_options = nil)
10
+ template.content_tag(:div, class: :switch) do
11
+ build_hidden_field_for_checkbox +
12
+ template.label_tag(nil) do
13
+ build_check_box_without_hidden_field(input_html_options) +
14
+ template.content_tag(:span, nil, class: :lever) +
15
+ label_text
16
+ end
17
+ end
18
+ end
19
+
20
+ def label_input(wrapper_options = nil)
21
+ input(wrapper_options)
22
+ end
23
+
24
+ def label(_wrapper_options = nil)
25
+ ''
26
+ end
27
+ end
28
+ end
29
+ end
data/lib/mtl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mtl
2
- VERSION = '1.1.4'.freeze
2
+ VERSION = '1.1.5'.freeze
3
3
  MATERIALIZE_VERSION = '0.98.0'.freeze
4
4
  ICONS_VERSION = '2.2.3'.freeze
5
5
  LODASH_VERSION = '4.14.1'.freeze
@@ -90,7 +90,7 @@ RSpec.describe Mtl::Rails::NavbarPresenter, dom: true do
90
90
 
91
91
  'Hello'
92
92
  end).to match_dom <<-HTML
93
- <div class="navbar-fixed">
93
+ <div class="navbar-fixed navbar-fixed-extended">
94
94
  <nav class="nav-extended">
95
95
  <div class="nav-wrapper">
96
96
  Hello
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Plüss
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-04-03 00:00:00.000000000 Z
13
+ date: 2017-04-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -155,6 +155,7 @@ files:
155
155
  - app/assets/stylesheets/mtl/extend/_grid.scss
156
156
  - app/assets/stylesheets/mtl/extend/_material-icons.scss
157
157
  - app/assets/stylesheets/mtl/extend/_mixins.scss
158
+ - app/assets/stylesheets/mtl/extend/_navbar.scss
158
159
  - app/assets/stylesheets/mtl/extend/_roboto-rails.scss
159
160
  - app/assets/stylesheets/mtl/extend/_side-nav.scss
160
161
  - app/assets/stylesheets/mtl/extend/_toc.scss
@@ -174,6 +175,7 @@ files:
174
175
  - lib/mtl/rails/navbar_presenter.rb
175
176
  - lib/mtl/rails/view_helpers.rb
176
177
  - lib/mtl/simple_form/suffix.rb
178
+ - lib/mtl/simple_form/switch_input.rb
177
179
  - lib/mtl/version.rb
178
180
  - mtl.gemspec
179
181
  - package.json