fleetio_spark 0.2.31 → 0.2.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spark/_icons.js +1 -1
  3. data/app/assets/javascripts/spark/code.js +2 -7
  4. data/app/assets/javascripts/spark/components/app/sidebar/_fix.js +3 -4
  5. data/app/assets/javascripts/spark/components/nav/_link-state.js +36 -0
  6. data/app/assets/javascripts/spark/components/nav/_tabs.js +23 -15
  7. data/app/assets/javascripts/spark/components/nav/_toggle.js +33 -7
  8. data/app/assets/javascripts/spark/components/nav/_tree.js +28 -4
  9. data/app/assets/javascripts/spark/form/_set-text.js +40 -0
  10. data/app/assets/javascripts/spark/spark.js +10 -7
  11. data/app/assets/stylesheets/spark/_icons.scss +1 -1
  12. data/app/assets/stylesheets/spark/components/_index.scss +8 -0
  13. data/app/assets/stylesheets/spark/components/app/_banner.scss +1 -1
  14. data/app/assets/stylesheets/spark/components/app/_header.scss +3 -3
  15. data/app/assets/stylesheets/spark/components/app/_layout.scss +14 -4
  16. data/app/assets/stylesheets/spark/components/app/_sidebar.scss +2 -2
  17. data/app/assets/stylesheets/spark/components/app/sidebar/_toggle.scss +3 -3
  18. data/app/assets/stylesheets/spark/components/form/_switch.scss +119 -0
  19. data/app/assets/{javascripts/spark/components/ui/_checklist_trigger.js → stylesheets/spark/components/layout/_base.scss} +0 -0
  20. data/app/assets/stylesheets/spark/components/layout/_header.scss +55 -0
  21. data/app/{components/spark/nav/breadcrumbs/_breadcrumbs.html.erb → assets/stylesheets/spark/components/layout/_page.scss} +0 -0
  22. data/app/assets/stylesheets/spark/components/nav/_item.scss +6 -2
  23. data/app/assets/stylesheets/spark/components/nav/_pills.scss +5 -1
  24. data/app/assets/stylesheets/spark/components/nav/_sidebar.scss +100 -0
  25. data/app/assets/stylesheets/spark/components/nav/_tabs.scss +46 -61
  26. data/app/assets/stylesheets/spark/components/nav/_toggle.scss +69 -33
  27. data/app/assets/stylesheets/spark/components/nav/tree/_group.scss +0 -1
  28. data/app/assets/stylesheets/spark/components/page/_header.scss +9 -0
  29. data/app/assets/stylesheets/spark/components/page/_main.scss +62 -0
  30. data/app/assets/stylesheets/spark/components/ui/_button.scss +0 -0
  31. data/app/assets/stylesheets/spark/components/ui/_card.scss +20 -0
  32. data/app/assets/stylesheets/spark/components/ui/_header.scss +56 -0
  33. data/app/assets/stylesheets/spark/components_old/header/_search.scss +1 -2
  34. data/app/assets/stylesheets/spark/core/_text.scss +1 -0
  35. data/app/assets/stylesheets/spark/core/_vars.scss +1 -0
  36. data/app/assets/stylesheets/spark/form/_check-switch.scss +0 -6
  37. data/app/assets/svgs/spark/comment.svg +3 -0
  38. data/app/assets/svgs/spark/description.svg +3 -0
  39. data/app/assets/svgs/spark/grid.svg +3 -0
  40. data/app/assets/svgs/spark/information-circle.svg +3 -0
  41. data/app/assets/svgs/spark/launch.svg +3 -0
  42. data/app/assets/svgs/spark/photo.svg +3 -0
  43. data/app/components/spark/app/banner_component.rb +12 -13
  44. data/app/components/spark/app/content_component.rb +32 -0
  45. data/app/components/spark/app/header_component.rb +4 -4
  46. data/app/components/spark/app/layout_component.rb +24 -8
  47. data/app/components/spark/app/sidebar/header_component.rb +11 -9
  48. data/app/components/spark/app/sidebar_component.rb +10 -9
  49. data/app/components/spark/display/tooltip_component.rb +13 -0
  50. data/app/components/spark/form/checkbox_component.rb +16 -0
  51. data/app/components/spark/form/input_component.rb +6 -0
  52. data/app/components/spark/form/label_component.rb +12 -0
  53. data/app/components/spark/form/switch_component.rb +29 -0
  54. data/app/components/spark/layout/base_component.rb +2 -0
  55. data/app/components/spark/layout/header_component.rb +26 -0
  56. data/app/components/spark/layout/page_component.rb +31 -0
  57. data/app/components/spark/nav/group_component.rb +4 -0
  58. data/app/components/spark/nav/item_component.rb +7 -7
  59. data/app/components/spark/nav/pills_component.rb +8 -2
  60. data/app/components/spark/nav/sidebar_component.rb +52 -6
  61. data/app/components/spark/nav/tab_panels/panel_component.rb +4 -8
  62. data/app/components/spark/nav/tab_panels/tab_component.rb +3 -3
  63. data/app/components/spark/nav/tab_panels_component.rb +7 -3
  64. data/app/components/spark/nav/tabs_component.rb +19 -5
  65. data/app/components/spark/nav/toggle_component.rb +19 -9
  66. data/app/components/spark/nav/tree/group_component.rb +4 -3
  67. data/app/components/spark/nav/tree_component.rb +16 -2
  68. data/app/components/spark/page/layout_component.rb +32 -0
  69. data/app/components/spark/page/main_component.rb +39 -0
  70. data/app/components/spark/ui/button_component.rb +2 -0
  71. data/app/components/spark/ui/card_component.rb +16 -0
  72. data/app/components/spark/ui/checklist_trigger_component.rb +2 -2
  73. data/app/components/spark/ui/header_component.rb +41 -0
  74. data/app/components/spark/ui/page_layout_component.rb +34 -0
  75. data/app/components/spark/ui/placeholder_component.rb +5 -5
  76. data/app/components/spark/ui/sticky_panel_component.rb +1 -1
  77. data/app/components/spark/ui/toolbar_component.rb +1 -1
  78. data/app/views/layouts/spark/default.html.slim +3 -5
  79. data/lib/fleetio_spark.rb +3 -0
  80. data/lib/fleetio_spark/component.rb +19 -0
  81. data/lib/fleetio_spark/version.rb +1 -1
  82. data/public/code-0.2.32.js +2 -0
  83. data/public/code-0.2.32.js.gz +0 -0
  84. data/public/code-0.2.32.js.map +1 -0
  85. data/public/spark-0.2.32.css +1 -0
  86. data/public/spark-0.2.32.css.gz +0 -0
  87. data/public/spark-0.2.32.js +2 -0
  88. data/public/spark-0.2.32.js.gz +0 -0
  89. data/public/spark-0.2.32.js.map +1 -0
  90. metadata +47 -16
  91. data/public/code-0.2.31.js +0 -2
  92. data/public/code-0.2.31.js.gz +0 -0
  93. data/public/code-0.2.31.js.map +0 -1
  94. data/public/spark-0.2.31.css +0 -1
  95. data/public/spark-0.2.31.css.gz +0 -0
  96. data/public/spark-0.2.31.js +0 -2
  97. data/public/spark-0.2.31.js.gz +0 -0
  98. data/public/spark-0.2.31.js.map +0 -1
