mtl 1.1.4 → 1.1.5
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 +4 -4
- data/app/assets/stylesheets/mtl/all.scss +1 -0
- data/app/assets/stylesheets/mtl/extend/_forms.scss +7 -0
- data/app/assets/stylesheets/mtl/extend/_navbar.scss +3 -0
- data/app/views/mtl/header.html.erb +2 -2
- data/lib/generators/mtl/templates/simple_form.rb +2 -19
- data/lib/mtl/rails/navbar_presenter.rb +7 -7
- data/lib/mtl/rails/view_helpers.rb +6 -9
- data/lib/mtl/simple_form/switch_input.rb +29 -0
- data/lib/mtl/version.rb +1 -1
- data/spec/mtl/rails/navbar_presenter_spec.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9187be6ff3dc7c7f070adf654ab5c397f121e4c
|
4
|
+
data.tar.gz: 2eb50dbbe841ba2fe5b87b79afb4273db0c6b7d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7139d663f45aeede5fbc95b4907dfacfdbca58fc9fc2abfd681a26d1adb2fc73ba2288b9ceecd79ea741f218eef033e7f485aa72f1b09e6b2baa174e4cc03452
|
7
|
+
data.tar.gz: f4ff6660f74eb92fabce331534e4b4f5418bbe976e065c4fd997c4a994f67919ab882b2e8627cee14314ffbd41568354912a7330b7f4721a76a5cab7a79f35f5
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<header class="<%= mtl_class %>">
|
2
|
-
<%=
|
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
|
-
<%=
|
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(@
|
16
|
+
render_extended(@extended_block, @extended_options)].compact),
|
17
17
|
class: @extended_block ? 'nav-extended' : nil
|
18
18
|
|
19
|
-
|
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 = {}
|
36
|
-
return unless
|
37
|
-
view.content_tag(:div,
|
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
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
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
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
|
+
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-
|
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
|