myg 2.4.0 → 2.5.0

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
  SHA256:
3
- metadata.gz: dd0adc23c9a2221fbe2467b95aba935a0a5c07c3b04d9dc65c2c78704b6fa537
4
- data.tar.gz: 896d97d0379fec8ca42417ce11d1cc2f8610f6231e38655495ccfec749e6bd19
3
+ metadata.gz: 8c29952c97ba88bea732f66414be85f5444e5754bf338c28cd2ecdb7a706eabb
4
+ data.tar.gz: 1df6280cae3bf39d6746452c3fbedb897aee28c8bdb5d86161273960c50ac689
5
5
  SHA512:
6
- metadata.gz: 55cd958b1a15530ff4f0b997ab88a741ae65aea70ee8823a6aa8559c2f2ee5c5a0f4cd1f007f6f3f406619564a8844be7ff50c207e64aec080dc93833d927ae9
7
- data.tar.gz: 2e9e493688f80677874a763c7f730b971dd8fe2f30e021317ea2c3d97beb07ecfac7c976ee5ef77bd47a40abc932b4bed1909fe4dc1aadeba2dcbc644bbeeba3
6
+ metadata.gz: 8b8d1112614a403feb425d508aa5021932a813501f03fe04907ee1aa5108d0eca188fecd15a235a351fab59bcacd95e1a8eb343120ef202d53a4cf7a1a4c5ea1
7
+ data.tar.gz: c3b91b66ee1b6c44d3d5b1f75db29ca767c7f5ca286da4a0713d9cfbbfbb18ac2da960d023db64f0755a0050a5b4b9e150aba63b89dc6f40824c74b2279e0bab
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 2.5.0 - 2018/03/01
8
+
9
+ * features
10
+ * added `tabs` generator
11
+ * added `tabs` component
12
+
7
13
  ### 2.4.0 - 2018/02/25
8
14
 
9
15
  * features
data/README.md CHANGED
@@ -82,6 +82,8 @@ These are the components currently supported by Myg on Rails:
82
82
  * [`radio`](components/myg/radio.md)
83
83
  * [`slider`](components/myg/slider.md)
84
84
  * [`switch`](components/myg/switch.md)
85
+ * [`tabs`](components/myg/tabs.md)
86
+ * [`toast`](components/myg/toast.md)
85
87
  * [`toolbar`](components/myg/toolbar.md)
86
88
 
87
89
  You feel a component is missing? Create an issue to make us aware, or implement it yourself. Pull requests are welcome.
@@ -1,5 +1,6 @@
1
1
  <% class_name = options.delete :class_name %>
2
2
  <% attribute = options.delete :attribute %>
3
+ <% values = options.delete(:values) || [0, 1] %>
3
4
  <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
4
5
  <% id = class_name ? "#{class_name.to_s.downcase}_#{attribute}" : "#{attribute}" %>
5
6
  <% wrapper_html = {
@@ -9,10 +10,12 @@
9
10
  type: 'checkbox',
10
11
  class: ['mdc-switch__native-control', options.dig(:input_html, :class)].join(' '),
11
12
  name: name,
12
- id: id
13
+ id: id,
14
+ value: values.last
13
15
  } %>
14
16
 
15
17
  <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
18
+ <input value="<%= values.first %>" type="hidden" name="<%= name %>" />
16
19
  <%= tag 'input', (options[:input_html] || {}).merge(input_html) %>
17
20
  <div class="mdc-switch__background">
18
21
  <div class="mdc-switch__knob"></div>
