better_ui 0.3.0 → 0.5.1
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.
Potentially problematic release.
This version of better_ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +140 -230
- data/app/assets/stylesheets/better_ui/_base.scss +9 -0
- data/app/assets/stylesheets/better_ui/_components.scss +2 -0
- data/app/assets/stylesheets/better_ui/_utilities.scss +14 -0
- data/app/assets/stylesheets/better_ui/application.css +32 -0
- data/app/assets/stylesheets/better_ui/components/_avatar.scss +200 -0
- data/app/assets/stylesheets/better_ui/components/_badge.scss +154 -0
- data/app/assets/stylesheets/better_ui/components/_breadcrumb.scss +106 -0
- data/app/assets/stylesheets/better_ui/components/_button.scss +105 -0
- data/app/assets/stylesheets/better_ui/components/_card.scss +60 -0
- data/app/assets/stylesheets/better_ui/components/_heading.scss +81 -0
- data/app/assets/stylesheets/better_ui/components/_icon.scss +134 -0
- data/app/assets/stylesheets/better_ui/components/_index.scss +17 -0
- data/app/assets/stylesheets/better_ui/components/_link.scss +100 -0
- data/app/assets/stylesheets/better_ui/components/_panel.scss +104 -0
- data/app/assets/stylesheets/better_ui/components/_spinner.scss +129 -0
- data/app/assets/stylesheets/better_ui/components/_table.scss +156 -0
- data/app/assets/stylesheets/better_ui/components/_variables.scss +1 -0
- data/app/assets/stylesheets/better_ui.scss +4 -0
- data/app/components/better_ui/application/alert_component.html.erb +27 -0
- data/app/components/better_ui/application/alert_component.rb +202 -0
- data/app/components/better_ui/application/card_component.html.erb +24 -0
- data/app/components/better_ui/application/card_component.rb +53 -0
- data/app/components/better_ui/application/card_container_component.html.erb +8 -0
- data/app/components/better_ui/application/card_container_component.rb +14 -0
- data/app/components/better_ui/application/header_component.html.erb +88 -0
- data/app/components/better_ui/application/header_component.rb +188 -0
- data/app/components/better_ui/application/navbar_component.html.erb +294 -0
- data/app/components/better_ui/application/navbar_component.rb +249 -0
- data/app/components/better_ui/application/sidebar_component.html.erb +207 -0
- data/app/components/better_ui/application/sidebar_component.rb +318 -0
- data/app/components/better_ui/application/toast_component.html.erb +35 -0
- data/app/components/better_ui/application/toast_component.rb +223 -0
- data/app/components/better_ui/general/avatar_component.html.erb +19 -0
- data/app/components/better_ui/general/avatar_component.rb +171 -0
- data/app/components/better_ui/general/{badge/component.html.erb → badge_component.html.erb} +2 -6
- data/app/components/better_ui/general/badge_component.rb +135 -0
- data/app/components/better_ui/general/{breadcrumb/component.html.erb → breadcrumb_component.html.erb} +4 -4
- data/app/components/better_ui/general/breadcrumb_component.rb +130 -0
- data/app/components/better_ui/general/{button/component.html.erb → button_component.html.erb} +7 -7
- data/app/components/better_ui/general/button_component.rb +160 -0
- data/app/components/better_ui/general/heading_component.html.erb +1 -0
- data/app/components/better_ui/general/heading_component.rb +49 -0
- data/app/components/better_ui/general/icon_component.html.erb +2 -0
- data/app/components/better_ui/general/icon_component.rb +77 -0
- data/app/components/better_ui/general/link_component.html.erb +17 -0
- data/app/components/better_ui/general/link_component.rb +132 -0
- data/app/components/better_ui/general/panel_component.html.erb +27 -0
- data/app/components/better_ui/general/panel_component.rb +92 -0
- data/app/components/better_ui/general/spinner_component.html.erb +15 -0
- data/app/components/better_ui/general/spinner_component.rb +79 -0
- data/app/components/better_ui/general/table_component.html.erb +73 -0
- data/app/components/better_ui/general/table_component.rb +143 -0
- data/app/controllers/better_ui/application_controller.rb +1 -0
- data/app/helpers/better_ui/general/components/avatar_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/badge_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/breadcrumb_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/button_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/heading_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/icon_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/link_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/panel_helper.rb +16 -0
- data/app/helpers/better_ui/general/components/spinner_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/table_helper.rb +17 -0
- data/app/helpers/better_ui/general_helper.rb +15 -0
- data/app/helpers/better_ui_helper.rb +12 -0
- data/app/views/components/better_ui/general/table/_custom_body_row.html.erb +17 -0
- data/app/views/components/better_ui/general/table/_custom_footer_rows.html.erb +17 -0
- data/app/views/components/better_ui/general/table/_custom_header_rows.html.erb +12 -0
- data/app/views/layouts/component_preview.html.erb +32 -0
- data/config/initializers/lookbook.rb +12 -12
- data/config/routes.rb +2 -0
- data/lib/better_ui/engine.rb +92 -5
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +32 -4
- data/lib/generators/better_ui/install_generator.rb +103 -0
- data/lib/generators/better_ui/stylesheet_generator.rb +159 -0
- data/lib/generators/better_ui/templates/README +125 -0
- data/lib/generators/better_ui/templates/components/_avatar.scss +200 -0
- data/lib/generators/better_ui/templates/components/_badge.scss +154 -0
- data/lib/generators/better_ui/templates/components/_breadcrumb.scss +106 -0
- data/lib/generators/better_ui/templates/components/_button.scss +109 -0
- data/lib/generators/better_ui/templates/components/_card.scss +60 -0
- data/lib/generators/better_ui/templates/components/_heading.scss +81 -0
- data/lib/generators/better_ui/templates/components/_icon.scss +134 -0
- data/lib/generators/better_ui/templates/components/_index.scss +17 -0
- data/lib/generators/better_ui/templates/components/_link.scss +100 -0
- data/lib/generators/better_ui/templates/components/_panel.scss +104 -0
- data/lib/generators/better_ui/templates/components/_spinner.scss +129 -0
- data/lib/generators/better_ui/templates/components/_table.scss +156 -0
- data/lib/generators/better_ui/templates/components/_variables.scss +0 -0
- data/lib/generators/better_ui/templates/components_stylesheet.scss +35 -0
- data/lib/generators/better_ui/templates/index.scss +18 -0
- data/lib/generators/better_ui/templates/initializer.rb +41 -0
- metadata +178 -147
- data/app/components/better_ui/application/card/component.html.erb +0 -20
- data/app/components/better_ui/application/card/component.rb +0 -214
- data/app/components/better_ui/application/main/component.html.erb +0 -9
- data/app/components/better_ui/application/main/component.rb +0 -123
- data/app/components/better_ui/application/navbar/component.html.erb +0 -92
- data/app/components/better_ui/application/navbar/component.rb +0 -136
- data/app/components/better_ui/application/sidebar/component.html.erb +0 -227
- data/app/components/better_ui/application/sidebar/component.rb +0 -130
- data/app/components/better_ui/general/accordion/component.html.erb +0 -5
- data/app/components/better_ui/general/accordion/component.rb +0 -92
- data/app/components/better_ui/general/accordion/item_component.html.erb +0 -12
- data/app/components/better_ui/general/accordion/item_component.rb +0 -176
- data/app/components/better_ui/general/alert/component.html.erb +0 -32
- data/app/components/better_ui/general/alert/component.rb +0 -242
- data/app/components/better_ui/general/avatar/component.html.erb +0 -20
- data/app/components/better_ui/general/avatar/component.rb +0 -301
- data/app/components/better_ui/general/badge/component.rb +0 -248
- data/app/components/better_ui/general/breadcrumb/component.rb +0 -187
- data/app/components/better_ui/general/button/component.rb +0 -214
- data/app/components/better_ui/general/divider/component.html.erb +0 -10
- data/app/components/better_ui/general/divider/component.rb +0 -226
- data/app/components/better_ui/general/dropdown/component.html.erb +0 -25
- data/app/components/better_ui/general/dropdown/component.rb +0 -170
- data/app/components/better_ui/general/dropdown/divider_component.html.erb +0 -1
- data/app/components/better_ui/general/dropdown/divider_component.rb +0 -41
- data/app/components/better_ui/general/dropdown/item_component.html.erb +0 -6
- data/app/components/better_ui/general/dropdown/item_component.rb +0 -119
- data/app/components/better_ui/general/field/component.html.erb +0 -27
- data/app/components/better_ui/general/field/component.rb +0 -37
- data/app/components/better_ui/general/heading/component.html.erb +0 -22
- data/app/components/better_ui/general/heading/component.rb +0 -257
- data/app/components/better_ui/general/icon/component.html.erb +0 -7
- data/app/components/better_ui/general/icon/component.rb +0 -239
- data/app/components/better_ui/general/input/checkbox/component.html.erb +0 -5
- data/app/components/better_ui/general/input/checkbox/component.rb +0 -238
- data/app/components/better_ui/general/input/datetime/component.html.erb +0 -5
- data/app/components/better_ui/general/input/datetime/component.rb +0 -223
- data/app/components/better_ui/general/input/radio/component.html.erb +0 -5
- data/app/components/better_ui/general/input/radio/component.rb +0 -230
- data/app/components/better_ui/general/input/select/component.html.erb +0 -16
- data/app/components/better_ui/general/input/select/component.rb +0 -184
- data/app/components/better_ui/general/input/select/select_component.html.erb +0 -5
- data/app/components/better_ui/general/input/select/select_component.rb +0 -37
- data/app/components/better_ui/general/input/text/component.html.erb +0 -5
- data/app/components/better_ui/general/input/text/component.rb +0 -171
- data/app/components/better_ui/general/input/textarea/component.html.erb +0 -5
- data/app/components/better_ui/general/input/textarea/component.rb +0 -166
- data/app/components/better_ui/general/link/component.html.erb +0 -18
- data/app/components/better_ui/general/link/component.rb +0 -258
- data/app/components/better_ui/general/modal/component.html.erb +0 -5
- data/app/components/better_ui/general/modal/component.rb +0 -47
- data/app/components/better_ui/general/modal/modal_component.html.erb +0 -52
- data/app/components/better_ui/general/modal/modal_component.rb +0 -160
- data/app/components/better_ui/general/pagination/component.html.erb +0 -85
- data/app/components/better_ui/general/pagination/component.rb +0 -216
- data/app/components/better_ui/general/panel/component.html.erb +0 -28
- data/app/components/better_ui/general/panel/component.rb +0 -249
- data/app/components/better_ui/general/progress/component.html.erb +0 -11
- data/app/components/better_ui/general/progress/component.rb +0 -160
- data/app/components/better_ui/general/spinner/component.html.erb +0 -35
- data/app/components/better_ui/general/spinner/component.rb +0 -93
- data/app/components/better_ui/general/table/component.html.erb +0 -5
- data/app/components/better_ui/general/table/component.rb +0 -217
- data/app/components/better_ui/general/table/tbody_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tbody_component.rb +0 -30
- data/app/components/better_ui/general/table/td_component.html.erb +0 -3
- data/app/components/better_ui/general/table/td_component.rb +0 -44
- data/app/components/better_ui/general/table/tfoot_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tfoot_component.rb +0 -28
- data/app/components/better_ui/general/table/th_component.html.erb +0 -6
- data/app/components/better_ui/general/table/th_component.rb +0 -51
- data/app/components/better_ui/general/table/thead_component.html.erb +0 -3
- data/app/components/better_ui/general/table/thead_component.rb +0 -28
- data/app/components/better_ui/general/table/tr_component.html.erb +0 -3
- data/app/components/better_ui/general/table/tr_component.rb +0 -30
- data/app/components/better_ui/general/tabs/component.html.erb +0 -11
- data/app/components/better_ui/general/tabs/component.rb +0 -120
- data/app/components/better_ui/general/tabs/panel_component.html.erb +0 -3
- data/app/components/better_ui/general/tabs/panel_component.rb +0 -37
- data/app/components/better_ui/general/tabs/tab_component.html.erb +0 -13
- data/app/components/better_ui/general/tabs/tab_component.rb +0 -111
- data/app/components/better_ui/general/tag/component.html.erb +0 -3
- data/app/components/better_ui/general/tag/component.rb +0 -104
- data/app/components/better_ui/general/tooltip/component.html.erb +0 -7
- data/app/components/better_ui/general/tooltip/component.rb +0 -239
- data/app/helpers/better_ui/application/components/card/card_helper.rb +0 -96
- data/app/helpers/better_ui/application/components/card.rb +0 -11
- data/app/helpers/better_ui/application/components/main/main_helper.rb +0 -64
- data/app/helpers/better_ui/application/components/navbar/navbar_helper.rb +0 -77
- data/app/helpers/better_ui/application/components/sidebar/sidebar_helper.rb +0 -51
- data/app/helpers/better_ui/application_helper.rb +0 -55
- data/app/helpers/better_ui/general/components/accordion/accordion_helper.rb +0 -73
- data/app/helpers/better_ui/general/components/accordion.rb +0 -11
- data/app/helpers/better_ui/general/components/alert/alert_helper.rb +0 -57
- data/app/helpers/better_ui/general/components/avatar/avatar_helper.rb +0 -29
- data/app/helpers/better_ui/general/components/badge/badge_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/breadcrumb/breadcrumb_helper.rb +0 -37
- data/app/helpers/better_ui/general/components/button/button_helper.rb +0 -65
- data/app/helpers/better_ui/general/components/container/container_helper.rb +0 -60
- data/app/helpers/better_ui/general/components/divider/divider_helper.rb +0 -63
- data/app/helpers/better_ui/general/components/dropdown/divider_helper.rb +0 -32
- data/app/helpers/better_ui/general/components/dropdown/dropdown_helper.rb +0 -79
- data/app/helpers/better_ui/general/components/dropdown/item_helper.rb +0 -62
- data/app/helpers/better_ui/general/components/field/field_helper.rb +0 -26
- data/app/helpers/better_ui/general/components/heading/heading_helper.rb +0 -72
- data/app/helpers/better_ui/general/components/icon/icon_helper.rb +0 -16
- data/app/helpers/better_ui/general/components/input/checkbox/checkbox_helper.rb +0 -81
- data/app/helpers/better_ui/general/components/input/datetime/datetime_helper.rb +0 -91
- data/app/helpers/better_ui/general/components/input/radio/radio_helper.rb +0 -79
- data/app/helpers/better_ui/general/components/input/radio_group/radio_group_helper.rb +0 -124
- data/app/helpers/better_ui/general/components/input/select/select_helper.rb +0 -70
- data/app/helpers/better_ui/general/components/input/text/text_helper.rb +0 -138
- data/app/helpers/better_ui/general/components/input/textarea/textarea_helper.rb +0 -73
- data/app/helpers/better_ui/general/components/link/link_helper.rb +0 -89
- data/app/helpers/better_ui/general/components/modal/modal_helper.rb +0 -85
- data/app/helpers/better_ui/general/components/modal.rb +0 -11
- data/app/helpers/better_ui/general/components/pagination/pagination_helper.rb +0 -82
- data/app/helpers/better_ui/general/components/panel/panel_helper.rb +0 -83
- data/app/helpers/better_ui/general/components/progress/progress_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/spinner/spinner_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/table_helper.rb +0 -53
- data/app/helpers/better_ui/general/components/table/tbody_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/td_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/tfoot_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/th_helper.rb +0 -19
- data/app/helpers/better_ui/general/components/table/thead_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/table/tr_helper.rb +0 -13
- data/app/helpers/better_ui/general/components/tabs/panel_helper.rb +0 -62
- data/app/helpers/better_ui/general/components/tabs/tab_helper.rb +0 -55
- data/app/helpers/better_ui/general/components/tabs/tabs_helper.rb +0 -95
- data/app/helpers/better_ui/general/components/tag/tag_helper.rb +0 -26
- data/app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb +0 -60
- data/app/views/layouts/better_ui/application.html.erb +0 -17
- data/lib/better_ui/railtie.rb +0 -20
data/app/components/better_ui/general/{button/component.html.erb → button_component.html.erb}
RENAMED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
<% if link? %>
|
|
3
3
|
<%= link_to @href, **link_attributes do %>
|
|
4
4
|
<% if @icon && @icon_position == :left %>
|
|
5
|
-
<span class="
|
|
5
|
+
<span class="bui-button__icon bui-button__icon--left"><%= render_icon(@icon) %></span>
|
|
6
6
|
<% end %>
|
|
7
7
|
|
|
8
8
|
<% if @label %>
|
|
9
|
-
<span class="
|
|
9
|
+
<span class="bui-button__text"><%= @label %></span>
|
|
10
10
|
<% end %>
|
|
11
11
|
|
|
12
12
|
<% if @icon && @icon_position == :right %>
|
|
13
|
-
<span class="
|
|
13
|
+
<span class="bui-button__icon bui-button__icon--right"><%= render_icon(@icon) %></span>
|
|
14
14
|
<% end %>
|
|
15
15
|
|
|
16
16
|
<%= content %>
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
<% else %>
|
|
19
19
|
<%= tag.button(**button_attributes) do %>
|
|
20
20
|
<% if @icon && @icon_position == :left %>
|
|
21
|
-
<span class="
|
|
21
|
+
<span class="bui-button__icon bui-button__icon--left"><%= render_icon(@icon) %></span>
|
|
22
22
|
<% end %>
|
|
23
23
|
|
|
24
24
|
<% if @label %>
|
|
25
|
-
<span class="
|
|
25
|
+
<span class="bui-button__text"><%= @label %></span>
|
|
26
26
|
<% end %>
|
|
27
27
|
|
|
28
28
|
<% if @icon && @icon_position == :right %>
|
|
29
|
-
<span class="
|
|
29
|
+
<span class="bui-button__icon bui-button__icon--right"><%= render_icon(@icon) %></span>
|
|
30
30
|
<% end %>
|
|
31
31
|
|
|
32
32
|
<%= content %>
|
|
33
33
|
<% end %>
|
|
34
|
-
<% end %>
|
|
34
|
+
<% end %>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
module BetterUi
|
|
2
|
+
module General
|
|
3
|
+
class ButtonComponent < ViewComponent::Base
|
|
4
|
+
attr_reader :label, :type, :size, :full_width, :disabled,
|
|
5
|
+
:icon, :icon_position, :href, :method, :data, :classes, :id, :rounded
|
|
6
|
+
|
|
7
|
+
# Temi di bottoni disponibili con classi CSS personalizzate
|
|
8
|
+
BUTTON_THEME = {
|
|
9
|
+
default: "bui-button--default",
|
|
10
|
+
white: "bui-button--white",
|
|
11
|
+
red: "bui-button--red",
|
|
12
|
+
rose: "bui-button--rose",
|
|
13
|
+
orange: "bui-button--orange",
|
|
14
|
+
green: "bui-button--green",
|
|
15
|
+
blue: "bui-button--blue",
|
|
16
|
+
yellow: "bui-button--yellow",
|
|
17
|
+
violet: "bui-button--violet"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Dimensioni disponibili con classi CSS personalizzate
|
|
21
|
+
BUTTON_SIZES = {
|
|
22
|
+
small: "bui-button--small",
|
|
23
|
+
medium: "bui-button--medium",
|
|
24
|
+
large: "bui-button--large"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Border radius disponibili con classi CSS personalizzate
|
|
28
|
+
BUTTON_RADIUS = {
|
|
29
|
+
none: "bui-button--radius-none",
|
|
30
|
+
small: "bui-button--radius-small",
|
|
31
|
+
medium: "bui-button--radius-medium",
|
|
32
|
+
large: "bui-button--radius-large",
|
|
33
|
+
full: "bui-button--radius-full"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Stati e comportamenti del bottone
|
|
37
|
+
BUTTON_STATES = {
|
|
38
|
+
disabled: "bui-button--disabled",
|
|
39
|
+
full_width: "bui-button--full-width"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Layout e stili comuni
|
|
43
|
+
BUTTON_LAYOUT = {
|
|
44
|
+
default: "bui-btn-layout-default",
|
|
45
|
+
focus: "bui-btn-focus"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Inizializzazione del componente
|
|
49
|
+
def initialize(
|
|
50
|
+
label: nil,
|
|
51
|
+
type: :default,
|
|
52
|
+
size: :medium,
|
|
53
|
+
full_width: false,
|
|
54
|
+
disabled: false,
|
|
55
|
+
icon: nil,
|
|
56
|
+
icon_position: :left,
|
|
57
|
+
href: nil,
|
|
58
|
+
method: nil,
|
|
59
|
+
data: {},
|
|
60
|
+
classes: nil,
|
|
61
|
+
id: nil,
|
|
62
|
+
rounded: :small
|
|
63
|
+
)
|
|
64
|
+
@label = label
|
|
65
|
+
@type = type.to_sym
|
|
66
|
+
@size = size.to_sym
|
|
67
|
+
@full_width = full_width
|
|
68
|
+
@disabled = disabled
|
|
69
|
+
@icon = icon
|
|
70
|
+
@icon_position = icon_position.to_sym
|
|
71
|
+
@href = href
|
|
72
|
+
@method = method
|
|
73
|
+
@data = data
|
|
74
|
+
@classes = classes
|
|
75
|
+
@id = id
|
|
76
|
+
@rounded = rounded.to_sym
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Determina se il bottone è un link o un button
|
|
80
|
+
def link?
|
|
81
|
+
@href.present?
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Combina tutte le classi
|
|
85
|
+
def combined_classes
|
|
86
|
+
[
|
|
87
|
+
"bui-button", # Classe base per tutti i bottoni
|
|
88
|
+
get_border_radius_class,
|
|
89
|
+
get_button_type_classes,
|
|
90
|
+
get_button_size_classes,
|
|
91
|
+
@full_width ? BUTTON_STATES[:full_width] : "",
|
|
92
|
+
@disabled ? BUTTON_STATES[:disabled] : "",
|
|
93
|
+
@classes
|
|
94
|
+
].compact.join(" ")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def get_button_type_classes
|
|
98
|
+
BUTTON_THEME[@type] || BUTTON_THEME[:default]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def get_border_radius_class
|
|
102
|
+
BUTTON_RADIUS[@rounded] || BUTTON_RADIUS[:small]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def get_button_size_classes
|
|
106
|
+
BUTTON_SIZES[@size] || BUTTON_SIZES[:medium]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Restituisce gli attributi per il bottone
|
|
110
|
+
def button_attributes
|
|
111
|
+
attrs = {
|
|
112
|
+
class: combined_classes,
|
|
113
|
+
type: "button",
|
|
114
|
+
id: @id
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
attrs[:disabled] = true if @disabled
|
|
118
|
+
attrs[:data] = @data if @data.present?
|
|
119
|
+
attrs
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Restituisce gli attributi per il link
|
|
123
|
+
def link_attributes
|
|
124
|
+
attrs = {
|
|
125
|
+
class: combined_classes,
|
|
126
|
+
id: @id
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
attrs[:data] = @data.merge(turbo_method: @method) if @method.present?
|
|
130
|
+
attrs[:data] = @data if @data.present? && !@method.present?
|
|
131
|
+
attrs[:href] = @disabled ? nil : @href
|
|
132
|
+
attrs[:role] = "button"
|
|
133
|
+
attrs[:tabindex] = @disabled ? "-1" : "0"
|
|
134
|
+
attrs[:aria] = { disabled: @disabled } if @disabled
|
|
135
|
+
|
|
136
|
+
attrs
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Helper per renderizzare le icone
|
|
140
|
+
def render_icon(icon_name)
|
|
141
|
+
# Mappa le dimensioni del bottone alle dimensioni dell'icona
|
|
142
|
+
icon_size = case @size
|
|
143
|
+
when :large
|
|
144
|
+
:large
|
|
145
|
+
when :small
|
|
146
|
+
:small
|
|
147
|
+
else
|
|
148
|
+
:medium
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Utilizziamo il componente Icon
|
|
152
|
+
render BetterUi::General::IconComponent.new(
|
|
153
|
+
name: icon_name,
|
|
154
|
+
size: icon_size,
|
|
155
|
+
fixed_width: true
|
|
156
|
+
)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= content_tag("h#{@level}", content, class: heading_classes) %>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module BetterUi
|
|
2
|
+
module General
|
|
3
|
+
class HeadingComponent < ViewComponent::Base
|
|
4
|
+
attr_reader :level, :variant, :align, :classes
|
|
5
|
+
|
|
6
|
+
# Varianti di colore disponibili
|
|
7
|
+
HEADER_THEME = {
|
|
8
|
+
default: "bui-heading--default",
|
|
9
|
+
white: "bui-heading--white",
|
|
10
|
+
red: "bui-heading--red",
|
|
11
|
+
rose: "bui-heading--rose",
|
|
12
|
+
orange: "bui-heading--orange",
|
|
13
|
+
green: "bui-heading--green",
|
|
14
|
+
blue: "bui-heading--blue",
|
|
15
|
+
yellow: "bui-heading--yellow",
|
|
16
|
+
violet: "bui-heading--violet"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Allineamenti disponibili
|
|
20
|
+
HEADER_ALIGNMENTS = {
|
|
21
|
+
left: "bui-heading--left",
|
|
22
|
+
center: "bui-heading--center",
|
|
23
|
+
right: "bui-heading--right"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def initialize(
|
|
27
|
+
level: 2,
|
|
28
|
+
variant: :default,
|
|
29
|
+
align: :left,
|
|
30
|
+
classes: nil
|
|
31
|
+
)
|
|
32
|
+
@level = level.to_i.clamp(1, 6)
|
|
33
|
+
@variant = variant.to_sym
|
|
34
|
+
@align = align.to_sym
|
|
35
|
+
@classes = classes
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def heading_classes
|
|
39
|
+
[
|
|
40
|
+
"bui-heading",
|
|
41
|
+
"bui-heading--#{@level}",
|
|
42
|
+
HEADER_THEME.fetch(@variant, HEADER_THEME[:default]),
|
|
43
|
+
HEADER_ALIGNMENTS.fetch(@align, HEADER_ALIGNMENTS[:left]),
|
|
44
|
+
@classes
|
|
45
|
+
].compact.join(" ")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module BetterUi
|
|
2
|
+
module General
|
|
3
|
+
class IconComponent < ViewComponent::Base
|
|
4
|
+
# Dimensioni disponibili
|
|
5
|
+
ICON_SIZES = {
|
|
6
|
+
xsmall: "bui-icon--xs",
|
|
7
|
+
tiny: "bui-icon--xs",
|
|
8
|
+
small: "bui-icon--sm",
|
|
9
|
+
medium: "bui-icon--md",
|
|
10
|
+
large: "bui-icon--lg",
|
|
11
|
+
xlarge: "bui-icon--xl"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Colori disponibili
|
|
15
|
+
ICON_THEMES = {
|
|
16
|
+
default: "bui-icon--default",
|
|
17
|
+
white: "bui-icon--white",
|
|
18
|
+
red: "bui-icon--red",
|
|
19
|
+
rose: "bui-icon--rose",
|
|
20
|
+
orange: "bui-icon--orange",
|
|
21
|
+
green: "bui-icon--green",
|
|
22
|
+
blue: "bui-icon--blue",
|
|
23
|
+
yellow: "bui-icon--yellow",
|
|
24
|
+
violet: "bui-icon--violet"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Inizializzazione del componente
|
|
28
|
+
def initialize(
|
|
29
|
+
name:,
|
|
30
|
+
size: :medium,
|
|
31
|
+
color: :default,
|
|
32
|
+
fixed_width: false,
|
|
33
|
+
spin: false,
|
|
34
|
+
pulse: false,
|
|
35
|
+
solid: false,
|
|
36
|
+
solid_color: false,
|
|
37
|
+
classes: nil
|
|
38
|
+
)
|
|
39
|
+
@name = name.to_s.gsub('_', '-') # Convertiamo da snake_case a kebab-case per Font Awesome
|
|
40
|
+
@size = size.to_sym
|
|
41
|
+
@color = color.to_sym
|
|
42
|
+
@fixed_width = fixed_width
|
|
43
|
+
@spin = spin
|
|
44
|
+
@pulse = pulse
|
|
45
|
+
@solid = solid
|
|
46
|
+
@solid_color = solid_color
|
|
47
|
+
@classes = classes
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Classe CSS per il colore
|
|
51
|
+
def color_class
|
|
52
|
+
ICON_THEMES[@color] || ICON_THEMES[:default]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Classe CSS per la dimensione
|
|
56
|
+
def size_class
|
|
57
|
+
ICON_SIZES[@size] || ICON_SIZES[:medium]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Combinazione di tutte le classi
|
|
61
|
+
def combined_classes
|
|
62
|
+
[
|
|
63
|
+
"bui-icon",
|
|
64
|
+
"fa-#{@name}", # Questa classe deve rimanere specifica di Font Awesome
|
|
65
|
+
size_class,
|
|
66
|
+
color_class,
|
|
67
|
+
@fixed_width ? "bui-icon--fixed-width" : nil,
|
|
68
|
+
@spin ? "bui-icon--spin" : nil,
|
|
69
|
+
@pulse ? "bui-icon--pulse" : nil,
|
|
70
|
+
@solid ? "bui-icon--solid" : nil,
|
|
71
|
+
@solid_color ? "bui-icon--solid-primary" : nil,
|
|
72
|
+
@classes
|
|
73
|
+
].reject(&:blank?).join(" ")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<% if link? %>
|
|
2
|
+
<%= link_to href, **link_attributes do %>
|
|
3
|
+
<% if render_icon %>
|
|
4
|
+
<span class="bui-link__icon"><%= render_icon %></span>
|
|
5
|
+
<% end %>
|
|
6
|
+
<span class="bui-link__text"><%= label %></span>
|
|
7
|
+
<%= content if content.present? %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% else %>
|
|
10
|
+
<span class="<%= component_classes %>" <%= "aria-current='page'" if active? %>>
|
|
11
|
+
<% if render_icon %>
|
|
12
|
+
<span class="bui-link__icon"><%= render_icon %></span>
|
|
13
|
+
<% end %>
|
|
14
|
+
<span class="bui-link__text"><%= label %></span>
|
|
15
|
+
<%= content if content.present? %>
|
|
16
|
+
</span>
|
|
17
|
+
<% end %>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
module BetterUi
|
|
2
|
+
module General
|
|
3
|
+
class LinkComponent < ViewComponent::Base
|
|
4
|
+
attr_reader :label, :href, :theme, :icon, :classes, :active, :data, :method, :target
|
|
5
|
+
|
|
6
|
+
# Temi di colore disponibili
|
|
7
|
+
LINK_THEME = {
|
|
8
|
+
default: {
|
|
9
|
+
link: "bui-link--default",
|
|
10
|
+
active: "bui-link--active bui-link--default",
|
|
11
|
+
text: "bui-link--text bui-link--default"
|
|
12
|
+
},
|
|
13
|
+
white: {
|
|
14
|
+
link: "bui-link--white",
|
|
15
|
+
active: "bui-link--active bui-link--white",
|
|
16
|
+
text: "bui-link--text bui-link--white"
|
|
17
|
+
},
|
|
18
|
+
red: {
|
|
19
|
+
link: "bui-link--red",
|
|
20
|
+
active: "bui-link--active bui-link--red",
|
|
21
|
+
text: "bui-link--text bui-link--red"
|
|
22
|
+
},
|
|
23
|
+
rose: {
|
|
24
|
+
link: "bui-link--rose",
|
|
25
|
+
active: "bui-link--active bui-link--rose",
|
|
26
|
+
text: "bui-link--text bui-link--rose"
|
|
27
|
+
},
|
|
28
|
+
orange: {
|
|
29
|
+
link: "bui-link--orange",
|
|
30
|
+
active: "bui-link--active bui-link--orange",
|
|
31
|
+
text: "bui-link--text bui-link--orange"
|
|
32
|
+
},
|
|
33
|
+
green: {
|
|
34
|
+
link: "bui-link--green",
|
|
35
|
+
active: "bui-link--active bui-link--green",
|
|
36
|
+
text: "bui-link--text bui-link--green"
|
|
37
|
+
},
|
|
38
|
+
blue: {
|
|
39
|
+
link: "bui-link--blue",
|
|
40
|
+
active: "bui-link--active bui-link--blue",
|
|
41
|
+
text: "bui-link--text bui-link--blue"
|
|
42
|
+
},
|
|
43
|
+
yellow: {
|
|
44
|
+
link: "bui-link--yellow",
|
|
45
|
+
active: "bui-link--active bui-link--yellow",
|
|
46
|
+
text: "bui-link--text bui-link--yellow"
|
|
47
|
+
},
|
|
48
|
+
violet: {
|
|
49
|
+
link: "bui-link--violet",
|
|
50
|
+
active: "bui-link--active bui-link--violet",
|
|
51
|
+
text: "bui-link--text bui-link--violet"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# Inizializzazione del componente
|
|
56
|
+
def initialize(
|
|
57
|
+
label:,
|
|
58
|
+
href: nil,
|
|
59
|
+
theme: :default,
|
|
60
|
+
icon: nil,
|
|
61
|
+
classes: nil,
|
|
62
|
+
active: false,
|
|
63
|
+
data: {},
|
|
64
|
+
method: nil,
|
|
65
|
+
target: nil
|
|
66
|
+
)
|
|
67
|
+
@label = label
|
|
68
|
+
@href = href
|
|
69
|
+
@theme = theme.to_sym
|
|
70
|
+
@icon = icon
|
|
71
|
+
@classes = classes
|
|
72
|
+
@active = active
|
|
73
|
+
@data = data || {}
|
|
74
|
+
@method = method
|
|
75
|
+
@target = target
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Determina se è un link attivo/corrente
|
|
79
|
+
def active?
|
|
80
|
+
@active
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Determina se è un link o solo testo
|
|
84
|
+
def link?
|
|
85
|
+
@href.present?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Genera le classi per il componente
|
|
89
|
+
def component_classes
|
|
90
|
+
theme_classes = LINK_THEME.fetch(@theme, LINK_THEME[:default])
|
|
91
|
+
|
|
92
|
+
base_classes = ["bui-link"]
|
|
93
|
+
|
|
94
|
+
if active?
|
|
95
|
+
base_classes << theme_classes[:active]
|
|
96
|
+
elsif link?
|
|
97
|
+
base_classes << theme_classes[:link]
|
|
98
|
+
else
|
|
99
|
+
base_classes << theme_classes[:text]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
base_classes << @classes if @classes.present?
|
|
103
|
+
|
|
104
|
+
base_classes.compact.join(" ")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Restituisce gli attributi per il link
|
|
108
|
+
def link_attributes
|
|
109
|
+
attrs = {
|
|
110
|
+
class: component_classes
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
attrs[:data] = @data.merge(turbo_method: @method) if @method.present?
|
|
114
|
+
attrs[:data] = @data if @data.present? && !@method.present?
|
|
115
|
+
attrs[:target] = @target if @target.present?
|
|
116
|
+
|
|
117
|
+
attrs
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Renderizza l'icona
|
|
121
|
+
def render_icon
|
|
122
|
+
return nil unless @icon.present?
|
|
123
|
+
|
|
124
|
+
if @icon.is_a?(String)
|
|
125
|
+
render BetterUi::General::IconComponent.new(name: @icon)
|
|
126
|
+
else
|
|
127
|
+
@icon # Assumiamo che sia già un componente renderizzato
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<div class="<%= panel_classes %>">
|
|
2
|
+
<% if @header.present? %>
|
|
3
|
+
<div class="<%= header_classes %>">
|
|
4
|
+
<%= raw @header %>
|
|
5
|
+
</div>
|
|
6
|
+
<% elsif @title.present? %>
|
|
7
|
+
<div class="<%= header_classes %>">
|
|
8
|
+
<div class="<%= title_classes %>"><%= @title %></div>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<% if @body.present? %>
|
|
13
|
+
<div class="<%= body_classes %>">
|
|
14
|
+
<%= raw @body %>
|
|
15
|
+
</div>
|
|
16
|
+
<% elsif content.present? %>
|
|
17
|
+
<div class="<%= body_classes %>">
|
|
18
|
+
<%= content %>
|
|
19
|
+
</div>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<% if @footer.present? %>
|
|
23
|
+
<div class="<%= footer_classes %>">
|
|
24
|
+
<%= raw @footer %>
|
|
25
|
+
</div>
|
|
26
|
+
<% end %>
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module BetterUi
|
|
2
|
+
module General
|
|
3
|
+
class PanelComponent < ViewComponent::Base
|
|
4
|
+
attr_reader :header, :footer, :body, :title, :padding, :variant, :rounded
|
|
5
|
+
|
|
6
|
+
# Opzioni di padding disponibili
|
|
7
|
+
PANEL_PADDING = {
|
|
8
|
+
none: 'bui-panel--padding-none',
|
|
9
|
+
small: 'bui-panel--padding-small',
|
|
10
|
+
medium: 'bui-panel--padding-medium',
|
|
11
|
+
large: 'bui-panel--padding-large'
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
# Temi di colore per il panel
|
|
15
|
+
PANEL_THEME = {
|
|
16
|
+
default: 'bui-panel--default',
|
|
17
|
+
white: 'bui-panel--white',
|
|
18
|
+
red: 'bui-panel--red',
|
|
19
|
+
rose: 'bui-panel--rose',
|
|
20
|
+
orange: 'bui-panel--orange',
|
|
21
|
+
green: 'bui-panel--green',
|
|
22
|
+
blue: 'bui-panel--blue',
|
|
23
|
+
yellow: 'bui-panel--yellow',
|
|
24
|
+
violet: 'bui-panel--violet'
|
|
25
|
+
}.freeze
|
|
26
|
+
|
|
27
|
+
# Opzioni di bordi arrotondati standardizzati
|
|
28
|
+
PANEL_RADIUS = {
|
|
29
|
+
none: 'bui-panel--radius-none',
|
|
30
|
+
small: 'bui-panel--radius-small',
|
|
31
|
+
medium: 'bui-panel--radius-medium',
|
|
32
|
+
large: 'bui-panel--radius-large',
|
|
33
|
+
full: 'bui-panel--radius-full'
|
|
34
|
+
}.freeze
|
|
35
|
+
|
|
36
|
+
def initialize(title: nil, body: nil, header: nil, footer: nil, padding: :medium, variant: :default, rounded: :small)
|
|
37
|
+
@title = title
|
|
38
|
+
@body = body
|
|
39
|
+
@header = header
|
|
40
|
+
@footer = footer
|
|
41
|
+
@padding = padding.to_sym
|
|
42
|
+
@variant = variant.to_sym
|
|
43
|
+
@rounded = rounded.to_sym
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def panel_classes
|
|
47
|
+
[
|
|
48
|
+
'bui-panel',
|
|
49
|
+
get_theme_class,
|
|
50
|
+
get_border_radius_class
|
|
51
|
+
].compact.join(' ')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def get_border_radius_class
|
|
55
|
+
PANEL_RADIUS[@rounded] || PANEL_RADIUS[:small]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def get_theme_class
|
|
59
|
+
PANEL_THEME[@variant] || PANEL_THEME[:default]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def header_classes
|
|
63
|
+
[
|
|
64
|
+
'bui-panel__header',
|
|
65
|
+
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
|
66
|
+
].compact.join(' ')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def body_classes
|
|
70
|
+
[
|
|
71
|
+
'bui-panel__body',
|
|
72
|
+
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
|
73
|
+
].compact.join(' ')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def footer_classes
|
|
77
|
+
[
|
|
78
|
+
'bui-panel__footer',
|
|
79
|
+
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
|
80
|
+
].compact.join(' ')
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def title_classes
|
|
84
|
+
'bui-panel__title'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def render?
|
|
88
|
+
@body.present? || @header.present? || @footer.present? || content.present?
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<div <%= spinner_attributes.to_s.html_safe %>>
|
|
2
|
+
<div class="bui-spinner__animation"></div>
|
|
3
|
+
|
|
4
|
+
<% if @label.present? %>
|
|
5
|
+
<div class="bui-spinner__label">
|
|
6
|
+
<%= @label %>
|
|
7
|
+
</div>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% if content.present? %>
|
|
11
|
+
<div class="bui-spinner__content">
|
|
12
|
+
<%= content %>
|
|
13
|
+
</div>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|