coveragebook_components 0.9.1 → 0.10.1.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/build/coco/app.css +4433 -3098
- data/app/assets/build/coco/app.js +125 -109
- data/app/assets/build/coco/book.css +1492 -99
- data/app/assets/build/coco/book.js +279 -18
- data/app/assets/css/app/tippy.css +1 -1
- data/app/assets/css/app.css +3 -3
- data/app/assets/css/{base/base.css → base.css} +14 -6
- data/app/assets/css/book.css +2 -2
- data/app/assets/css/{libs → shared}/tippy.css +20 -1
- data/app/assets/css/shared/utils/text.css +143 -0
- data/app/assets/js/app.js +2 -2
- data/app/assets/js/book.js +2 -2
- data/app/assets/js/libs/alpine/directives/dropdown.js +1 -1
- data/app/assets/js/libs/alpine/directives/tooltip.js +1 -1
- data/app/assets/js/shared/components.js +4 -0
- data/app/components/coco/app/blocks/header/header.js +1 -1
- data/app/components/coco/app/blocks/header/header.rb +2 -2
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.css +4 -0
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.js +1 -1
- data/app/components/coco/app/blocks/sidebar_nav/item/item.css +3 -3
- data/app/components/coco/app/blocks/sidebar_nav/item/item.js +2 -2
- data/app/components/coco/app/blocks/sidebar_nav/menu/menu.css +3 -3
- data/app/components/coco/app/blocks/sidebar_nav/menu/menu.js +1 -1
- data/app/components/coco/app/blocks/sidebar_nav/navbar/navbar.js +1 -1
- data/app/components/coco/app/blocks/slide_editor/slide_editor.js +1 -1
- data/app/components/coco/app/elements/alert/alert.css +18 -50
- data/app/components/coco/app/elements/alert/alert.html.erb +2 -2
- data/app/components/coco/app/elements/alert/alert.js +1 -1
- data/app/components/coco/app/elements/alert/alert.rb +11 -16
- data/app/components/coco/app/elements/color_picker/color_picker.css +2 -2
- data/app/components/coco/app/elements/color_picker/color_picker.js +1 -1
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.js +1 -1
- data/app/components/coco/app/elements/color_picker_button/color_picker_button.rb +3 -3
- data/app/components/coco/app/elements/confirm_panel/confirm_panel.css +1 -1
- data/app/components/coco/app/elements/confirm_panel/confirm_panel.js +1 -1
- data/app/components/coco/app/elements/image_picker/image_picker.css +4 -4
- data/app/components/coco/app/elements/image_picker/image_picker.js +1 -1
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.js +1 -1
- data/app/components/coco/app/elements/image_picker_button/image_picker_button.rb +3 -3
- data/app/components/coco/app/elements/layout_picker_button/layout_picker_button.js +1 -1
- data/app/components/coco/app/elements/layout_picker_button/layout_picker_button.rb +3 -3
- data/app/components/coco/app/elements/link/link.rb +1 -1
- data/app/components/coco/app/elements/menu/menu.css +5 -5
- data/app/components/coco/app/elements/menu_button/menu_button.js +1 -1
- data/app/components/coco/app/elements/menu_button/menu_button.rb +3 -3
- data/app/components/coco/app/elements/menu_items/user_profile/user_profile.css +1 -1
- data/app/components/coco/app/elements/notice/notice.js +1 -1
- data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.js +1 -1
- data/app/components/coco/app/elements/snackbar/snackbar.css +1 -1
- data/app/components/coco/app/elements/snackbar/snackbar.js +1 -1
- data/app/components/coco/app/elements/stamp/stamp.css +103 -0
- data/app/components/coco/app/elements/stamp/stamp.html.erb +3 -0
- data/app/components/coco/app/elements/stamp/stamp.rb +29 -0
- data/app/components/coco/app/elements/system_banner/system_banner.js +1 -1
- data/app/components/coco/app/elements/toast/toast.js +1 -1
- data/app/components/coco/app/elements/toolbar/toolbar.js +1 -1
- data/app/components/coco/app/elements/toolbar/toolbar.rb +1 -1
- data/app/components/coco/app/fields/button_component.rb +1 -1
- data/app/components/coco/app/fields/submit_component.rb +1 -0
- data/app/components/coco/app/layouts/application/application.css +1 -1
- data/app/components/coco/app/layouts/application/application.js +1 -1
- data/app/components/coco/app/layouts/page/page.css +4 -0
- data/app/components/coco/app/layouts/page/page.html.erb +5 -0
- data/app/components/coco/app/layouts/page/page.js +1 -1
- data/app/components/coco/app/layouts/page/page.rb +4 -0
- data/app/components/coco/{app/elements → shared}/button/button.css +104 -32
- data/app/components/coco/shared/button/button.html.erb +83 -0
- data/app/components/coco/{base → shared}/button/button.js +2 -1
- data/app/components/coco/{base → shared}/button/button.rb +107 -42
- data/app/components/coco/{base → shared}/button/button_dropdown.js +11 -2
- data/app/components/coco/{app/elements → shared}/button_group/button_group.css +1 -1
- data/app/components/coco/{app/elements → shared}/button_group/button_group.js +12 -4
- data/app/components/coco/shared/button_group/button_group.rb +40 -0
- data/app/components/coco/{app/elements → shared}/button_to/button_to.css +1 -1
- data/app/components/coco/shared/button_to/button_to.rb +50 -0
- data/app/components/coco/{base → shared}/dropdown/dropdown.js +1 -1
- data/app/components/coco/{base → shared}/icon/icon.js +1 -1
- data/app/components/coco/{base → shared}/image_uploader/image_uploader.js +1 -1
- data/app/components/coco/{base → shared}/modal/modal.html.erb +2 -2
- data/app/components/coco/{base → shared}/modal/modal.js +3 -3
- data/app/components/coco/{base → shared}/modal/modal.rb +6 -4
- data/app/components/coco/{base → shared}/modal_dialog/modal_dialog.js +1 -1
- data/app/components/coco/{base → shared}/modal_lightbox/modal_lightbox.js +1 -1
- data/app/components/coco/{base → shared}/placeholder/placeholder.html.erb +1 -1
- data/app/components/coco/{base → shared}/placeholder/placeholder.rb +6 -0
- data/app/components/coco/{base → shared}/poll_controller/poll_controller.js +1 -1
- data/app/helpers/coco/app_helper.rb +17 -23
- data/app/helpers/coco/component_helper.rb +1 -1
- data/app/helpers/coco/{base_helper.rb → shared_helper.rb} +26 -3
- data/app/helpers/coco/url_helper.rb +1 -1
- data/config/tailwind.app.config.cjs +1 -1
- data/config/tailwind.book.config.cjs +1 -0
- data/config/tokens.cjs +9 -4
- data/lib/coco/engine.rb +6 -4
- data/lib/coco.rb +1 -1
- data/lib/generators/coco/coco_generator.rb +1 -1
- metadata +77 -80
- data/app/assets/css/base/components/coco.css +0 -14
- data/app/assets/css/base/components/dropdown.css +0 -7
- data/app/assets/css/base/components/tooltip.css +0 -19
- data/app/assets/js/base/components.js +0 -4
- data/app/components/coco/app/blocks/slat/slat.css +0 -9
- data/app/components/coco/app/blocks/slat/slat.rb +0 -13
- data/app/components/coco/app/elements/button/button.rb +0 -87
- data/app/components/coco/app/elements/button_group/button_group.rb +0 -42
- data/app/components/coco/app/elements/button_to/button_to.rb +0 -54
- data/app/components/coco/base/button/button.css +0 -75
- data/app/components/coco/base/button/button.html.erb +0 -71
- /data/app/assets/css/app/{utilities.css → utils.css} +0 -0
- /data/app/assets/css/{base → shared}/utils/colors.css +0 -0
- /data/app/assets/css/{base → shared}/utils/icons.css +0 -0
- /data/app/assets/js/{coco.js → shared/coco.js} +0 -0
- /data/app/components/coco/{base → shared}/avatar/avatar.css +0 -0
- /data/app/components/coco/{base → shared}/avatar/avatar.rb +0 -0
- /data/app/components/coco/{app/elements → shared}/button_group/button_group.html.erb +0 -0
- /data/app/components/coco/{app/elements → shared}/button_to/button_to.html.erb +0 -0
- /data/app/components/coco/{base → shared}/content/content.rb +0 -0
- /data/app/components/coco/{base → shared}/dropdown/dropdown.css +0 -0
- /data/app/components/coco/{base → shared}/dropdown/dropdown.html.erb +0 -0
- /data/app/components/coco/{base → shared}/dropdown/dropdown.rb +0 -0
- /data/app/components/coco/{base → shared}/embeds/youtube/youtube.css +0 -0
- /data/app/components/coco/{base → shared}/embeds/youtube/youtube.html.erb +0 -0
- /data/app/components/coco/{base → shared}/embeds/youtube/youtube.rb +0 -0
- /data/app/components/coco/{base → shared}/icon/icon.css +0 -0
- /data/app/components/coco/{base → shared}/icon/icon.html.erb +0 -0
- /data/app/components/coco/{base → shared}/icon/icon.rb +0 -0
- /data/app/components/coco/{base → shared}/image/image.css +0 -0
- /data/app/components/coco/{base → shared}/image/image.rb +0 -0
- /data/app/components/coco/{base → shared}/image_uploader/image_uploader.css +0 -0
- /data/app/components/coco/{base → shared}/image_uploader/image_uploader.html.erb +0 -0
- /data/app/components/coco/{base → shared}/image_uploader/image_uploader.rb +0 -0
- /data/app/components/coco/{base → shared}/link/link.css +0 -0
- /data/app/components/coco/{base → shared}/link/link.rb +0 -0
- /data/app/components/coco/{base → shared}/modal/modal.css +0 -0
- /data/app/components/coco/{base → shared}/modal_dialog/modal_dialog.css +0 -0
- /data/app/components/coco/{base → shared}/modal_dialog/modal_dialog.html.erb +0 -0
- /data/app/components/coco/{base → shared}/modal_dialog/modal_dialog.rb +0 -0
- /data/app/components/coco/{base → shared}/modal_lightbox/modal_lightbox.css +0 -0
- /data/app/components/coco/{base → shared}/modal_lightbox/modal_lightbox.html.erb +0 -0
- /data/app/components/coco/{base → shared}/modal_lightbox/modal_lightbox.rb +0 -0
- /data/app/components/coco/{base → shared}/pager_link/pager_link.css +0 -0
- /data/app/components/coco/{base → shared}/pager_link/pager_link.html.erb +0 -0
- /data/app/components/coco/{base → shared}/pager_link/pager_link.rb +0 -0
- /data/app/components/coco/{base → shared}/panel/panel.css +0 -0
- /data/app/components/coco/{base → shared}/panel/panel.html.erb +0 -0
- /data/app/components/coco/{base → shared}/panel/panel.rb +0 -0
- /data/app/components/coco/{base → shared}/placeholder/placeholder.css +0 -0
- /data/app/components/coco/{base → shared}/poll_controller/poll_controller.css +0 -0
- /data/app/components/coco/{base → shared}/poll_controller/poll_controller.html.erb +0 -0
- /data/app/components/coco/{base → shared}/poll_controller/poll_controller.rb +0 -0
- /data/app/components/coco/{base → shared}/svg/svg.html.erb +0 -0
- /data/app/components/coco/{base → shared}/svg/svg.rb +0 -0
@@ -6,73 +6,90 @@ module Coco
|
|
6
6
|
include Concerns::WithTooltip
|
7
7
|
include Concerns::AcceptsTheme
|
8
8
|
|
9
|
-
SIZES = [:sm, :md, :lg, nil]
|
9
|
+
SIZES = [:xs, :sm, :md, :lg, nil]
|
10
10
|
|
11
11
|
SIZE_ALIASES = {
|
12
12
|
default: [:sm, {xl: :md}]
|
13
13
|
}
|
14
14
|
|
15
|
-
THEMES = [
|
16
|
-
|
17
|
-
|
15
|
+
THEMES = [
|
16
|
+
"primary",
|
17
|
+
"text-primary",
|
18
|
+
"secondary",
|
19
|
+
"text-secondary",
|
20
|
+
"positive",
|
21
|
+
"text-positive",
|
22
|
+
"negative",
|
23
|
+
"text-negative",
|
24
|
+
"warning",
|
25
|
+
"text-warning",
|
26
|
+
"info",
|
27
|
+
"text-info",
|
28
|
+
"toolbar",
|
29
|
+
"toolbar-floating",
|
30
|
+
"text-toolbar",
|
31
|
+
"neutral-dark",
|
32
|
+
"neutral-light",
|
33
|
+
"text-neutral-light",
|
34
|
+
"text-neutral-dark",
|
35
|
+
"blank",
|
36
|
+
nil
|
37
|
+
]
|
38
|
+
|
39
|
+
DEFAULT_THEME = "primary"
|
18
40
|
|
19
41
|
tag_attr :type, :value, :name, :disabled, :href, :target
|
20
42
|
|
43
|
+
accepts_option :size, from: SIZES, default: :md
|
44
|
+
accepts_option :theme, from: THEMES, default: DEFAULT_THEME
|
21
45
|
accepts_option :disabled, from: [true, false]
|
22
46
|
accepts_option :confirm, from: [true, false, nil], default: nil
|
23
47
|
accepts_option :fit, from: [:auto, :full]
|
24
48
|
accepts_option :collapsible, from: [true, false, nil]
|
25
49
|
accepts_option :toggle, from: [:horizontal, :vertical]
|
26
50
|
accepts_option :state
|
51
|
+
accepts_option :variant
|
27
52
|
|
28
53
|
accepts_option :dropdown do |dd|
|
29
54
|
dd.accepts_option :placement,
|
30
|
-
from: %w[top top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-end auto auto-start auto-end]
|
55
|
+
from: %w[top top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-end auto auto-start auto-end],
|
56
|
+
private: true
|
31
57
|
end
|
32
58
|
|
33
59
|
renders_one :text, Coco::Content
|
34
60
|
|
61
|
+
renders_one :dropdown, types: {
|
62
|
+
content: ->(&block) { block.call },
|
63
|
+
confirmation: ->(**kwargs) do
|
64
|
+
set_option_value(:confirm, true)
|
65
|
+
Coco::App::Elements::ConfirmPanel.new(**kwargs)
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
35
69
|
renders_many :states, ->(name = nil, **kwargs) do
|
36
70
|
name ||= kwargs.fetch(:name)
|
37
71
|
@states[name.to_sym] = kwargs.except!(:name)
|
38
72
|
end
|
39
73
|
|
40
|
-
before_initialize do |kwargs|
|
41
|
-
button_size = kwargs.fetch(:size, :default)&.to_sym
|
42
|
-
if button_size.in?(self::SIZE_ALIASES.keys) && !kwargs.key?(:resize)
|
43
|
-
kwargs[:size], kwargs[:resize] = self::SIZE_ALIASES.fetch(button_size)
|
44
|
-
end
|
45
|
-
|
46
|
-
kwargs
|
47
|
-
end
|
48
|
-
|
49
|
-
before_render do
|
50
|
-
resize.each { set_tag_data_attr("size-#{_1}", _2) }
|
51
|
-
|
52
|
-
if loading?
|
53
|
-
set_option_value(:state, "loading")
|
54
|
-
elsif active?
|
55
|
-
set_option_value(:state, "active")
|
56
|
-
end
|
57
|
-
|
58
|
-
set_tag_attr(:disabled, true) if disabled?
|
59
|
-
set_tag_attr(:type, "button") unless tag_attr?(:type) || link?
|
60
|
-
|
61
|
-
if dropdown? || confirm? && get_option(:dropdown, :placement).blank?
|
62
|
-
set_option_value(:dropdown, :placement, "bottom-start")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
74
|
attr_reader :on_click, :resize
|
67
75
|
|
68
|
-
def initialize(click: nil, resize: nil, states: nil, loading: false, active: false,
|
76
|
+
def initialize(click: nil, resize: nil, states: nil, loading: false, active: false, static: nil, **kwargs)
|
69
77
|
@on_click = click
|
70
78
|
@resize = resize.to_h
|
71
79
|
@states = states.to_h
|
72
80
|
@loading = loading
|
81
|
+
@static = static
|
73
82
|
@active = active
|
74
83
|
end
|
75
84
|
|
85
|
+
def with_dropdown(...)
|
86
|
+
with_dropdown_content(...)
|
87
|
+
end
|
88
|
+
|
89
|
+
def with_confirmation(...)
|
90
|
+
with_dropdown_confirmation(...)
|
91
|
+
end
|
92
|
+
|
76
93
|
def toggle?
|
77
94
|
toggle_direction.present? && button_text.present?
|
78
95
|
end
|
@@ -89,6 +106,14 @@ module Coco
|
|
89
106
|
text&.to_s || content&.to_s || ""
|
90
107
|
end
|
91
108
|
|
109
|
+
def static?
|
110
|
+
if @static.nil?
|
111
|
+
!(confirm? || dropdown? || tooltip? || @states.any? || on_click.present? || get_option_value(:collapsible))
|
112
|
+
else
|
113
|
+
@static
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
92
117
|
def loading?
|
93
118
|
@loading == true
|
94
119
|
end
|
@@ -101,6 +126,10 @@ module Coco
|
|
101
126
|
get_option_value(:confirm)
|
102
127
|
end
|
103
128
|
|
129
|
+
def tooltip?
|
130
|
+
get_option_value(:tooltip, :content).present?
|
131
|
+
end
|
132
|
+
|
104
133
|
def disabled?
|
105
134
|
get_option_value(:disabled)
|
106
135
|
end
|
@@ -114,22 +143,16 @@ module Coco
|
|
114
143
|
end
|
115
144
|
|
116
145
|
def icon_only?
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
def dropdown?
|
121
|
-
false
|
146
|
+
(@states.none? && button_text.blank?) ||
|
147
|
+
!states.find { _2[:text].present? }
|
122
148
|
end
|
123
149
|
|
124
150
|
def alpine_wrapper_attrs
|
125
151
|
if dropdown? || confirm?
|
126
152
|
{
|
127
153
|
data: x_data("buttonDropdown"),
|
128
|
-
dropdown: jsify_data({
|
129
|
-
|
130
|
-
"@dropdown:hide": ("button.resetState()" if dropdown?),
|
131
|
-
"@confirmation:confirm": ("button.approveAndRun($event)" if confirm?),
|
132
|
-
"@confirmation:cancel": ("button.cancelConfirmation($event)" if confirm?)
|
154
|
+
dropdown: jsify_data({placement: get_option_value(:dropdown, :placement)}.compact),
|
155
|
+
bind: "root"
|
133
156
|
}
|
134
157
|
end
|
135
158
|
end
|
@@ -193,5 +216,47 @@ module Coco
|
|
193
216
|
icon = icon.is_a?(Symbol) ? {name: icon} : icon
|
194
217
|
icon.is_a?(Hash) ? render(Coco::Icon.new(**icon)) : icon
|
195
218
|
end
|
219
|
+
|
220
|
+
before_initialize do |kwargs|
|
221
|
+
if kwargs.key?(:modal)
|
222
|
+
modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal]
|
223
|
+
kwargs[:data] = kwargs.fetch(:data, {}).merge(coco_modal_data_attributes(modal_name))
|
224
|
+
kwargs.delete(:modal)
|
225
|
+
end
|
226
|
+
|
227
|
+
button_size = kwargs.fetch(:size, :default)&.to_sym
|
228
|
+
if button_size.in?(SIZE_ALIASES.keys) && !kwargs.key?(:resize)
|
229
|
+
kwargs[:size], kwargs[:resize] = SIZE_ALIASES.fetch(button_size)
|
230
|
+
end
|
231
|
+
|
232
|
+
kwargs
|
233
|
+
end
|
234
|
+
|
235
|
+
before_render do
|
236
|
+
resize.each { set_tag_data_attr("size-#{_1}", _2) }
|
237
|
+
|
238
|
+
if loading?
|
239
|
+
set_option_value(:state, "loading")
|
240
|
+
elsif active?
|
241
|
+
set_option_value(:state, "active")
|
242
|
+
end
|
243
|
+
|
244
|
+
set_tag_attr(:disabled, true) if disabled?
|
245
|
+
set_tag_attr(:type, "button") unless tag_attr?(:type) || link?
|
246
|
+
|
247
|
+
if confirm? && !dropdown?
|
248
|
+
with_confirmation do |confirm|
|
249
|
+
confirm.with_text { "Are you sure?" }
|
250
|
+
confirm.with_button { "Yes, continue" }
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
if (dropdown? || confirm?) && get_option(:dropdown, :placement).blank?
|
255
|
+
set_option_value(:dropdown, :placement, "bottom-start")
|
256
|
+
end
|
257
|
+
end
|
258
|
+
class << self
|
259
|
+
include Coco::SharedHelper
|
260
|
+
end
|
196
261
|
end
|
197
262
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { CocoComponent } from "@js/coco.js";
|
1
|
+
import { CocoComponent } from "@assets/js/shared/coco.js";
|
2
2
|
import { getComponent } from "@helpers/alpine";
|
3
3
|
|
4
|
-
export default CocoComponent("buttonDropdown", (
|
4
|
+
export default CocoComponent("buttonDropdown", () => {
|
5
5
|
return {
|
6
6
|
dropdown: null,
|
7
7
|
button: null,
|
@@ -23,5 +23,14 @@ export default CocoComponent("buttonDropdown", (data = {}) => {
|
|
23
23
|
this.dropdown.show();
|
24
24
|
}
|
25
25
|
},
|
26
|
+
|
27
|
+
/* bindings */
|
28
|
+
|
29
|
+
root: {
|
30
|
+
"@dropdown:show": "button.setState('active')",
|
31
|
+
"@dropdown:hide": "button.resetState()",
|
32
|
+
"@confirmation:confirm": "button.approveAndRun($event)",
|
33
|
+
"@confirmation:cancel": "button.cancelConfirmation($event)",
|
34
|
+
},
|
26
35
|
};
|
27
36
|
});
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CocoComponent } from "@js/coco.js";
|
1
|
+
import { CocoComponent } from "@assets/js/shared/coco.js";
|
2
2
|
import { getComponent } from "@helpers/alpine";
|
3
|
-
import { createSingleton } from "@libs/tippy";
|
3
|
+
import { createSingleton } from "@assets/js/libs/tippy";
|
4
4
|
|
5
5
|
export default CocoComponent("appButtonGroup", () => {
|
6
6
|
return {
|
@@ -19,7 +19,7 @@ export default CocoComponent("appButtonGroup", () => {
|
|
19
19
|
|
20
20
|
get buttons() {
|
21
21
|
const buttonElements = this.$el.querySelectorAll(
|
22
|
-
"[data-component='
|
22
|
+
"[data-component='button']"
|
23
23
|
);
|
24
24
|
return Array.from(buttonElements).map((el) => getComponent(el));
|
25
25
|
},
|
@@ -51,7 +51,15 @@ export default CocoComponent("appButtonGroup", () => {
|
|
51
51
|
this.destroySingletonTooltip();
|
52
52
|
|
53
53
|
this.tooltipInstances = this.buttons
|
54
|
-
.map((button) =>
|
54
|
+
.map((button) => {
|
55
|
+
if (
|
56
|
+
button.tippyInstance &&
|
57
|
+
button.shouldShowTooltip &&
|
58
|
+
button.shouldShowTooltip()
|
59
|
+
) {
|
60
|
+
return button.tippyInstance;
|
61
|
+
}
|
62
|
+
})
|
55
63
|
.filter((t) => t);
|
56
64
|
|
57
65
|
this.singletonTooltip = createSingleton(this.tooltipInstances, {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Coco
|
2
|
+
class ButtonGroup < Coco::Component
|
3
|
+
include Concerns::ActsAsButtonGroup
|
4
|
+
include Concerns::AcceptsOptions
|
5
|
+
|
6
|
+
accepts_option :size, default: :default, private: true
|
7
|
+
accepts_option :theme, default: :primary, private: true
|
8
|
+
accepts_option :segmented, from: [true, false], default: false
|
9
|
+
accepts_option :floating, from: [true, false], default: false
|
10
|
+
accepts_option :collapsible, from: [true, false, nil]
|
11
|
+
|
12
|
+
before_initialize do |kwargs|
|
13
|
+
if kwargs[:floating] == true
|
14
|
+
kwargs[:segmented] = true
|
15
|
+
kwargs[:theme] = :toolbar_floating
|
16
|
+
end
|
17
|
+
kwargs
|
18
|
+
end
|
19
|
+
|
20
|
+
def button_kwargs(kwargs, type = nil)
|
21
|
+
args = {
|
22
|
+
theme: get_option_value(:theme),
|
23
|
+
size: get_option_value(:size),
|
24
|
+
**kwargs
|
25
|
+
}
|
26
|
+
|
27
|
+
if component_args.key?(:resize)
|
28
|
+
args[:resize] = component_args[:resize]
|
29
|
+
end
|
30
|
+
|
31
|
+
if get_option_value(:collapsible) == false
|
32
|
+
args[:collapsible] = false
|
33
|
+
elsif get_option_value(:collapsible) == true
|
34
|
+
args[:static] = false
|
35
|
+
end
|
36
|
+
|
37
|
+
args
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Coco
|
2
|
+
class ButtonTo < Coco::Component
|
3
|
+
include Concerns::WrapsComponent
|
4
|
+
include Concerns::AcceptsOptions
|
5
|
+
|
6
|
+
accepts_option :fit, from: [:auto, :full]
|
7
|
+
|
8
|
+
wraps_component :button do |args|
|
9
|
+
Coco::Button.new(
|
10
|
+
type: :submit,
|
11
|
+
fit: get_option_value(:fit) || :auto,
|
12
|
+
**args
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
%i[confirmation].each do |slot_name|
|
17
|
+
renders_one slot_name, ->(**kwargs, &block) do
|
18
|
+
button.send("with_#{slot_name}".to_sym, **kwargs, &block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :method, :turbo
|
23
|
+
|
24
|
+
def initialize(form: nil, params: nil, method: :post, action: nil, href: nil, turbo: false, **kwargs)
|
25
|
+
@form_args = form.to_h
|
26
|
+
@action = action || href
|
27
|
+
@method = method
|
28
|
+
@params = params.to_h
|
29
|
+
@turbo = turbo
|
30
|
+
end
|
31
|
+
|
32
|
+
def params
|
33
|
+
to_form_params(@params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def form_args
|
37
|
+
{
|
38
|
+
url: action,
|
39
|
+
method: method,
|
40
|
+
data: {
|
41
|
+
turbo: ("false" if !turbo)
|
42
|
+
}
|
43
|
+
}.deep_merge(@form_args)
|
44
|
+
end
|
45
|
+
|
46
|
+
def action
|
47
|
+
@action.is_a?(String) ? @action : helpers.url_for(@action)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -24,11 +24,11 @@
|
|
24
24
|
<% else %>
|
25
25
|
<div data-role="inline-modal-content">
|
26
26
|
<% if container_type == :dialog %>
|
27
|
-
<%= render Coco::ModalDialog.new(title: title.to_s, dismissable: false) do %>
|
27
|
+
<%= render Coco::ModalDialog.new(id: @container_id, title: title.to_s, dismissable: false) do %>
|
28
28
|
<%= content %>
|
29
29
|
<% end %>
|
30
30
|
<% else %>
|
31
|
-
<%= coco_panel do %>
|
31
|
+
<%= coco_panel(id: @container_id) do %>
|
32
32
|
<%= content %>
|
33
33
|
<% end %>
|
34
34
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { CocoComponent } from "@js/coco";
|
2
|
-
import { hideAll } from "@libs/tippy";
|
1
|
+
import { CocoComponent } from "@assets/js/shared/coco";
|
2
|
+
import { hideAll } from "@assets/js/libs/tippy";
|
3
3
|
import { navigateTo } from "@helpers/location";
|
4
4
|
|
5
5
|
export default CocoComponent("modal", () => {
|
@@ -40,7 +40,7 @@ export default CocoComponent("modal", () => {
|
|
40
40
|
},
|
41
41
|
|
42
42
|
visit(url) {
|
43
|
-
navigateTo(url, { frame: this.frame.id });
|
43
|
+
navigateTo(url, { frame: this.frame.id, turbo: true });
|
44
44
|
},
|
45
45
|
|
46
46
|
scrollTo(pos) {
|
@@ -9,15 +9,17 @@ module Coco
|
|
9
9
|
renders_one :title
|
10
10
|
|
11
11
|
renders_one :container, types: {
|
12
|
-
dialog: ->(**kwargs, &block) do
|
12
|
+
dialog: ->(id: nil, **kwargs, &block) do
|
13
13
|
@container_content = block
|
14
|
+
@container_id = id
|
14
15
|
@container_type = :dialog
|
15
|
-
Coco::ModalDialog.new(dismissable: get_option_value(:dismissable), **kwargs)
|
16
|
+
Coco::ModalDialog.new(dismissable: get_option_value(:dismissable), id:, **kwargs)
|
16
17
|
end,
|
17
18
|
|
18
|
-
lightbox: ->(**kwargs, &block) do
|
19
|
+
lightbox: ->(id: nil, **kwargs, &block) do
|
19
20
|
@container_type = :lightbox
|
20
|
-
|
21
|
+
@container_id = id
|
22
|
+
Coco::ModalLightbox.new(dismissable: get_option_value(:dismissable), id:, **kwargs)
|
21
23
|
end
|
22
24
|
}
|
23
25
|
|
@@ -5,5 +5,11 @@ module Coco
|
|
5
5
|
accepts_option :size, from: [:auto, :full], default: :auto
|
6
6
|
accepts_option :prose, from: [true, false], default: false
|
7
7
|
accepts_option :boxed, from: [true, false], default: true
|
8
|
+
|
9
|
+
attr_reader :text_content
|
10
|
+
|
11
|
+
def initialize(text_content: nil, **)
|
12
|
+
@text_content = text_content
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
@@ -13,25 +13,6 @@ module Coco
|
|
13
13
|
render(link, &block)
|
14
14
|
end
|
15
15
|
|
16
|
-
def coco_button(*args, **kwargs, &block)
|
17
|
-
href, content = if block
|
18
|
-
[args.first, nil]
|
19
|
-
else
|
20
|
-
(args.size == 1) ? [nil, args.first] : args[0..2].reverse!
|
21
|
-
end
|
22
|
-
|
23
|
-
button = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params)
|
24
|
-
"ButtonTo"
|
25
|
-
else
|
26
|
-
"Button"
|
27
|
-
end
|
28
|
-
|
29
|
-
component = "Coco::App::Elements::#{button}".constantize.new(href: href, **kwargs)
|
30
|
-
component = component.with_content(content) if !block && content.present?
|
31
|
-
|
32
|
-
render(component, &block)
|
33
|
-
end
|
34
|
-
|
35
16
|
def coco_menu_button(**, &block)
|
36
17
|
render Coco::App::Elements::MenuButton.new(**), &block
|
37
18
|
end
|
@@ -56,10 +37,6 @@ module Coco
|
|
56
37
|
render Coco::App::Elements::DropdownButton.new(**), &block
|
57
38
|
end
|
58
39
|
|
59
|
-
def coco_button_group(**, &block)
|
60
|
-
render Coco::App::Elements::ButtonGroup.new(**), &block
|
61
|
-
end
|
62
|
-
|
63
40
|
def coco_toolbar(**, &block)
|
64
41
|
render Coco::App::Elements::Toolbar.new(**), &block
|
65
42
|
end
|
@@ -68,6 +45,23 @@ module Coco
|
|
68
45
|
render Coco::App::Elements::SeamlessTextarea.new(**), &block
|
69
46
|
end
|
70
47
|
|
48
|
+
def coco_stamp(type = nil, **)
|
49
|
+
props = case type
|
50
|
+
when :success, :positive
|
51
|
+
{icon: :check_circle, theme: :positive}
|
52
|
+
when :error, :negative
|
53
|
+
{icon: :alert_circle, theme: :negative}
|
54
|
+
when :warning
|
55
|
+
{icon: :alert_triangle, theme: :warning}
|
56
|
+
when :info
|
57
|
+
{icon: :info, theme: :info}
|
58
|
+
else
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
|
62
|
+
render Coco::App::Elements::Stamp.new(**props, **)
|
63
|
+
end
|
64
|
+
|
71
65
|
def coco_snackbar(**, &block)
|
72
66
|
render Coco::App::Elements::Snackbar.new(**), &block
|
73
67
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Coco
|
2
|
-
module
|
2
|
+
module SharedHelper
|
3
3
|
def coco_tag(*, **, &block)
|
4
4
|
render Coco::Tag.new(*, **), &block
|
5
5
|
end
|
@@ -29,8 +29,31 @@ module Coco
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def coco_placeholder(
|
33
|
-
render Coco::Placeholder.new(
|
32
|
+
def coco_placeholder(text_content = nil, **, &block)
|
33
|
+
render Coco::Placeholder.new(text_content:, **), &block
|
34
|
+
end
|
35
|
+
|
36
|
+
def coco_button(*args, **kwargs, &block)
|
37
|
+
href, content = if block
|
38
|
+
[args.first, nil]
|
39
|
+
else
|
40
|
+
(args.size == 1) ? [nil, args.first] : args[0..2].reverse!
|
41
|
+
end
|
42
|
+
|
43
|
+
button = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params)
|
44
|
+
"Coco::ButtonTo"
|
45
|
+
else
|
46
|
+
"Coco::Button"
|
47
|
+
end
|
48
|
+
|
49
|
+
component = button.constantize.new(href: href, **kwargs)
|
50
|
+
component = component.with_content(content) if !block && content.present?
|
51
|
+
|
52
|
+
render(component, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
def coco_button_group(**, &block)
|
56
|
+
render Coco::ButtonGroup.new(**), &block
|
34
57
|
end
|
35
58
|
|
36
59
|
def coco_modal(name = "default", **, &block)
|
@@ -22,7 +22,7 @@ module Coco
|
|
22
22
|
html_options ||= {}
|
23
23
|
html_options.symbolize_keys!
|
24
24
|
|
25
|
-
button = Coco::
|
25
|
+
button = Coco::ButtonTo.new(action: options, type: :submit, **html_options)
|
26
26
|
button = button.with_content(name) unless block
|
27
27
|
render(button, &block)
|
28
28
|
end
|
@@ -12,7 +12,7 @@ module.exports = merge(baseConfig, {
|
|
12
12
|
fontFamily: {
|
13
13
|
display: [fontFamily.displaySans, ...defaultTheme.fontFamily.sans],
|
14
14
|
body: [fontFamily.bodySans, ...defaultTheme.fontFamily.sans],
|
15
|
-
|
15
|
+
branded: [fontFamily.displaySerif, ...defaultTheme.fontFamily.serif],
|
16
16
|
},
|
17
17
|
extend: {
|
18
18
|
fontSize,
|
@@ -12,6 +12,7 @@ module.exports = merge(baseConfig, {
|
|
12
12
|
fontFamily: {
|
13
13
|
display: [fontFamily.displaySans, ...defaultTheme.fontFamily.sans],
|
14
14
|
body: [fontFamily.bodySans, ...defaultTheme.fontFamily.sans],
|
15
|
+
branded: [fontFamily.displaySerif, ...defaultTheme.fontFamily.serif],
|
15
16
|
},
|
16
17
|
extend: {
|
17
18
|
fontSize,
|
data/config/tokens.cjs
CHANGED
@@ -199,11 +199,16 @@ const fontSize = {
|
|
199
199
|
"display-3": ["64px", "68px"],
|
200
200
|
"display-4": ["48px", "52px"],
|
201
201
|
|
202
|
-
"
|
203
|
-
"
|
204
|
-
"
|
202
|
+
"relaxed-display-1": ["96px", "104px"],
|
203
|
+
"relaxed-display-2": ["80px", "88px"],
|
204
|
+
"relaxed-display-3": ["64px", "72px"],
|
205
|
+
"relaxed-display-4": ["48px", "56px"],
|
206
|
+
|
207
|
+
"heading-1": ["40px", "48px"],
|
208
|
+
"heading-2": ["32px", "40px"],
|
209
|
+
"heading-3": ["28px", "36px"],
|
205
210
|
"heading-4": ["24px", "30px"],
|
206
|
-
"heading-5": ["20px", "
|
211
|
+
"heading-5": ["20px", "24px"],
|
207
212
|
"heading-6": ["16px", "20px"],
|
208
213
|
|
209
214
|
"subheading-1": ["32px", "40px"],
|