rails-active-ui 0.3.7 → 0.3.8

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: dc0cc8da3df26f99e7a8cc99484217887250d5012cf7dabb3c226ce44a0c0dfa
4
- data.tar.gz: fe3478bbc49e83fd764b9731d45938d3a211106c80c17efc93d7a084e5930db2
3
+ metadata.gz: ecbf2cf056cd56dbcac4a80553455b3a6b303ef8439bd38b5be513652835985f
4
+ data.tar.gz: 07c80687e4e01edb2050fe9e8f277dedbb7472f410f36e703948f791d4196104
5
5
  SHA512:
6
- metadata.gz: c6a8ca84a74bd5d08eb650e612187dc09d7e5b11b1559b219a883e6846860018ae8e0238f5a653be4cd4d686f8dc34200dce6258f0e90d9e98511f66773c4808
7
- data.tar.gz: 03ead102486b56deee8c6bd01db61a09324d5bfd25f150b33aaf144ad3d0823897fd0186e8b1211d919861a303d3df50cafa0b1f3666966449772655f634da3d
6
+ metadata.gz: 03b90d0da8e67d306bb9e59946264a1d931118179b35dfbcb6f80f16bd07a4b39cd7772453dffd7faba31bdc675aa9a620898f4cf545bc4ef8b2d633ffcaf08c
7
+ data.tar.gz: e60026a65dc4c3fcd3bfdfe97c56b36dc8a6fd9586da21122a20374122b273b38eb7b9333273fa749ad665b151e6b755bf0b667dc487bd7ef567d3445f473c20
@@ -25,6 +25,7 @@ class MenuItemComponent < Component
25
25
  attribute :value, :string, default: nil
26
26
  attribute :target, :string, default: nil
27
27
  attribute :rel, :string, default: nil
28
+ attribute :tab, :string, default: nil
28
29
 
29
30
  def to_s
