anchor_view_components 0.11.3 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/app/components/anchor/action_menu_component.html.erb +15 -23
- data/app/components/anchor/action_menu_component.rb +4 -2
- data/app/components/anchor/anchor_view_components.ts +6 -6
- data/app/components/anchor/popover_component.html.erb +18 -0
- data/app/components/anchor/popover_component.rb +5 -0
- data/app/components/anchor/{action_menu_controller.ts → popover_controller.ts} +1 -4
- data/app/components/anchor/table_component.en.yml +1 -0
- data/app/components/anchor/table_component.html.erb +6 -2
- data/app/components/anchor/table_component.rb +8 -2
- data/app/helpers/anchor/view_helper.rb +8 -0
- data/lib/anchor/view_components/version.rb +1 -1
- data/previews/anchor/table_component_preview.rb +5 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54fe54f9b32e62f69edd813a0fa7c888da757f3fb35ea99c9ec7b2942c96b85e
|
4
|
+
data.tar.gz: ca892dda3d5ea422838b0fa2af607ab4159b8e6ea522b61d4c8a3580b014c510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e11eb6d50799d5664f7b1a7262b06fa4d1cd0e3c8d4763ca5098ebd574887b631a8a1bf8c4e2cc037d79c57318d91b9d21aa651ea3cd7db13e167fe2ab4e9eb4
|
7
|
+
data.tar.gz: 1db50607d4d1c83cc8d9884dfae24a4ac280904d56336cbff5263cc84def5ae49568509dcceb0e9c1450cb907fbcc2a6beb5c365a2453b3f657fa7942f9c152c
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,17 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<%= tag.div(
|
7
|
-
class: class_names(
|
8
|
-
"absolute -left-full -top-full m-0 px-0 py-1 bg-white rounded border border-subdued popover-open:block",
|
9
|
-
menu_classes
|
10
|
-
),
|
11
|
-
data: { action: "toggle->action-menu#positionPopover" },
|
12
|
-
id: menu_id,
|
13
|
-
popover: "auto",
|
14
|
-
) do %>
|
15
|
-
<ul>
|
16
|
-
<% items.each do |item| %>
|
17
|
-
<%= tag.li(
|
18
|
-
item,
|
19
|
-
class: "action-menu-item whitespace-nowrap hover:bg-grey-10",
|
20
|
-
data: { testid: "action-menu-item" }
|
21
|
-
) %>
|
22
|
-
<% end %>
|
23
|
-
</ul>
|
1
|
+
<%= anchor_popover(id: menu_id, classes: class_names("px-0", "py-1", menu_classes)) do |popover| %>
|
2
|
+
<% if show_button? %>
|
3
|
+
<% popover.with_trigger do %>
|
4
|
+
<%= show_button %>
|
5
|
+
<% end %>
|
24
6
|
<% end %>
|
7
|
+
|
8
|
+
<ul>
|
9
|
+
<% items.each do |item| %>
|
10
|
+
<%= tag.li(
|
11
|
+
item,
|
12
|
+
class: "action-menu-item whitespace-nowrap hover:bg-grey-10",
|
13
|
+
data: { testid: "action-menu-item" }
|
14
|
+
) %>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
25
17
|
<% end %>
|
@@ -2,8 +2,10 @@ module Anchor
|
|
2
2
|
class ActionMenuComponent < Component
|
3
3
|
renders_one :show_button, lambda { |**kwargs|
|
4
4
|
ButtonComponent.new(
|
5
|
-
|
6
|
-
|
5
|
+
**popover_trigger_attributes(
|
6
|
+
popovertarget: menu_id,
|
7
|
+
data: { testid: "action-menu-btn" }
|
8
|
+
),
|
7
9
|
**kwargs
|
8
10
|
)
|
9
11
|
}
|
@@ -1,29 +1,29 @@
|
|
1
1
|
import "@oddbird/popover-polyfill";
|
2
2
|
|
3
|
-
import ActionMenuController from "./action_menu_controller";
|
4
3
|
import AutocompleteController from "./autocomplete_controller";
|
5
4
|
import DialogController from "./dialog_controller";
|
6
5
|
import InvokerController from "./invoker_controller";
|
6
|
+
import PopoverController from "./popover_controller";
|
7
|
+
import Sortable from "stimulus-sortable";
|
7
8
|
import ToastController from "./toast_controller";
|
8
9
|
import ToggleController from "./toggle_controller";
|
9
|
-
import Sortable from "stimulus-sortable";
|
10
10
|
import { Application } from "@hotwired/stimulus";
|
11
11
|
|
12
12
|
export function registerAnchorControllers(application: Application) {
|
13
|
-
application.register("action-menu", ActionMenuController);
|
14
13
|
application.register("autocomplete", AutocompleteController);
|
15
14
|
application.register("dialog", DialogController);
|
16
15
|
application.register("invoker", InvokerController);
|
17
|
-
application.register("
|
16
|
+
application.register("popover", PopoverController);
|
17
|
+
application.register("sortable", Sortable);
|
18
18
|
application.register("toast", ToastController);
|
19
19
|
application.register("toggle", ToggleController);
|
20
20
|
}
|
21
21
|
|
22
22
|
export {
|
23
|
-
ActionMenuController,
|
24
23
|
AutocompleteController,
|
25
24
|
DialogController,
|
26
25
|
InvokerController,
|
26
|
+
PopoverController,
|
27
27
|
ToastController,
|
28
|
-
ToggleController
|
28
|
+
ToggleController,
|
29
29
|
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= tag.div(
|
2
|
+
class: "contents",
|
3
|
+
data: { controller: "popover" },
|
4
|
+
) do %>
|
5
|
+
<%= trigger if trigger? %>
|
6
|
+
|
7
|
+
<%= tag.div(
|
8
|
+
class: class_names(
|
9
|
+
"absolute -left-full -top-full m-0 bg-white rounded border border-subdued popover-open:block",
|
10
|
+
classes
|
11
|
+
),
|
12
|
+
data: { action: "toggle->popover#positionPopover" },
|
13
|
+
id:,
|
14
|
+
popover: "auto",
|
15
|
+
) do %>
|
16
|
+
<%= content %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
@@ -10,10 +10,7 @@ export default class extends Controller<HTMLDivElement> {
|
|
10
10
|
const popover = event.target;
|
11
11
|
computePosition(this.buttonTarget, popover, {
|
12
12
|
placement: "bottom-start",
|
13
|
-
middleware: [
|
14
|
-
flip(),
|
15
|
-
offset(4),
|
16
|
-
]
|
13
|
+
middleware: [flip(), offset(4)],
|
17
14
|
}).then(({ x, y }) => {
|
18
15
|
Object.assign(popover.style, {
|
19
16
|
left: `${x}px`,
|
@@ -41,7 +41,11 @@
|
|
41
41
|
end %>
|
42
42
|
</table>
|
43
43
|
|
44
|
-
<% if
|
44
|
+
<% if show_total %>
|
45
|
+
<%= tag.div total, class: "mt-3 text-base font-semibold" %>
|
46
|
+
<% end %>
|
47
|
+
|
48
|
+
<% if data.empty? %>
|
45
49
|
<%= tag.p empty_message, class: "text-base text-center mt-6" %>
|
46
|
-
<% end
|
50
|
+
<% end %>
|
47
51
|
</div>
|
@@ -3,20 +3,22 @@ module Anchor
|
|
3
3
|
renders_many :columns, "ColumnComponent"
|
4
4
|
renders_one :link
|
5
5
|
|
6
|
-
attr_reader :data, :sortable, :caption
|
6
|
+
attr_reader :data, :sortable, :caption, :show_total
|
7
7
|
|
8
8
|
def initialize(
|
9
9
|
data:,
|
10
10
|
caption: nil,
|
11
11
|
empty_message: nil,
|
12
12
|
sort_url: nil,
|
13
|
-
sortable: false
|
13
|
+
sortable: false,
|
14
|
+
show_total: false
|
14
15
|
)
|
15
16
|
@data = data
|
16
17
|
@empty_message = empty_message
|
17
18
|
@sortable = sortable
|
18
19
|
@sort_url = sort_url
|
19
20
|
@caption = caption
|
21
|
+
@show_total = show_total
|
20
22
|
|
21
23
|
super
|
22
24
|
end
|
@@ -91,6 +93,10 @@ module Anchor
|
|
91
93
|
columns.present?
|
92
94
|
end
|
93
95
|
|
96
|
+
def total
|
97
|
+
t(".total", count: data.size)
|
98
|
+
end
|
99
|
+
|
94
100
|
class ColumnComponent < Anchor::Component
|
95
101
|
attr_reader :header, :value
|
96
102
|
|
@@ -11,6 +11,7 @@ module Anchor
|
|
11
11
|
icon
|
12
12
|
loading_indicator
|
13
13
|
panel
|
14
|
+
popover
|
14
15
|
prose
|
15
16
|
side_nav
|
16
17
|
tab_bar
|
@@ -68,5 +69,12 @@ module Anchor
|
|
68
69
|
|
69
70
|
doc.to_html.html_safe
|
70
71
|
end
|
72
|
+
|
73
|
+
def popover_trigger_attributes(popovertarget:, data: {})
|
74
|
+
{
|
75
|
+
data: { popover_target: "button", **data },
|
76
|
+
popovertarget:,
|
77
|
+
}
|
78
|
+
end
|
71
79
|
end
|
72
80
|
end
|
@@ -14,8 +14,11 @@ module Anchor
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def playground
|
17
|
-
|
18
|
-
|
17
|
+
render Anchor::TableComponent.new(
|
18
|
+
data:,
|
19
|
+
caption: "A demo table",
|
20
|
+
show_total: true
|
21
|
+
) do |table|
|
19
22
|
table.with_column(header: "Id", value: :id)
|
20
23
|
table.with_column(header: "Name", value: -> { _1.name.capitalize })
|
21
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anchor_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buoy Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- app/assets/stylesheets/components/toast.css
|
63
63
|
- app/components/anchor/action_menu_component.html.erb
|
64
64
|
- app/components/anchor/action_menu_component.rb
|
65
|
-
- app/components/anchor/action_menu_controller.ts
|
66
65
|
- app/components/anchor/anchor_view_components.ts
|
67
66
|
- app/components/anchor/autocomplete_component.en.yml
|
68
67
|
- app/components/anchor/autocomplete_component.html.erb
|
@@ -95,6 +94,9 @@ files:
|
|
95
94
|
- app/components/anchor/panel/header_component.rb
|
96
95
|
- app/components/anchor/panel_component.html.erb
|
97
96
|
- app/components/anchor/panel_component.rb
|
97
|
+
- app/components/anchor/popover_component.html.erb
|
98
|
+
- app/components/anchor/popover_component.rb
|
99
|
+
- app/components/anchor/popover_controller.ts
|
98
100
|
- app/components/anchor/prose_component.html.erb
|
99
101
|
- app/components/anchor/prose_component.rb
|
100
102
|
- app/components/anchor/side_nav_component.en.yml
|
@@ -160,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
162
|
- !ruby/object:Gem::Version
|
161
163
|
version: '0'
|
162
164
|
requirements: []
|
163
|
-
rubygems_version: 3.4.
|
165
|
+
rubygems_version: 3.4.19
|
164
166
|
signing_key:
|
165
167
|
specification_version: 4
|
166
168
|
summary: ViewComponents for Buoy’s design system, Anchor
|