coveragebook_components 0.7.9 → 0.8.0.beta.1
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 +1134 -165
- data/app/assets/build/coco/app.js +307 -49
- data/app/assets/build/coco/book.css +55 -9
- data/app/assets/build/coco/book.js +24 -2
- data/app/assets/css/app/tippy.css +4 -0
- data/app/assets/css/base/base.css +12 -0
- data/app/assets/css/base/components/coco.css +0 -3
- data/app/assets/js/app/setup.js +22 -0
- data/app/assets/js/app.js +2 -0
- data/app/assets/js/helpers/location.js +9 -0
- data/app/assets/js/libs/tippy/index.js +7 -2
- data/app/components/coco/app/blocks/header/header.css +43 -0
- data/app/components/coco/app/blocks/header/header.html.erb +30 -0
- data/app/components/coco/app/blocks/header/header.js +11 -0
- data/app/components/coco/app/blocks/header/header.rb +35 -0
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.css +48 -3
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.html.erb +14 -6
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.js +18 -1
- data/app/components/coco/app/blocks/nav_drawer/nav_drawer.rb +26 -1
- data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.css +104 -0
- data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.html.erb +42 -0
- data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.js +28 -0
- data/app/components/coco/app/blocks/sidebar_nav/sidebar_nav.rb +28 -0
- data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.css +165 -0
- data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.html.erb +43 -0
- data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.js +41 -0
- data/app/components/coco/app/blocks/sidebar_nav_item/sidebar_nav_item.rb +98 -0
- data/app/components/coco/app/elements/alert/alert.css +65 -18
- data/app/components/coco/app/elements/alert/alert.html.erb +20 -5
- data/app/components/coco/app/elements/alert/alert.js +4 -3
- data/app/components/coco/app/elements/alert/alert.rb +16 -6
- data/app/components/coco/app/elements/button/button.css +87 -5
- data/app/components/coco/app/elements/button/button.rb +3 -1
- data/app/components/coco/app/elements/button_group/button_group.rb +4 -0
- data/app/components/coco/app/elements/button_to/button_to.css +5 -1
- data/app/components/coco/app/elements/button_to/button_to.rb +8 -1
- data/app/components/coco/app/elements/color_picker/color_picker.rb +1 -1
- data/app/components/coco/app/elements/menu/menu.css +5 -0
- data/app/components/coco/app/elements/menu/menu.html.erb +1 -1
- data/app/components/coco/app/elements/menu/menu.rb +2 -1
- data/app/components/coco/app/elements/menu_button/menu_button.html.erb +6 -0
- data/app/components/coco/app/elements/menu_button/menu_button.rb +8 -9
- data/app/components/coco/app/elements/menu_items/user_profile/user_profile.css +22 -0
- data/app/components/coco/app/elements/menu_items/user_profile/user_profile.html.erb +17 -0
- data/app/components/coco/app/elements/menu_items/user_profile/user_profile.rb +20 -0
- data/app/components/coco/app/elements/notice/notice.css +4 -0
- data/app/components/coco/app/elements/notice/notice.rb +2 -2
- data/app/components/coco/app/elements/snackbar/snackbar.css +8 -1
- data/app/components/coco/app/elements/snackbar/snackbar.rb +2 -2
- data/app/components/coco/app/elements/system_banner/system_banner.html.erb +2 -1
- data/app/components/coco/app/elements/system_banner/system_banner.js +35 -2
- data/app/components/coco/app/elements/system_banner/system_banner.rb +47 -3
- data/app/components/coco/app/layouts/application/application.css +104 -4
- data/app/components/coco/app/layouts/application/application.html.erb +28 -7
- data/app/components/coco/app/layouts/application/application.js +16 -0
- data/app/components/coco/app/layouts/application/application.rb +11 -3
- data/app/components/coco/base/avatar/avatar.css +25 -0
- data/app/components/coco/base/avatar/avatar.rb +20 -0
- data/app/components/coco/base/icon/icon.css +6 -2
- data/app/components/coco/base/icon/icon.rb +1 -1
- data/app/components/coco/base/modal/modal.css +2 -1
- data/app/components/coco/base/modal/modal.html.erb +1 -1
- data/app/components/coco/base/modal/modal.js +2 -0
- data/app/components/coco/base/modal_lightbox/modal_lightbox.js +2 -2
- data/app/components/coco/base/placeholder/placeholder.css +15 -1
- data/app/components/coco/base/placeholder/placeholder.rb +2 -0
- data/app/components/coco/concerns/accepts_tag_attributes.rb +6 -2
- data/app/components/coco/concerns/acts_as_button_group.rb +30 -12
- data/app/helpers/coco/app_helper.rb +26 -2
- data/app/helpers/coco/base_helper.rb +6 -0
- data/app/helpers/coco/url_helper.rb +5 -1
- data/config/tailwind.base.config.cjs +3 -0
- data/config/tokens.cjs +6 -0
- data/lib/coco.rb +1 -1
- metadata +24 -10
- data/app/components/coco/app/blocks/banner/banner.css +0 -5
- data/app/components/coco/app/blocks/banner/banner.rb +0 -8
- data/app/components/coco/app/blocks/nav_bar/nav_bar.css +0 -51
- data/app/components/coco/app/blocks/nav_bar/nav_bar.html.erb +0 -23
- data/app/components/coco/app/blocks/nav_bar/nav_bar.js +0 -31
- data/app/components/coco/app/blocks/nav_bar/nav_bar.rb +0 -19
@@ -0,0 +1,165 @@
|
|
1
|
+
@layer components {
|
2
|
+
[data-coco][data-component="app-sidebar-nav-item"] {
|
3
|
+
@apply bg-background-dark-2 text-content-dark-muted text-center no-underline transition-colors flex-none;
|
4
|
+
@apply flex items-center justify-center px-4 w-full flex-col;
|
5
|
+
|
6
|
+
&[href] {
|
7
|
+
@apply hover:text-content-light-1;
|
8
|
+
}
|
9
|
+
|
10
|
+
.nav-item-icon {
|
11
|
+
@apply block mx-auto transition-colors;
|
12
|
+
@apply w-6 h-6;
|
13
|
+
}
|
14
|
+
|
15
|
+
.nav-item-label {
|
16
|
+
@apply block font-semibold text-label-xxs transition-colors mt-0.5;
|
17
|
+
}
|
18
|
+
|
19
|
+
&.emphasised {
|
20
|
+
.nav-item-icon {
|
21
|
+
@apply sm:text-content-primary-inverse-vivid;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&.active {
|
26
|
+
@apply text-content-light-1;
|
27
|
+
}
|
28
|
+
|
29
|
+
&:hover {
|
30
|
+
.nav-item-icon {
|
31
|
+
@apply text-content-light-1;
|
32
|
+
}
|
33
|
+
|
34
|
+
&.emphasised .nav-item-icon {
|
35
|
+
@apply sm:text-content-primary-inverse-vivid;
|
36
|
+
}
|
37
|
+
|
38
|
+
.nav-item-label {
|
39
|
+
@apply text-content-light-1;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
@media screen(sm) {
|
44
|
+
@apply sidebar-nav-item-vertical-condensed;
|
45
|
+
}
|
46
|
+
|
47
|
+
@media screen(md) {
|
48
|
+
@apply sidebar-nav-item-vertical;
|
49
|
+
}
|
50
|
+
|
51
|
+
@media screen(letterbox) {
|
52
|
+
@apply sidebar-nav-item-vertical-condensed;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
.sidebar-nav-menu {
|
57
|
+
@apply bg-content-dark-2 shadow-md sm:rounded-r-md overflow-hidden divide-y divide-content-dark-muted/20;
|
58
|
+
|
59
|
+
[data-placement="bottom"] & {
|
60
|
+
@apply rounded-b-md;
|
61
|
+
}
|
62
|
+
|
63
|
+
[data-placement="top"] & {
|
64
|
+
@apply rounded-t-md;
|
65
|
+
}
|
66
|
+
|
67
|
+
.sidebar-nav-menu-select {
|
68
|
+
@apply focus:ring-0 bg-transparent hover:bg-content-dark-1 active:bg-content-dark-1 border-0 text-content-light-2 w-full font-semibold;
|
69
|
+
}
|
70
|
+
|
71
|
+
.sidebar-nav-menu-item {
|
72
|
+
@apply flex w-full items-center p-3 text-center no-underline bg-content-dark-2 text-content-dark-muted transition;
|
73
|
+
}
|
74
|
+
|
75
|
+
.coco-link.sidebar-nav-menu-item {
|
76
|
+
@apply hover:bg-content-dark-1;
|
77
|
+
}
|
78
|
+
|
79
|
+
.sidebar-nav-menu-item-text {
|
80
|
+
@apply truncate min-w-0 font-semibold text-content-light-1 transition-colors;
|
81
|
+
}
|
82
|
+
|
83
|
+
.sidebar-nav-menu-item-qualifier {
|
84
|
+
@apply ml-auto text-label-sm flex-none pl-4;
|
85
|
+
}
|
86
|
+
|
87
|
+
@apply sidebar-nav-menu-large;
|
88
|
+
|
89
|
+
@media screen(sm) {
|
90
|
+
@apply sidebar-nav-menu-small;
|
91
|
+
}
|
92
|
+
|
93
|
+
@media screen(md) {
|
94
|
+
@apply sidebar-nav-menu-large;
|
95
|
+
}
|
96
|
+
|
97
|
+
@media screen(letterbox) {
|
98
|
+
@apply sidebar-nav-menu-small;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
@layer utilities {
|
104
|
+
.sidebar-nav-item-vertical-condensed {
|
105
|
+
@apply block px-2 py-4;
|
106
|
+
|
107
|
+
&[href] {
|
108
|
+
@apply hover:bg-content-dark-1;
|
109
|
+
}
|
110
|
+
|
111
|
+
.nav-item-icon {
|
112
|
+
@apply w-7 h-7;
|
113
|
+
}
|
114
|
+
|
115
|
+
.nav-item-label {
|
116
|
+
@apply mt-1 text-label-xxs;
|
117
|
+
}
|
118
|
+
|
119
|
+
&.active {
|
120
|
+
@apply bg-background-dark-3 hover:bg-background-dark-3 text-content-light-1;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
.sidebar-nav-item-vertical {
|
125
|
+
@apply py-5;
|
126
|
+
|
127
|
+
&[href] {
|
128
|
+
@apply hover:bg-content-dark-1;
|
129
|
+
}
|
130
|
+
|
131
|
+
.nav-item-icon {
|
132
|
+
@apply w-8 h-8;
|
133
|
+
}
|
134
|
+
|
135
|
+
.nav-item-label {
|
136
|
+
@apply text-label-xs;
|
137
|
+
}
|
138
|
+
|
139
|
+
&.active {
|
140
|
+
@apply bg-background-dark-3 hover:bg-background-dark-3 text-content-light-1;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
.sidebar-nav-menu-small {
|
145
|
+
.sidebar-nav-menu-select {
|
146
|
+
@apply text-sm;
|
147
|
+
}
|
148
|
+
|
149
|
+
.sidebar-nav-menu-item {
|
150
|
+
@apply text-sm;
|
151
|
+
width: 240px;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
.sidebar-nav-menu-large {
|
156
|
+
.sidebar-nav-menu-select {
|
157
|
+
@apply text-base;
|
158
|
+
}
|
159
|
+
|
160
|
+
.sidebar-nav-menu-item {
|
161
|
+
@apply text-base;
|
162
|
+
width: 280px;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%= render component_tag(
|
2
|
+
x: {
|
3
|
+
data: "appSidebarNavItem",
|
4
|
+
"on:click": "if (menu) $event.preventDefault()"
|
5
|
+
},
|
6
|
+
class: {
|
7
|
+
active: active?,
|
8
|
+
emphasised: emphasise?
|
9
|
+
}) do %>
|
10
|
+
<%= icon %>
|
11
|
+
<label class="nav-item-label">
|
12
|
+
<%= label %>
|
13
|
+
</label>
|
14
|
+
<% if menu? || menu_items? %>
|
15
|
+
<template x-ref="menu">
|
16
|
+
<div class="sidebar-nav-menu" x-cloak>
|
17
|
+
<% if menu? %>
|
18
|
+
<%= menu %>
|
19
|
+
<% else %>
|
20
|
+
<%= safe_join(menu_items) %>
|
21
|
+
|
22
|
+
<% if dropdown_menu_items.any? %>
|
23
|
+
<select
|
24
|
+
x-data
|
25
|
+
class="sidebar-nav-menu-select"
|
26
|
+
@change="$dispatch('navigate', {url: $el.value})">
|
27
|
+
<% if menu_select_placeholder.present? %>
|
28
|
+
<option disabled="disabled" selected="selected"><%= menu_select_placeholder %></option>
|
29
|
+
<% end %>
|
30
|
+
<% dropdown_menu_items.each do |item| %>
|
31
|
+
<option value="<%= item[:href] %>">
|
32
|
+
<%= item[:label] %> <%= "(#{item[:qualifier]})" if item[:qualifier].present? %>
|
33
|
+
</option>
|
34
|
+
<% end %>
|
35
|
+
</select>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= menu_action %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
</template>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import tippy from "@libs/tippy";
|
2
|
+
import { CocoComponent } from "@js/coco";
|
3
|
+
|
4
|
+
export default CocoComponent("appSidebarNavItem", () => {
|
5
|
+
return {
|
6
|
+
menu: null,
|
7
|
+
|
8
|
+
init() {
|
9
|
+
if (this.$refs.menu) {
|
10
|
+
this.menu = tippy(this.$el, {
|
11
|
+
theme: "coco-naked-dropdown",
|
12
|
+
placement: this.menuPlacement,
|
13
|
+
arrow: false,
|
14
|
+
offset: [0, 0],
|
15
|
+
trigger: "click",
|
16
|
+
interactive: true,
|
17
|
+
maxWidth: null,
|
18
|
+
content: () => {
|
19
|
+
return this.$refs.menu.innerHTML;
|
20
|
+
},
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
this.$watch("mobileLayout", () => {
|
25
|
+
this.onOrientationChange();
|
26
|
+
});
|
27
|
+
},
|
28
|
+
|
29
|
+
onOrientationChange() {
|
30
|
+
if (this.menu) {
|
31
|
+
this.menu.setProps({
|
32
|
+
placement: this.menuPlacement,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
},
|
36
|
+
|
37
|
+
get menuPlacement() {
|
38
|
+
return this.mobileLayout ? "top" : "right-start";
|
39
|
+
},
|
40
|
+
};
|
41
|
+
});
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Coco
|
2
|
+
module App
|
3
|
+
module Blocks
|
4
|
+
class SidebarNavItem < Coco::Component
|
5
|
+
tag_name :a
|
6
|
+
tag_attr :href
|
7
|
+
|
8
|
+
renders_one :icon
|
9
|
+
renders_one :menu
|
10
|
+
|
11
|
+
renders_many :menu_items, ->(label, href, **kwargs) do
|
12
|
+
data = {label: label, href: href, **kwargs}
|
13
|
+
if menu_items.size < max_menu_items
|
14
|
+
SidebarNavMenuItem.new(**data)
|
15
|
+
else
|
16
|
+
dropdown_menu_items << data
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
renders_one :menu_action, ->(*args, **kwargs, &block) do
|
22
|
+
tag.div class: "sidebar-nav-menu-item" do
|
23
|
+
coco_button(*args, theme: :primary, size: :sm, fit: :full, **kwargs, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
before_render do
|
28
|
+
if @icon && !icon?
|
29
|
+
with_icon do
|
30
|
+
tag.span(class: "nav-item-icon") do
|
31
|
+
coco_icon(@icon, size: :full)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_reader :label, :tooltip, :dropdown_menu_items, :max_menu_items
|
38
|
+
|
39
|
+
def initialize(label:, icon: nil, emphasise: false, active: false, tooltip: nil, menu_select_placeholder: nil, max_menu_items: 6, **)
|
40
|
+
@label = label
|
41
|
+
@icon = icon
|
42
|
+
@emphasise = emphasise
|
43
|
+
@tooltip = tooltip
|
44
|
+
@active = active
|
45
|
+
@max_menu_items = max_menu_items
|
46
|
+
@menu_select_placeholder = menu_select_placeholder
|
47
|
+
@dropdown_menu_items = []
|
48
|
+
end
|
49
|
+
|
50
|
+
def tooltip?
|
51
|
+
tooltip.present?
|
52
|
+
end
|
53
|
+
|
54
|
+
def active?
|
55
|
+
@active == true
|
56
|
+
end
|
57
|
+
|
58
|
+
def emphasise?
|
59
|
+
@emphasise == true
|
60
|
+
end
|
61
|
+
|
62
|
+
def menu_select_placeholder
|
63
|
+
@menu_select_placeholder || "More items..."
|
64
|
+
end
|
65
|
+
|
66
|
+
class SidebarNavMenuItem < Coco::Component
|
67
|
+
attr_reader :icon, :href, :modal
|
68
|
+
|
69
|
+
def initialize(label:, href:, icon: nil, modal: nil, qualifier: nil, **)
|
70
|
+
@label = label
|
71
|
+
@href = href
|
72
|
+
@icon = icon
|
73
|
+
@modal = modal
|
74
|
+
@qualifier = qualifier
|
75
|
+
end
|
76
|
+
|
77
|
+
def call
|
78
|
+
coco_link(href, theme: nil, modal: modal, class: "sidebar-nav-menu-item") do
|
79
|
+
label
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def label
|
84
|
+
tag.span(@label, class: "sidebar-nav-menu-item-text") + qualifier
|
85
|
+
end
|
86
|
+
|
87
|
+
def qualifier
|
88
|
+
if @icon || @qualifier
|
89
|
+
tag.span(class: "sidebar-nav-menu-item-qualifier") do
|
90
|
+
@icon ? coco_icon(icon, size: :sm) : @qualifier
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
@apply rounded-xl overflow-hidden border border-transparent @container;
|
4
4
|
|
5
5
|
.alert-container {
|
6
|
-
@apply flex items-start
|
6
|
+
@apply flex items-start px-4 py-2 relative;
|
7
7
|
}
|
8
8
|
|
9
9
|
.alert-icon {
|
@@ -23,7 +23,7 @@
|
|
23
23
|
}
|
24
24
|
|
25
25
|
.alert-title {
|
26
|
-
@apply text-
|
26
|
+
@apply text-heading-6 font-bold;
|
27
27
|
}
|
28
28
|
|
29
29
|
.alert-message {
|
@@ -34,10 +34,6 @@
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
37
|
-
&.with-title .alert-message {
|
38
|
-
@apply mt-1;
|
39
|
-
}
|
40
|
-
|
41
37
|
.alert-actions {
|
42
38
|
@apply space-x-1 flex items-center;
|
43
39
|
}
|
@@ -56,7 +52,7 @@
|
|
56
52
|
@apply rounded-none;
|
57
53
|
|
58
54
|
.alert-container {
|
59
|
-
@apply @[1000px]:justify-center;
|
55
|
+
@apply @[1000px]:justify-center px-app;
|
60
56
|
}
|
61
57
|
|
62
58
|
.alert-body {
|
@@ -71,14 +67,36 @@
|
|
71
67
|
@apply flex-none;
|
72
68
|
|
73
69
|
.coco-button .button-element {
|
74
|
-
@apply text-content-dark-2 hover:text-content-dark-1;
|
70
|
+
@apply text-content-dark-2 hover:text-content-dark-1 bg-transparent hover:bg-white/10 transition;
|
75
71
|
}
|
76
72
|
}
|
77
73
|
}
|
78
74
|
|
75
|
+
/* Condensed */
|
76
|
+
|
77
|
+
&[data-condensed="true"] {
|
78
|
+
.alert-icon {
|
79
|
+
.coco-icon {
|
80
|
+
@apply w-4 h-4;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
.alert-body {
|
85
|
+
@apply pl-3;
|
86
|
+
}
|
87
|
+
|
88
|
+
.alert-title {
|
89
|
+
@apply text-para-sm;
|
90
|
+
}
|
91
|
+
|
92
|
+
.alert-message {
|
93
|
+
@apply text-para-sm;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
79
97
|
/* Layout */
|
80
98
|
|
81
|
-
@apply app-alert-stacked @[
|
99
|
+
@apply app-alert-stacked @[576px]:app-alert-multi-line;
|
82
100
|
|
83
101
|
&[data-single-line="true"]:not(.force-multi-line) {
|
84
102
|
@apply @[1000px]:app-alert-single-line;
|
@@ -95,7 +113,7 @@
|
|
95
113
|
}
|
96
114
|
|
97
115
|
&[data-theme*="vivid"] {
|
98
|
-
@apply border-none;
|
116
|
+
@apply border-none antialiased;
|
99
117
|
|
100
118
|
.alert-content {
|
101
119
|
@apply text-content-light-1;
|
@@ -186,13 +204,16 @@
|
|
186
204
|
|
187
205
|
@layer utilities {
|
188
206
|
.app-alert-stacked {
|
189
|
-
.alert-
|
190
|
-
|
191
|
-
margin-bottom: 2px;
|
207
|
+
.alert-container {
|
208
|
+
@apply py-4;
|
192
209
|
}
|
193
210
|
|
194
211
|
.alert-actions {
|
195
|
-
@apply mt-
|
212
|
+
@apply mt-3;
|
213
|
+
}
|
214
|
+
|
215
|
+
&.with-title .alert-message {
|
216
|
+
@apply mt-1;
|
196
217
|
}
|
197
218
|
|
198
219
|
&[data-dismissable="true"] {
|
@@ -208,7 +229,7 @@
|
|
208
229
|
|
209
230
|
.app-alert-multi-line {
|
210
231
|
.alert-container {
|
211
|
-
@apply items-center;
|
232
|
+
@apply items-center py-2.5;
|
212
233
|
}
|
213
234
|
|
214
235
|
.alert-icon {
|
@@ -227,22 +248,34 @@
|
|
227
248
|
margin-bottom: 0;
|
228
249
|
}
|
229
250
|
|
251
|
+
&.with-title .alert-message {
|
252
|
+
@apply mt-1;
|
253
|
+
}
|
254
|
+
|
255
|
+
&[data-condensed="true"].with-title .alert-message {
|
256
|
+
@apply mt-0.5;
|
257
|
+
}
|
258
|
+
|
230
259
|
.alert-actions {
|
231
260
|
@apply mt-0 ml-auto;
|
232
261
|
}
|
233
262
|
|
234
263
|
&[data-dismissable="true"] {
|
235
|
-
.alert-
|
236
|
-
@apply pr-
|
264
|
+
.alert-body {
|
265
|
+
@apply pr-10;
|
237
266
|
}
|
238
267
|
|
239
268
|
.alert-dismiss {
|
240
|
-
@apply
|
269
|
+
@apply absolute right-3 top-1/2 -translate-y-1/2;
|
241
270
|
}
|
242
271
|
}
|
243
272
|
}
|
244
273
|
|
245
274
|
.app-alert-single-line {
|
275
|
+
.alert-container {
|
276
|
+
@apply py-3;
|
277
|
+
}
|
278
|
+
|
246
279
|
.alert-content {
|
247
280
|
@apply flex items-center w-full space-x-2;
|
248
281
|
}
|
@@ -251,8 +284,22 @@
|
|
251
284
|
@apply whitespace-nowrap;
|
252
285
|
}
|
253
286
|
|
287
|
+
&.with-title .alert-message {
|
288
|
+
@apply mt-0;
|
289
|
+
}
|
290
|
+
|
254
291
|
.alert-link {
|
255
292
|
@apply hidden;
|
256
293
|
}
|
294
|
+
|
295
|
+
&[data-dismissable="true"] {
|
296
|
+
.alert-container {
|
297
|
+
@apply px-12;
|
298
|
+
}
|
299
|
+
|
300
|
+
.alert-dismiss {
|
301
|
+
@apply absolute right-[21px] top-1/2 -translate-y-1/2;
|
302
|
+
}
|
303
|
+
}
|
257
304
|
}
|
258
305
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%= render component_tag(x: {
|
2
2
|
data: "appAlert",
|
3
|
-
show: "!dismissed",
|
4
3
|
bind: "root",
|
5
|
-
|
4
|
+
show: "!dismissed",
|
5
|
+
cloak: (true if cloak?)
|
6
6
|
}, class: {
|
7
7
|
"with-title": title?,
|
8
8
|
"vivid": vivid?
|
@@ -24,7 +24,12 @@
|
|
24
24
|
|
25
25
|
<% if link? %>
|
26
26
|
<div class="alert-link" data-role="link">
|
27
|
-
<%=
|
27
|
+
<%= helpers.coco_link(
|
28
|
+
*@link_data[:args],
|
29
|
+
**@link_data[:kwargs],
|
30
|
+
size: :sm,
|
31
|
+
&@link_data[:block]
|
32
|
+
) %>
|
28
33
|
</div>
|
29
34
|
<% end %>
|
30
35
|
</div>
|
@@ -36,7 +41,12 @@
|
|
36
41
|
x-ref="action"
|
37
42
|
@click="dismiss"
|
38
43
|
data-role="action">
|
39
|
-
<%=
|
44
|
+
<%= coco_button(
|
45
|
+
*@action_data[:args],
|
46
|
+
**@action_data[:kwargs],
|
47
|
+
size: button_size,
|
48
|
+
&@action_data[:block]
|
49
|
+
) %>
|
40
50
|
</div>
|
41
51
|
<% end %>
|
42
52
|
|
@@ -45,7 +55,12 @@
|
|
45
55
|
x-ref="secondaryAction"
|
46
56
|
@click="dismiss"
|
47
57
|
data-role="secondary-action">
|
48
|
-
<%=
|
58
|
+
<%= coco_button(
|
59
|
+
*@secondary_action_data[:args],
|
60
|
+
**@secondary_action_data[:kwargs],
|
61
|
+
size: button_size,
|
62
|
+
&@secondary_action_data[:block]
|
63
|
+
) %>
|
49
64
|
</div>
|
50
65
|
<% end %>
|
51
66
|
</div>
|
@@ -21,18 +21,19 @@ export default CocoComponent("appAlert", () => {
|
|
21
21
|
},
|
22
22
|
|
23
23
|
remove() {
|
24
|
+
this.$nextTick(() => this.$dispatch("alert:removed", { alert: this }));
|
24
25
|
this.$root.remove();
|
25
26
|
},
|
26
27
|
|
27
28
|
checkSingleLineWrap({ height }) {
|
28
|
-
|
29
|
+
this.forceMultiLine = false;
|
30
|
+
this.$nextTick(() => {
|
29
31
|
this.forceMultiLine = height > 24 && this.$options.singleLine;
|
30
|
-
}
|
32
|
+
});
|
31
33
|
},
|
32
34
|
|
33
35
|
root: {
|
34
36
|
"x-options": '["dismissable", "singleLine"]',
|
35
|
-
"x-show": "!dismissed",
|
36
37
|
":class": "{'force-multi-line': forceMultiLine}",
|
37
38
|
},
|
38
39
|
};
|
@@ -22,22 +22,24 @@ module Coco
|
|
22
22
|
accepts_option :banner, from: [true, false], default: false
|
23
23
|
accepts_option :theme, from: THEMES, default: "info"
|
24
24
|
accepts_option :single_line, from: [true, false]
|
25
|
+
accepts_option :cloak, from: [true, false], default: true, private: true
|
26
|
+
accepts_option :condensed, from: [true, false], default: false
|
25
27
|
|
26
28
|
renders_one :title
|
27
29
|
|
28
|
-
renders_one :action, ->(**kwargs, &block) do
|
30
|
+
renders_one :action, ->(*args, **kwargs, &block) do
|
29
31
|
theme = vivid? ? "neutral-dark" : get_option_value(:theme)
|
30
|
-
|
32
|
+
@action_data = {args: args, kwargs: kwargs.merge(theme: theme), block: block}
|
31
33
|
end
|
32
34
|
|
33
|
-
renders_one :secondary_action, ->(**kwargs, &block) do
|
35
|
+
renders_one :secondary_action, ->(*args, **kwargs, &block) do
|
34
36
|
theme = vivid? ? "neutral-light" : "text-#{get_option_value(:theme)}"
|
35
|
-
|
37
|
+
@secondary_action_data = {args: args, kwargs: kwargs.merge(theme: theme), block: block}
|
36
38
|
end
|
37
39
|
|
38
|
-
renders_one :link, ->(**kwargs, &block) do
|
40
|
+
renders_one :link, ->(*args, **kwargs, &block) do
|
39
41
|
theme = vivid? ? nil : unvividify(get_option_value(:theme))
|
40
|
-
|
42
|
+
@link_data = {args: args, kwargs: kwargs.merge(theme: theme), block: block}
|
41
43
|
end
|
42
44
|
|
43
45
|
before_render do
|
@@ -58,6 +60,10 @@ module Coco
|
|
58
60
|
get_option_value(:single_line)
|
59
61
|
end
|
60
62
|
|
63
|
+
def cloak?
|
64
|
+
get_option_value(:cloak)
|
65
|
+
end
|
66
|
+
|
61
67
|
def vivid?
|
62
68
|
theme = get_option_value(:theme)
|
63
69
|
theme.to_s.match?(/vivid$/)
|
@@ -66,6 +72,10 @@ module Coco
|
|
66
72
|
def unvividify(theme)
|
67
73
|
theme.to_s.match?(/vivid$/) ? theme.to_s.underscore.gsub("_vivid", "").to_sym : theme
|
68
74
|
end
|
75
|
+
|
76
|
+
def button_size
|
77
|
+
get_option_value(:condensed) ? :xs : :sm
|
78
|
+
end
|
69
79
|
end
|
70
80
|
end
|
71
81
|
end
|