30
31
  classes = class_names(
@@ -45,6 +46,7 @@ class MenuItemComponent < Component
45
46
 
46
47
  opts = merge_html_options(class: classes)
47
48
  opts["data-value"] = value if value
49
+ opts["data-tab"] = tab if tab
48
50
  opts[:target] = target if target
49
51
  opts[:rel] = rel if rel
50
52
 
@@ -1,24 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Tab — tab navigation with content panes.
3
+ # Tab — a single content pane within a TabGroup.
4
4
  #
5
- # Usage:
6
- # Tab(active: true) { text "Tab pane content" }
5
+ # Usage (inside TabGroup):
6
+ # Tab(active: true, path: "first", attached: true, segment: true) {
7
+ # text "First tab content"
8
+ # }
9
+ #
10
+ # Usage (standalone, no TabGroup):
11
+ # Tab(active: true, path: "first") { text "Pane content" }
7
12
 
8
13
  class TabComponent < Component
9
- attribute :active, :boolean, default: false
10
- attribute :path, :string, default: nil
14
+ include Attachable
15
+
16
+ attribute :active, :boolean, default: false
17
+ attribute :path, :string, default: nil
18
+ attribute :segment, :boolean, default: false
11
19
 
12
20
  def to_s
13
21
  classes = class_names(
14
22
  "ui",
15
- { "active" => active },
23
+ { "active" => active,
24
+ "bottom attached" => attached,
25
+ "segment" => segment },
16
26
  "tab"
17
27
  )
18
28
 
19
- data = { controller: "fui-tab" }
29
+ data = {}
20
30
  data[:tab] = path if path
21
31
 
22
- tag.div(class: classes, data: data) { @content }
32
+ tag.div(**merge_html_options(class: classes, data: data)) { @content }
23
33
  end
24
34
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TabGroup — wrapper for tab navigation with content panes.
4
+ #
5
+ # Renders a <div data-controller="fui-tab"> that wraps a Menu and Tab panes.
6
+ # The fui-tab Stimulus controller finds .item[data-tab] elements within
7
+ # and initializes Fomantic-UI's $.fn.tab plugin for click-based switching.
8
+ #
9
+ # Usage:
10
+ # TabGroup {
11
+ # Menu(tabular: true, attached: "top") {
12
+ # MenuItem(active: true, tab: "first") { text "First" }
13
+ # MenuItem(tab: "second") { text "Second" }
14
+ # }
15
+ # Tab(active: true, path: "first", attached: true, segment: true) {
16
+ # text "First tab content"
17
+ # }
18
+ # Tab(path: "second", attached: true, segment: true) {
19
+ # text "Second tab content"
20
+ # }
21
+ # }
22
+
23
+ class TabGroupComponent < Component
24
+ attribute :history, :boolean, default: false
25
+ attribute :history_type, :string, default: "hash"
26
+
27
+ def to_s
28
+ data = { controller: "fui-tab" }
29
+ data[:fui_tab_history_value] = history if history
30
+ data[:fui_tab_history_type_value] = history_type if history
31
+
32
+ tag.div(**merge_html_options(data: data)) { @content }
33
+ end
34
+ end
@@ -94,6 +94,7 @@ module ComponentHelper
94
94
  Sidebar: "SidebarComponent",
95
95
  Sticky: "StickyComponent",
96
96
  Tab: "TabComponent",
97
+ TabGroup: "TabGroupComponent",
97
98
  Toast: "ToastComponent",
98
99
  Transition: "TransitionComponent",
99
100
 
@@ -587,37 +587,33 @@ Header(size: :h3) { text "Tab" }
587
587
  text "Tab content panels used with a menu for switching views."
588
588
 
589
589
  Segment {
590
- Menu(pointing: true, secondary: true) {
591
- MenuItem(active: true) {
592
- concat tag.a("data-tab": "tab-1") { "Tab 1" }
590
+ TabGroup {
591
+ Menu(tabular: true, attached: "top") {
592
+ MenuItem(active: true, tab: "tab-1") { text "Tab 1" }
593
+ MenuItem(tab: "tab-2") { text "Tab 2" }
593
594
  }
594
- MenuItem {
595
- concat tag.a("data-tab": "tab-2") { "Tab 2" }
595
+ Tab(active: true, path: "tab-1", attached: true, segment: true) {
596
+ text "Content for Tab 1"
597
+ }
598
+ Tab(path: "tab-2", attached: true, segment: true) {
599
+ text "Content for Tab 2"
596
600
  }
597
- }
598
- Tab(active: true, path: "tab-1") {
599
- text "Content for Tab 1"
600
- }
601
- Tab(path: "tab-2") {
602
- text "Content for Tab 2"
603
601
  }
604
602
  }
605
603
 
606
604
  Segment(secondary: true) {
607
605
  concat tag.pre { tag.code(
608
- 'Menu(pointing: true, secondary: true) {
609
- MenuItem(active: true) {
610
- concat tag.a("data-tab": "tab-1") { "Tab 1" }
606
+ 'TabGroup {
607
+ Menu(tabular: true, attached: "top") {
608
+ MenuItem(active: true, tab: "tab-1") { text "Tab 1" }
609
+ MenuItem(tab: "tab-2") { text "Tab 2" }
611
610
  }
612
- MenuItem {
613
- concat tag.a("data-tab": "tab-2") { "Tab 2" }
611
+ Tab(active: true, path: "tab-1", attached: true, segment: true) {
612
+ text "Content for Tab 1"
613
+ }
614
+ Tab(path: "tab-2", attached: true, segment: true) {
615
+ text "Content for Tab 2"
614
616
  }
615
- }
616
- Tab(active: true, path: "tab-1") {
617
- text "Content for Tab 1"
618
- }
619
- Tab(path: "tab-2") {
620
- text "Content for Tab 2"
621
617
  }'
622
618
  )}
623
619
  }
data/lib/ui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ui
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-active-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - nathan
@@ -113,6 +113,7 @@ files:
113
113
  - app/components/sub_header_component.rb
114
114
  - app/components/sub_menu_component.rb
115
115
  - app/components/tab_component.rb
116
+ - app/components/tab_group_component.rb
116
117
  - app/components/table_cell_component.rb
117
118
  - app/components/table_component.rb
118
119
  - app/components/table_row_component.rb