@@ -6,7 +6,7 @@ class App::LayoutComponent < SparkComponents::Component
6
6
 
7
7
  def render
8
8
  data_attr scroll: true
9
- content_tag(:div, attrs) do
9
+ content_tag(:div, tag_attrs) do
10
10
  concat header
11
11
  concat nav
12
12
  concat @yield
@@ -15,13 +15,13 @@ class App::LayoutComponent < SparkComponents::Component
15
15
 
16
16
  element :header do
17
17
  def render
18
- content_tag(:div, @yield, class: 'app-content-header') unless @yield.blank?
18
+ content_tag(:div, @yield, class: "app-content-header") unless @yield.blank?
19
19
  end
20
20
  end
21
21
 
22
22
  element :nav do
23
23
  def render
24
- content_tag(:div, @yield, class: 'app-content-nav') unless @yield.blank?
24
+ content_tag(:div, @yield, class: "app-content-nav") unless @yield.blank?
25
25
  end
26
26
  end
27
27
  end
@@ -30,7 +30,7 @@ class App::LayoutComponent < SparkComponents::Component
30
30
  add_class @sidebar ? "with-sidebar" : "without-sidebar"
31
31
  @view.capture do
32
32
  @banner.each { |item| concat(item) } if @banner
33
- concat content_tag(:div, attrs) {
33
+ concat content_tag(:div, tag_attrs) {
34
34
  concat ie_fix
35
35
  concat @sidebar
36
36
  concat content_tag(:div, class: "app-main") {
@@ -38,21 +38,37 @@ class App::LayoutComponent < SparkComponents::Component
38
38
  concat content
39
39
  }
40
40
  }
41
- concat content_tag(:div, content_for(:modals), class: 'app-modals') if @view.content_for?(:modals)
41
+ #concat content_tag(:div, content_for(:modals), class: "app-modals") if @view.content_for?(:modals)
42
+ end
43
+ end
44
+
45
+ def render
46
+ add_class @sidebar ? "with-sidebar" : "without-sidebar"
47
+ @view.capture do
48
+ @banner.each { |item| concat(item) } if @banner
49
+ concat content_tag(:div, tag_attrs) {
50
+ concat ie_fix
51
+ concat @sidebar
52
+ concat content_tag(:div, class: "app-main") {
53
+ concat @header
54
+ concat content
55
+ }
56
+ }
57
+ concat content_tag(:div, content_for(:modals), class: "app-modals") if @view.content_for?(:modals)
42
58
  end
43
59
  end
44
60
 
45
61
  def sidebar(options, &block)
46
- @sidebar = compose('app/sidebar', options, &block)
62
+ @sidebar = compose("app/sidebar", options, &block)
47
63
  end
48
64
 
49
65
  def header(options, &block)
50
- @header = compose('app/header', options, &block)
66
+ @header = compose("app/header", options, &block)
51
67
  end
52
68
 
53
69
  def banner(options, &block)
54
70
  @banner ||= []
55
- @banner.push compose('app/banner', options, &block)
71
+ @banner.push compose("app/banner", options, &block)
56
72
  end
57
73
 
58
74
  def compose(name, options, &block)
@@ -5,16 +5,18 @@ class App::Sidebar::HeaderComponent < SparkComponents::Component
5
5
 
6
6
  def render
7
7
  @view.capture do
8
- concat content_tag(:header, attrs) {
9
- concat content_tag(:a, class: "dropdown-toggle", href: "javascript:void(0)", "data-toggle" => "dropdown") {
10
- concat content_tag(:div, class: "details") {
11
- concat account_tag
12
- concat icon
13
- concat user_tag
8
+ concat content_tag(:header, tag_attrs) {
9
+ if account && contact && avatar
10
+ concat content_tag(:a, class: "dropdown-toggle", href: "javascript:void(0)", "data-toggle" => "dropdown") {
11
+ concat content_tag(:div, class: "details") {
12
+ concat account_tag
13
+ concat icon
14
+ concat user_tag
15
+ }
16
+ concat avatar_tag
14
17
  }
15
- concat avatar_tag
16
- }
17
- concat self
18
+ end
19
+ concat @yield
18
20
  }
19
21
  end
20
22
  end
@@ -1,19 +1,20 @@
1
1
  class App::SidebarComponent < Nav::SidebarComponent
2
2
  aria_attr label: "primary navigation"
3
3
  base_class "app-sidebar"
4
- data_attr scroll: true
4
+ data_attr scroll: true, toggled_by: ".app-sidebar-toggle"
5
5
 
6
6
  element :header, component: "app/sidebar/header"
7
7
 
8
- element :footer do
9
- base_class "app-sidebar-footer"
10
-
11
- def render
12
- content_tag(:div, @yield, attrs)
13
- end
8
+ element :nav, component: "nav/tree" do
9
+ root_attr id: "app-sidebar-nav"
10
+ attribute root_icon_size: "18px"
14
11
  end
15
12
 
16
- element :nav, component: "nav/tree" do
17
- attribute id: "app-sidebar-nav"
13
+ def render
14
+ content_tag(:nav, tag_attrs) do
15
+ concat header
16
+ concat nav
17
+ concat footer_tag unless footer.blank?
18
+ end
18
19
  end
19
20
  end
@@ -0,0 +1,13 @@
1
+ class Display::TooltipComponent < SparkComponents::Component
2
+ base_class "spark-tooltip"
3
+ root_attr :id
4
+ attribute :text
5
+ validates :text, presence: true
6
+
7
+ def render
8
+ content_tag(:div, tag_attrs){
9
+ concat @view.use_svg('information-circle', height: '14')
10
+ concat content_tag(:span, text, class: "tooltip-text")
11
+ }
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ class Form::CheckboxComponent < Form::InputComponent
2
+ root_attr :checked
3
+ data_attr :toggle
4
+
5
+ def render
6
+ component "form/label", text: label do
7
+ concat tag(:input, input_attrs)
8
+ end
9
+ end
10
+
11
+ def input_attrs
12
+ tag_attrs.merge({
13
+ type: "checkbox"
14
+ })
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ class Form::InputComponent < SparkComponents::Component
2
+ root_attr :value, :id, :disabled, :required
3
+ attribute :label
4
+ add_class "spark-input"
5
+
6
+ end
@@ -0,0 +1,12 @@
1
+ class Form::LabelComponent < SparkComponents::Component
2
+ attribute :text
3
+ base_class "label"
4
+
5
+ def render
6
+ content_tag(:label, tag_attrs) do
7
+ concat content_tag(:div, text, class: join_class("text"))
8
+ concat @yield
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ class Form::SwitchComponent < Form::CheckboxComponent
2
+ base_class "spark-switch"
3
+ attribute :size, align: :left
4
+
5
+ validates_choice :size, %i[small medium], required: false
6
+ validates_choice :align, %i[left right]
7
+
8
+ def before_render
9
+ add_class(size) if size
10
+ add_class(join_class("align-#{align}")) if align
11
+ end
12
+
13
+ def render
14
+ content_tag(:div, class: classnames) do
15
+ component("form/label", text: label, class: join_class("label")) do
16
+ concat(tag(:input, input_attrs))
17
+ concat content_tag(:span, class: join_class("panel")) {
18
+ content_tag(:span, nil, class: join_class("tick"))
19
+ }
20
+ end
21
+ end
22
+ end
23
+
24
+ def input_attrs
25
+ super.merge({
26
+ class: join_class("input")
27
+ })
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ class Layout::BaseComponent < SparkComponents::Component
2
+ end
@@ -0,0 +1,26 @@
1
+ class Layout::HeaderComponent < SparkComponents::Component
2
+ base_class "spark-header"
3
+ attribute :title, :badge, :tooltip
4
+ aria_attr :described_by
5
+ element :action, multiple: true
6
+
7
+ def before_render
8
+ aria_attr(described_by: %(tooltip-#{SecureRandom.hex(10)})) if tooltip
9
+ end
10
+
11
+ def render
12
+ content_tag(:header, tag_attrs) {
13
+ concat content_tag(:div, class: join_class("title")) {
14
+ concat if_content_tag(:div, title, join_class: "title-content")
15
+ concat tooltip_tag if tooltip
16
+ concat if_content_tag(:div, badge, join_class: "badge")
17
+ }
18
+ concat if_content_tags(:div, actions, join_class: "action")
19
+ }
20
+ end
21
+
22
+ def tooltip_tag
23
+ component("display/tooltip", text: tooltip, id: aria_attr[:described_by], class: join_class("tooltip"))
24
+ end
25
+ end
26
+
@@ -0,0 +1,31 @@
1
+ class Layout::PageComponent < SparkComponents::Component
2
+ element :nav
3
+ element :title
4
+ element :header
5
+ element :body
6
+ element :footer
7
+ element :main, component: "layout/base"
8
+ element :action, multiple: true
9
+
10
+ def render
11
+ @view.capture do
12
+ if title || nav || header
13
+ concat(component("page/header") { |page_header|
14
+ concat(page_header.nav { nav.yield }) if nav
15
+ concat component("layout/header", title: title) { |ui_header|
16
+ actions.each { |a| ui_header.action { a.yield } }
17
+ }
18
+ concat(page_header.body { header.yield }) if header
19
+ })
20
+ end
21
+ concat(content_tag(:div, main, class: "spark-page-main-wrapper")) if main
22
+ concat(content_tag(:div, body, class: "spark-page-body")) unless body.blank?
23
+ concat(content_tag(:div, footer, class: "spark-page-footer")) unless footer.blank?
24
+ concat content_for(:modal)
25
+ end
26
+ end
27
+
28
+ def modal(&block)
29
+ content_for(:modals, &block)
30
+ end
31
+ end
@@ -24,6 +24,10 @@ class Nav::GroupComponent < SparkComponents::Component
24
24
  items.any?(&:beta?)
25
25
  end
26
26
 
27
+ def active_item
28
+ items.find(&:active?)
29
+ end
30
+
27
31
  def active?
28
32
  items.any?(&:active?)
29
33
  end
@@ -1,17 +1,17 @@
1
1
  class Nav::ItemComponent < SparkComponents::Component
2
- attribute :text, :icon, :detail, :badge, :active, :beta, :new, :href
3
- attribute icon_size: '18px'
4
- tag_attr :role, :id
2
+ attribute :text, :icon, :detail, :badge, :active, :beta, :new
3
+ attribute icon_size: "12px"
4
+ root_attr :href, :role, :id, :tabindex, :target
5
5
  base_class "nav-item"
6
6
 
7
7
  def before_render
8
- tag_attr(href: href || "#")
8
+ #root_attr(href: href || "#")
9
9
  add_class "active" if active?
10
10
  end
11
11
 
12
12
  def render
13
- content_tag(:a, attrs) do
14
- concat @view.use_svg(icon, width: icon_size, class: join_class("icon")) if icon
13
+ content_tag(:a, tag_attrs) do
14
+ concat @view.use_svg(icon, width: icon_size, height: icon_size, class: join_class("icon")) if icon
15
15
  concat content_tag(:span, class: join_class("content")) {
16
16
  concat content_tag(:span, text || self, class: join_class("text"))
17
17
  concat content_tag(:span, label.upcase, class: [join_class("label"), label]) if label
@@ -39,6 +39,6 @@ class Nav::ItemComponent < SparkComponents::Component
39
39
  end
40
40
 
41
41
  def active?
42
- tag_attr[:href] != "#" && @view.current_page?(tag_attr[:href]) || active
42
+ root_attr[:href] != "#" && @view.current_page?(root_attr[:href]) || active
43
43
  end
44
44
  end
@@ -1,15 +1,21 @@
1
1
  class Nav::PillsComponent < SparkComponents::Component
2
2
  base_class "spark-nav-pills"
3
- tag_attr role: "navigation"
3
+ root_attr role: "navigation"
4
+ attribute layout: :flush
4
5
 
5
6
  aria_attr :label
6
7
  validates :label, presence: true
8
+ validates_choice :layout, %i[padded flush]
7
9
 
8
10
  element :item, multiple: true, component: "nav/item"
9
11
 
12
+ def before_render
13
+ add_class %(layout-#{layout})
14
+ end
15
+
10
16
  def render
11
17
  return if items.empty?
12
- content_tag(:nav, attrs) do
18
+ content_tag(:nav, tag_attrs) do
13
19
  content_tag(:div, class: "nav-pills-wrapper") {
14
20
  concat content_tag(:ul, class: "nav-group") {
15
21
  items.each { |item|
@@ -1,16 +1,62 @@
1
1
  class Nav::SidebarComponent < SparkComponents::Component
2
2
  aria_attr :label
3
- base_class "sidebar-nav"
3
+ validates :label, presence: true
4
+
5
+ base_class "spark-nav-sidebar"
4
6
 
5
7
  element :header
6
- element :nav, component: "nav/group"
7
8
  element :footer
9
+ element :nav, component: "nav/group", multiple: true do
10
+ attribute :title
11
+
12
+ def render
13
+ @view.capture do
14
+ concat content_tag(:h4, title, class: parent.join_class("title")) unless title.blank?
15
+ concat super
16
+ end
17
+ end
18
+ end
19
+
20
+ def before_render
21
+ data_attr nav_id: %(sidebar-#{SecureRandom.hex(10)})
22
+ end
8
23
 
9
24
  def render
10
- content_tag(:nav, attrs) do
11
- concat header
12
- concat nav
13
- concat footer
25
+ content_tag(:nav, tag_attrs) do
26
+ concat sidebar_toggle_tag
27
+ concat content_tag(:div, class: join_class("wrapper")) {
28
+ concat header_tag unless header.blank?
29
+ if nav.is_a?(Array)
30
+ navs.each { |nav| concat nav }
31
+ else
32
+ concat nav
33
+ end
34
+ concat footer_tag unless footer.blank?
35
+ }
14
36
  end
15
37
  end
38
+
39
+ private
40
+
41
+ def header_tag
42
+ content_tag(:div, header, class: join_class("header"))
43
+ end
44
+
45
+ def footer_tag
46
+ content_tag(:div, footer, class: join_class("footer"))
47
+ end
48
+
49
+ def sidebar_toggle_tag
50
+ component("nav/toggle", target: %([data-nav-id="#{data_attr[:nav_id]}"]), class: join_class("toggle"), text: sidebar_button_text)
51
+ end
52
+ # Tries to find the text for the active nav item, otherwise shows sidebar label text
53
+ def sidebar_button_text
54
+ # Find any navs which have active items
55
+ active_nav = navs.find { |nav|
56
+ nav.active_item
57
+ }
58
+
59
+ # Use the active item text or the label for the sidebar
60
+ active_nav&.active_item&.text || label
61
+ end
16
62
  end
@@ -4,7 +4,7 @@ class Nav::TabPanels::PanelComponent < SparkComponents::Component
4
4
  element :tab, component: "nav/tab_panels/tab"
5
5
 
6
6
  def after_init
7
- tag_attr id: "panel-#{SecureRandom.hex(8)}", role: "tabpanel"
7
+ root_attr id: "panel-#{SecureRandom.hex(8)}", role: "tabpanel"
8
8
  aria_attr labeledby: tab_id
9
9
  end
10
10
 
@@ -12,23 +12,19 @@ class Nav::TabPanels::PanelComponent < SparkComponents::Component
12
12
  if bool
13
13
  add_class 'active'
14
14
  else
15
- tag_attr(hidden: true)
15
+ root_attr(hidden: true)
16
16
  end
17
17
  end
18
18
 
19
- def id
20
- tag_attr[:id]
21
- end
22
-
23
19
  def tab_id
24
- "tab-for-#{id}"
20
+ "tab-for-#{root_attr[:id]}"
25
21
  end
26
22
 
27
23
  def tab_wrapper_id
28
24
  "wrapper-for-#{tab_id}"
29
25
  end
30
26
 
31
- def new_tab(active=false)
27
+ def new_tab(active: false)
32
28
  tab = Nav::TabPanels::TabComponent.new(@view, text: text, href: href, icon: icon, active: active)
33
29
  tab.parent = self
34
30
  tab.before_render