@@ -0,0 +1,45 @@
1
+ <% nav_html = {
2
+ class: ['myg-tabs mdc-tab-bar', options.dig(:nav_html, :class)].join(' '),
3
+ update: {
4
+ history: options[:update_history]
5
+ }
6
+ } %>
7
+ <% wrapper_html = {
8
+ class: ['myg-tabs--panels', options.dig(:wrapper_html, :class)].join(' ')
9
+ } %>
10
+
11
+ <%= content_tag 'nav', (options[:nav_html] || {}).merge(nav_html) do %>
12
+ <% options[:tabs]&.each do |tab| %>
13
+ <% tab_html = {
14
+ class: ['mdc-tab', options.dig(:tab_html, :class), ('mdc-tab--active' if tab[:active])].join(' '),
15
+ aria: {
16
+ controls: tab[:id]
17
+ },
18
+ role: 'tab'
19
+ } %>
20
+ <%= link_to tab[:name], tab[:href] || "##{tab[:id]}", (options[:tab_html] || {}).merge(tab_html) %>
21
+ <% end %>
22
+ <span class="mdc-tab-bar__indicator"></span>
23
+ <% end %>
24
+ <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
25
+ <% if options[:async] %>
26
+ <div class="myg-tabs--loader">
27
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"><g class="nc-loop_bars-rotate-24" transform="rotate(270 12 12)"> <rect x="11" fill="#444444" width="2" height="6"></rect> <rect x="17.3639603" y="2.636039" transform="matrix(0.7071068 0.7071068 -0.7071068 0.7071068 9.3639612 -11.3345242)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="18" y="11" fill="#444444" width="6" height="2" style="opacity: 0.4;"></rect> <rect x="17.3639603" y="15.3639612" transform="matrix(-0.7071068 0.7071068 -0.7071068 -0.7071068 44.3345222 18.3639603)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="11" y="18" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="4.6360388" y="15.3639612" transform="matrix(-0.7071068 -0.7071068 0.7071068 -0.7071068 -3.363961 35.3345222)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="0" y="11" fill="#444444" width="6" height="2" style="opacity: 0.5;"></rect> <rect x="4.6360388" y="2.636039" transform="matrix(0.7071068 -0.7071068 0.7071068 0.7071068 -2.3345237 5.6360388)" fill="#444444" width="2" height="6" style="opacity: 0.8;"></rect> </g> <script>!function(){function t(t){this.element=t,this.animationId,this.start=null,this.init()}if(!window.requestAnimationFrame){var i=null;window.requestAnimationFrame=function(t,n){var e=(new Date).getTime();i||(i=e);var a=Math.max(0,16-(e-i)),o=window.setTimeout(function(){t(e+a)},a);return i=e+a,o}}t.prototype.init=function(){var t=this;this.animationId=window.requestAnimationFrame(t.triggerAnimation.bind(t))},t.prototype.reset=function(){var t=this;window.cancelAnimationFrame(t.animationId)},t.prototype.triggerAnimation=function(t){var i=this;this.start||(this.start=t);var n=t-this.start;800&gt;n||(this.start=this.start+800),this.element.setAttribute("transform","rotate("+parseInt(Math.min(n/100,8))%8*45+" 12 12)");if(document.documentElement.contains(this.element))window.requestAnimationFrame(i.triggerAnimation.bind(i))};var n=document.getElementsByClassName("nc-loop_bars-rotate-24"),e=[];if(n)for(var a=0;n.length&gt;a;a++)!function(i){e.push(new t(n[i]))}(a);document.addEventListener("visibilitychange",function(){"hidden"==document.visibilityState?e.forEach(function(t){t.reset()}):e.forEach(function(t){t.init()})})}();</script></g></svg>
28
+ </div>
29
+ <div class="myg-tabs--panel" id="myg-tabs--panel-success" role="tabpanel" aria-hidden="true"></div>
30
+ <div class="myg-tabs--panel" id="myg-tabs--panel-error" role="tabpanel" aria-hidden="true"></div>
31
+ <% end %>
32
+ <% options[:tabs]&.each do |tab| %>
33
+ <% panel_html = {
34
+ class: ['myg-tabs--panel', options.dig(:panel_html, :class), ('myg-tabs--shown' if tab[:active])].join(' '),
35
+ id: tab[:id],
36
+ role: 'tabpanel',
37
+ aria: {
38
+ hidden: (tab[:active] ? false : true)
39
+ }
40
+ } %>
41
+ <%= content_tag 'div', (options[:panel_html] || {}).merge(panel_html) do %>
42
+ <%= tab[:content] || render(partial: tab[:partial], locals: tab[:partial_locales]) %>
43
+ <% end %>
44
+ <% end %>
45
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  <% html = {
2
- class: ['myg-toast mdc-snackbar', options[:class]].join(' '),
2
+ class: ['myg-toast mdc-snackbar mdc-snackbar--align-start', options[:class]].join(' '),
3
3
  aria: {
4
4
  live: 'assertive',
5
5
  atomic: true,
@@ -0,0 +1,23 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class Myg::TabsGenerator < Rails::Generators::Base
5
+
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.join File.dirname(__FILE__), '../templates/tabs'
9
+ desc 'Generate a Myg tabs template'
10
+
11
+ class_option :controller, desc: 'Tabs controller', type: :string, aliases: '-c'
12
+ class_option :method_names, desc: 'Tab method names', type: :array, aliases: '-m'
13
+
14
+ def create_templates
15
+ template '_tabs.html.erb', "app/views/#{options[:controller]}/_tabs.html.erb"
16
+ options[:method_names]&.each do |name|
17
+ @name = name
18
+ template 'tab.html.erb', "app/views/#{options[:controller]}/_#{name}.html.erb"
19
+ template '_tab.html.erb', "app/views/#{options[:controller]}/#{name}.html.erb"
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1 @@
1
+ <h1><%= @name.titleize %></h1>
@@ -0,0 +1,3 @@
1
+ <h1>Title</h1>
2
+
3
+ <%%= component 'myg/tabs', update_history: true, tabs: <%= options[:method_names]&.map! { |t| { name: t.titleize, id: t, partial: t } } %> %>
@@ -0,0 +1 @@
1
+ <%%= render 'tabs' %>
data/lib/myg/railtie.rb CHANGED
@@ -14,6 +14,7 @@ module Myg
14
14
  config.define_component 'myg/radio'
15
15
  config.define_component 'myg/slider', discrete: false, disabled: false, value: 0, min: 0, max: 50, label: 'Select value'
16
16
  config.define_component 'myg/switch'
17
+ config.define_component 'myg/tabs', async: false, update_history: false
17
18
  config.define_component 'myg/toast'
18
19
  config.define_component 'myg/toolbar'
19
20
  end
data/lib/myg/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Myg
2
2
 
3
- VERSION = '2.4.0'
3
+ VERSION = '2.5.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myg
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-25 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -114,9 +114,11 @@ files:
114
114
  - app/views/mozaic/myg/_radio.html.erb
115
115
  - app/views/mozaic/myg/_slider.html.erb
116
116
  - app/views/mozaic/myg/_switch.html.erb
117
+ - app/views/mozaic/myg/_tabs.html.erb
117
118
  - app/views/mozaic/myg/_toast.html.erb
118
119
  - app/views/mozaic/myg/_toolbar.html.erb
119
120
  - lib/generators/myg/install_generator.rb
121
+ - lib/generators/myg/tabs_generator.rb
120
122
  - lib/generators/myg/theme_generator.rb
121
123
  - lib/generators/templates/install/initializer.rb
122
124
  - lib/generators/templates/install/javascripts/action-button.js
@@ -162,6 +164,9 @@ files:
162
164
  - lib/generators/templates/install/stylesheets/variables/_spacing.scss
163
165
  - lib/generators/templates/install/stylesheets/variables/_text.scss
164
166
  - lib/generators/templates/install/stylesheets/variables/_theme.scss
167
+ - lib/generators/templates/tabs/_tab.html.erb
168
+ - lib/generators/templates/tabs/_tabs.html.erb
169
+ - lib/generators/templates/tabs/tab.html.erb
165
170
  - lib/generators/templates/theme/stylesheets/_theme.scss.erb
166
171
  - lib/myg.rb
167
172
  - lib/myg/configuration.rb