better_ui_tmp 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +211 -0
- data/Rakefile +8 -0
- data/app/assets/builds/application.js +1 -0
- data/app/assets/builds/better_ui.css +1 -0
- data/app/assets/stylesheets/better_ui.scss +3 -0
- data/app/components/better_ui/application/main/component.html.erb +5 -0
- data/app/components/better_ui/application/main/component.rb +99 -0
- data/app/components/better_ui/application/navbar/component.html.erb +219 -0
- data/app/components/better_ui/application/navbar/component.rb +148 -0
- data/app/components/better_ui/application/sidebar/component.html.erb +184 -0
- data/app/components/better_ui/application/sidebar/component.rb +129 -0
- data/app/components/better_ui/general/alert/component.html.erb +32 -0
- data/app/components/better_ui/general/alert/component.rb +242 -0
- data/app/components/better_ui/general/avatar/component.html.erb +20 -0
- data/app/components/better_ui/general/avatar/component.rb +301 -0
- data/app/components/better_ui/general/badge/component.html.erb +23 -0
- data/app/components/better_ui/general/badge/component.rb +248 -0
- data/app/components/better_ui/general/breadcrumb/component.html.erb +15 -0
- data/app/components/better_ui/general/breadcrumb/component.rb +186 -0
- data/app/components/better_ui/general/button/component.html.erb +34 -0
- data/app/components/better_ui/general/button/component.rb +214 -0
- data/app/components/better_ui/general/card/component.html.erb +21 -0
- data/app/components/better_ui/general/card/component.rb +37 -0
- data/app/components/better_ui/general/container/component.html.erb +8 -0
- data/app/components/better_ui/general/container/component.rb +158 -0
- data/app/components/better_ui/general/divider/component.html.erb +10 -0
- data/app/components/better_ui/general/divider/component.rb +226 -0
- data/app/components/better_ui/general/heading/component.html.erb +22 -0
- data/app/components/better_ui/general/heading/component.rb +257 -0
- data/app/components/better_ui/general/icon/component.html.erb +1 -0
- data/app/components/better_ui/general/icon/component.rb +222 -0
- data/app/components/better_ui/general/link/component.html.erb +18 -0
- data/app/components/better_ui/general/link/component.rb +255 -0
- data/app/components/better_ui/general/panel/component.html.erb +28 -0
- data/app/components/better_ui/general/panel/component.rb +249 -0
- data/app/components/better_ui/general/progress/component.html.erb +11 -0
- data/app/components/better_ui/general/progress/component.rb +160 -0
- data/app/components/better_ui/general/spinner/component.html.erb +35 -0
- data/app/components/better_ui/general/spinner/component.rb +93 -0
- data/app/components/better_ui/general/table/component.html.erb +5 -0
- data/app/components/better_ui/general/table/component.rb +217 -0
- data/app/components/better_ui/general/table/tbody_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tbody_component.rb +30 -0
- data/app/components/better_ui/general/table/td_component.html.erb +3 -0
- data/app/components/better_ui/general/table/td_component.rb +44 -0
- data/app/components/better_ui/general/table/tfoot_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tfoot_component.rb +28 -0
- data/app/components/better_ui/general/table/th_component.html.erb +6 -0
- data/app/components/better_ui/general/table/th_component.rb +51 -0
- data/app/components/better_ui/general/table/thead_component.html.erb +3 -0
- data/app/components/better_ui/general/table/thead_component.rb +28 -0
- data/app/components/better_ui/general/table/tr_component.html.erb +3 -0
- data/app/components/better_ui/general/table/tr_component.rb +30 -0
- data/app/components/better_ui/general/tag/component.html.erb +3 -0
- data/app/components/better_ui/general/tag/component.rb +104 -0
- data/app/components/better_ui/general/tooltip/component.html.erb +7 -0
- data/app/components/better_ui/general/tooltip/component.rb +239 -0
- data/app/controllers/better_ui/application_controller.rb +5 -0
- data/app/helpers/better_ui/application/components/main/main_helper.rb +42 -0
- data/app/helpers/better_ui/application/components/main.rb +13 -0
- data/app/helpers/better_ui/application/components/navbar/navbar_helper.rb +51 -0
- data/app/helpers/better_ui/application/components/navbar.rb +13 -0
- data/app/helpers/better_ui/application/components/sidebar/sidebar_helper.rb +51 -0
- data/app/helpers/better_ui/application/components/sidebar.rb +13 -0
- data/app/helpers/better_ui/application_helper.rb +10 -0
- data/app/helpers/better_ui/form_helper.rb +5 -0
- data/app/helpers/better_ui/general/components/alert/alert_helper.rb +29 -0
- data/app/helpers/better_ui/general/components/alert.rb +13 -0
- data/app/helpers/better_ui/general/components/avatar/avatar_helper.rb +29 -0
- data/app/helpers/better_ui/general/components/avatar.rb +13 -0
- data/app/helpers/better_ui/general/components/badge/badge_helper.rb +53 -0
- data/app/helpers/better_ui/general/components/badge.rb +13 -0
- data/app/helpers/better_ui/general/components/breadcrumb/breadcrumb_helper.rb +37 -0
- data/app/helpers/better_ui/general/components/breadcrumb.rb +13 -0
- data/app/helpers/better_ui/general/components/button/button_helper.rb +65 -0
- data/app/helpers/better_ui/general/components/button.rb +13 -0
- data/app/helpers/better_ui/general/components/card/card_helper.rb +37 -0
- data/app/helpers/better_ui/general/components/card.rb +13 -0
- data/app/helpers/better_ui/general/components/container/container_helper.rb +60 -0
- data/app/helpers/better_ui/general/components/container.rb +13 -0
- data/app/helpers/better_ui/general/components/divider/divider_helper.rb +63 -0
- data/app/helpers/better_ui/general/components/divider.rb +13 -0
- data/app/helpers/better_ui/general/components/heading/heading_helper.rb +72 -0
- data/app/helpers/better_ui/general/components/heading.rb +13 -0
- data/app/helpers/better_ui/general/components/icon/icon_helper.rb +16 -0
- data/app/helpers/better_ui/general/components/icon.rb +13 -0
- data/app/helpers/better_ui/general/components/link/link_helper.rb +89 -0
- data/app/helpers/better_ui/general/components/link.rb +13 -0
- data/app/helpers/better_ui/general/components/panel/panel_helper.rb +83 -0
- data/app/helpers/better_ui/general/components/panel.rb +13 -0
- data/app/helpers/better_ui/general/components/progress/progress_helper.rb +53 -0
- data/app/helpers/better_ui/general/components/progress.rb +11 -0
- data/app/helpers/better_ui/general/components/spinner/spinner_helper.rb +17 -0
- data/app/helpers/better_ui/general/components/spinner.rb +10 -0
- data/app/helpers/better_ui/general/components/table/table_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/tbody_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/td_helper.rb +19 -0
- data/app/helpers/better_ui/general/components/table/tfoot_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/th_helper.rb +19 -0
- data/app/helpers/better_ui/general/components/table/thead_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table/tr_helper.rb +13 -0
- data/app/helpers/better_ui/general/components/table.rb +25 -0
- data/app/helpers/better_ui/general/components/tag/tag_helper.rb +26 -0
- data/app/helpers/better_ui/general/components/tag.rb +15 -0
- data/app/helpers/better_ui/general/components/tooltip/tooltip_helper.rb +60 -0
- data/app/helpers/better_ui/general/components/tooltip.rb +13 -0
- data/app/helpers/better_ui/general_helper.rb +24 -0
- data/app/helpers/better_ui_helper.rb +16 -0
- data/app/javascript/application.js +1 -0
- data/app/jobs/better_ui/application_job.rb +4 -0
- data/app/mailers/better_ui/application_mailer.rb +6 -0
- data/app/models/better_ui/application_record.rb +5 -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 +23 -0
- data/config/routes.rb +3 -0
- data/lib/better_ui/engine.rb +109 -0
- data/lib/better_ui/version.rb +3 -0
- data/lib/better_ui.rb +37 -0
- 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/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
- data/lib/tasks/better_ui_tasks.rake +4 -0
- metadata +260 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BetterUi
|
4
|
+
module General
|
5
|
+
module Tag
|
6
|
+
class Component < ViewComponent::Base
|
7
|
+
def initialize(text:, theme: :white, size: :medium, style: :filled, **options)
|
8
|
+
@text = text
|
9
|
+
@theme = theme.to_sym
|
10
|
+
@size = size.to_sym
|
11
|
+
@style = style.to_sym
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :text, :theme, :size, :style, :options
|
18
|
+
|
19
|
+
def tag_classes
|
20
|
+
base_classes = %w[
|
21
|
+
inline-flex
|
22
|
+
items-center
|
23
|
+
justify-center
|
24
|
+
font-medium
|
25
|
+
transition-colors
|
26
|
+
duration-200
|
27
|
+
bui-tag
|
28
|
+
]
|
29
|
+
|
30
|
+
base_classes.concat(size_classes)
|
31
|
+
base_classes.concat(theme_classes)
|
32
|
+
base_classes.concat(style_classes)
|
33
|
+
base_classes.join(' ')
|
34
|
+
end
|
35
|
+
|
36
|
+
def size_classes
|
37
|
+
case size
|
38
|
+
when :small
|
39
|
+
%w[text-xs px-2 py-1 rounded]
|
40
|
+
when :large
|
41
|
+
%w[text-base px-4 py-2 rounded-lg]
|
42
|
+
else # :medium
|
43
|
+
%w[text-sm px-3 py-1.5 rounded-md]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def theme_classes
|
48
|
+
case theme
|
49
|
+
when :default
|
50
|
+
%w[bg-gray-100 text-gray-800]
|
51
|
+
when :red
|
52
|
+
%w[bg-red-100 text-red-800]
|
53
|
+
when :rose
|
54
|
+
%w[bg-rose-100 text-rose-800]
|
55
|
+
when :orange
|
56
|
+
%w[bg-orange-100 text-orange-800]
|
57
|
+
when :green
|
58
|
+
%w[bg-green-100 text-green-800]
|
59
|
+
when :blue
|
60
|
+
%w[bg-blue-100 text-blue-800]
|
61
|
+
when :yellow
|
62
|
+
%w[bg-yellow-100 text-yellow-800]
|
63
|
+
when :violet
|
64
|
+
%w[bg-violet-100 text-violet-800]
|
65
|
+
else # :white
|
66
|
+
%w[bg-white text-gray-700 border border-gray-200]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def style_classes
|
71
|
+
case style
|
72
|
+
when :outline
|
73
|
+
outline_theme_classes
|
74
|
+
else # :filled
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def outline_theme_classes
|
80
|
+
case theme
|
81
|
+
when :default
|
82
|
+
%w[bg-transparent border-gray-300 text-gray-700 hover:bg-gray-50]
|
83
|
+
when :red
|
84
|
+
%w[bg-transparent border-red-300 text-red-700 hover:bg-red-50]
|
85
|
+
when :rose
|
86
|
+
%w[bg-transparent border-rose-300 text-rose-700 hover:bg-rose-50]
|
87
|
+
when :orange
|
88
|
+
%w[bg-transparent border-orange-300 text-orange-700 hover:bg-orange-50]
|
89
|
+
when :green
|
90
|
+
%w[bg-transparent border-green-300 text-green-700 hover:bg-green-50]
|
91
|
+
when :blue
|
92
|
+
%w[bg-transparent border-blue-300 text-blue-700 hover:bg-blue-50]
|
93
|
+
when :yellow
|
94
|
+
%w[bg-transparent border-yellow-300 text-yellow-700 hover:bg-yellow-50]
|
95
|
+
when :violet
|
96
|
+
%w[bg-transparent border-violet-300 text-violet-700 hover:bg-violet-50]
|
97
|
+
else # :white
|
98
|
+
%w[bg-transparent border-gray-300 text-gray-700 hover:bg-gray-50]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Tooltip
|
4
|
+
class Component < ViewComponent::Base
|
5
|
+
# Classi base sempre presenti
|
6
|
+
TOOLTIP_BASE_CLASSES = "relative inline-block"
|
7
|
+
|
8
|
+
# Classi base per il bubble del tooltip
|
9
|
+
TOOLTIP_BUBBLE_BASE_CLASSES = "absolute z-50 px-2 py-1 text-sm rounded shadow-lg opacity-0 pointer-events-none transition-opacity duration-200"
|
10
|
+
|
11
|
+
# Classi per la visibilità su hover
|
12
|
+
TOOLTIP_HOVER_CLASSES = "group-hover:opacity-100"
|
13
|
+
|
14
|
+
# Posizioni del tooltip con classi Tailwind dirette
|
15
|
+
TOOLTIP_POSITIONS = {
|
16
|
+
top: "bottom-full left-1/2 transform -translate-x-1/2 mb-2",
|
17
|
+
right: "left-full top-1/2 transform -translate-y-1/2 ml-2",
|
18
|
+
bottom: "top-full left-1/2 transform -translate-x-1/2 mt-2",
|
19
|
+
left: "right-full top-1/2 transform -translate-y-1/2 mr-2"
|
20
|
+
}
|
21
|
+
|
22
|
+
# Dimensioni del tooltip con classi Tailwind dirette
|
23
|
+
TOOLTIP_SIZES = {
|
24
|
+
small: "px-1.5 py-0.5 text-xs",
|
25
|
+
medium: "px-2 py-1 text-sm",
|
26
|
+
large: "px-3 py-2 text-base"
|
27
|
+
}
|
28
|
+
|
29
|
+
# Temi di tooltip con classi Tailwind dirette - Stile filled
|
30
|
+
TOOLTIP_FILLED_THEMES = {
|
31
|
+
default: "bg-gray-900 text-white",
|
32
|
+
white: "bg-white text-gray-900 border border-gray-200",
|
33
|
+
red: "bg-red-600 text-white",
|
34
|
+
rose: "bg-rose-600 text-white",
|
35
|
+
orange: "bg-orange-600 text-white",
|
36
|
+
green: "bg-green-600 text-white",
|
37
|
+
blue: "bg-blue-600 text-white",
|
38
|
+
yellow: "bg-yellow-600 text-white",
|
39
|
+
violet: "bg-violet-600 text-white"
|
40
|
+
}
|
41
|
+
|
42
|
+
# Temi di tooltip con classi Tailwind dirette - Stile outline
|
43
|
+
TOOLTIP_OUTLINE_THEMES = {
|
44
|
+
default: "bg-white text-gray-900 border border-gray-900",
|
45
|
+
white: "bg-gray-50 text-gray-900 border border-gray-300",
|
46
|
+
red: "bg-white text-red-600 border border-red-600",
|
47
|
+
rose: "bg-white text-rose-600 border border-rose-600",
|
48
|
+
orange: "bg-white text-orange-600 border border-orange-600",
|
49
|
+
green: "bg-white text-green-600 border border-green-600",
|
50
|
+
blue: "bg-white text-blue-600 border border-blue-600",
|
51
|
+
yellow: "bg-white text-yellow-600 border border-yellow-600",
|
52
|
+
violet: "bg-white text-violet-600 border border-violet-600"
|
53
|
+
}
|
54
|
+
|
55
|
+
# Classi per le frecce del tooltip - Filled
|
56
|
+
TOOLTIP_ARROW_BASE_CLASSES = "absolute w-2 h-2 transform rotate-45"
|
57
|
+
|
58
|
+
TOOLTIP_ARROW_POSITIONS = {
|
59
|
+
top: "top-full left-1/2 -translate-x-1/2 -mt-1",
|
60
|
+
right: "right-full top-1/2 -translate-y-1/2 -mr-1",
|
61
|
+
bottom: "bottom-full left-1/2 -translate-x-1/2 -mb-1",
|
62
|
+
left: "left-full top-1/2 -translate-y-1/2 -ml-1"
|
63
|
+
}
|
64
|
+
|
65
|
+
TOOLTIP_ARROW_FILLED_THEMES = {
|
66
|
+
default: "bg-gray-900",
|
67
|
+
white: "bg-white border border-gray-200",
|
68
|
+
red: "bg-red-600",
|
69
|
+
rose: "bg-rose-600",
|
70
|
+
orange: "bg-orange-600",
|
71
|
+
green: "bg-green-600",
|
72
|
+
blue: "bg-blue-600",
|
73
|
+
yellow: "bg-yellow-600",
|
74
|
+
violet: "bg-violet-600"
|
75
|
+
}
|
76
|
+
|
77
|
+
TOOLTIP_ARROW_OUTLINE_THEMES = {
|
78
|
+
default: "bg-white border border-gray-900",
|
79
|
+
white: "bg-gray-50 border border-gray-300",
|
80
|
+
red: "bg-white border border-red-600",
|
81
|
+
rose: "bg-white border border-rose-600",
|
82
|
+
orange: "bg-white border border-orange-600",
|
83
|
+
green: "bg-white border border-green-600",
|
84
|
+
blue: "bg-white border border-blue-600",
|
85
|
+
yellow: "bg-white border border-yellow-600",
|
86
|
+
violet: "bg-white border border-violet-600"
|
87
|
+
}
|
88
|
+
|
89
|
+
# @param text [String] testo del tooltip
|
90
|
+
# @param theme [Symbol] :default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet
|
91
|
+
# @param position [Symbol] :top, :right, :bottom, :left posizione del tooltip
|
92
|
+
# @param size [Symbol] :small, :medium, :large dimensione del tooltip
|
93
|
+
# @param style [Symbol] :filled, :outline stile del tooltip
|
94
|
+
# @param classes [String] classi CSS aggiuntive per il container
|
95
|
+
# @param html_options [Hash] opzioni HTML per il container
|
96
|
+
def initialize(
|
97
|
+
text: nil,
|
98
|
+
theme: :white,
|
99
|
+
position: :top,
|
100
|
+
size: :medium,
|
101
|
+
style: :filled,
|
102
|
+
classes: nil,
|
103
|
+
**html_options
|
104
|
+
)
|
105
|
+
@text = text
|
106
|
+
@theme = theme.to_sym
|
107
|
+
@position = position.to_sym
|
108
|
+
@size = size.to_sym
|
109
|
+
@style = style.to_sym
|
110
|
+
@classes = classes
|
111
|
+
@html_options = html_options
|
112
|
+
|
113
|
+
validate_params
|
114
|
+
end
|
115
|
+
|
116
|
+
# Combina tutte le classi per il container
|
117
|
+
def combined_classes
|
118
|
+
[
|
119
|
+
TOOLTIP_BASE_CLASSES,
|
120
|
+
"group", # Necessario per il trigger hover
|
121
|
+
@classes,
|
122
|
+
@html_options[:class]
|
123
|
+
].compact.join(" ")
|
124
|
+
end
|
125
|
+
|
126
|
+
# Combina tutte le classi per il bubble del tooltip
|
127
|
+
def bubble_classes
|
128
|
+
[
|
129
|
+
TOOLTIP_BUBBLE_BASE_CLASSES,
|
130
|
+
get_position_class,
|
131
|
+
get_size_class,
|
132
|
+
get_theme_class,
|
133
|
+
TOOLTIP_HOVER_CLASSES
|
134
|
+
].compact.join(" ")
|
135
|
+
end
|
136
|
+
|
137
|
+
# Combina tutte le classi per la freccia del tooltip
|
138
|
+
def arrow_classes
|
139
|
+
[
|
140
|
+
TOOLTIP_ARROW_BASE_CLASSES,
|
141
|
+
get_arrow_position_class,
|
142
|
+
get_arrow_theme_class
|
143
|
+
].compact.join(" ")
|
144
|
+
end
|
145
|
+
|
146
|
+
# Restituisce gli attributi per il container del tooltip
|
147
|
+
def tooltip_attributes
|
148
|
+
attrs = {
|
149
|
+
class: combined_classes,
|
150
|
+
role: "tooltip",
|
151
|
+
"data-tooltip": @text
|
152
|
+
}
|
153
|
+
|
154
|
+
# Aggiungi altri attributi HTML se presenti
|
155
|
+
@html_options.except(:class).each do |key, value|
|
156
|
+
attrs[key] = value
|
157
|
+
end
|
158
|
+
|
159
|
+
attrs
|
160
|
+
end
|
161
|
+
|
162
|
+
# Genera le classi per la posizione
|
163
|
+
def get_position_class
|
164
|
+
TOOLTIP_POSITIONS[@position] || TOOLTIP_POSITIONS[:top]
|
165
|
+
end
|
166
|
+
|
167
|
+
# Genera le classi per la dimensione
|
168
|
+
def get_size_class
|
169
|
+
TOOLTIP_SIZES[@size] || TOOLTIP_SIZES[:medium]
|
170
|
+
end
|
171
|
+
|
172
|
+
# Genera le classi per il tema
|
173
|
+
def get_theme_class
|
174
|
+
if @style == :outline
|
175
|
+
TOOLTIP_OUTLINE_THEMES[@theme] || TOOLTIP_OUTLINE_THEMES[:white]
|
176
|
+
else
|
177
|
+
TOOLTIP_FILLED_THEMES[@theme] || TOOLTIP_FILLED_THEMES[:white]
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Genera le classi per la posizione della freccia
|
182
|
+
def get_arrow_position_class
|
183
|
+
TOOLTIP_ARROW_POSITIONS[@position] || TOOLTIP_ARROW_POSITIONS[:top]
|
184
|
+
end
|
185
|
+
|
186
|
+
# Genera le classi per il tema della freccia
|
187
|
+
def get_arrow_theme_class
|
188
|
+
if @style == :outline
|
189
|
+
TOOLTIP_ARROW_OUTLINE_THEMES[@theme] || TOOLTIP_ARROW_OUTLINE_THEMES[:white]
|
190
|
+
else
|
191
|
+
TOOLTIP_ARROW_FILLED_THEMES[@theme] || TOOLTIP_ARROW_FILLED_THEMES[:white]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Verifica se il componente deve essere renderizzato
|
196
|
+
def render?
|
197
|
+
@text.present? && content.present?
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def validate_params
|
203
|
+
validate_theme
|
204
|
+
validate_position
|
205
|
+
validate_size
|
206
|
+
validate_style
|
207
|
+
end
|
208
|
+
|
209
|
+
def validate_theme
|
210
|
+
valid_themes = TOOLTIP_FILLED_THEMES.keys
|
211
|
+
unless valid_themes.include?(@theme)
|
212
|
+
raise ArgumentError, "Il tema deve essere uno tra: #{valid_themes.join(', ')}"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def validate_position
|
217
|
+
valid_positions = TOOLTIP_POSITIONS.keys
|
218
|
+
unless valid_positions.include?(@position)
|
219
|
+
raise ArgumentError, "La posizione deve essere una tra: #{valid_positions.join(', ')}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def validate_size
|
224
|
+
valid_sizes = TOOLTIP_SIZES.keys
|
225
|
+
unless valid_sizes.include?(@size)
|
226
|
+
raise ArgumentError, "La dimensione deve essere una tra: #{valid_sizes.join(', ')}"
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def validate_style
|
231
|
+
valid_styles = [:filled, :outline]
|
232
|
+
unless valid_styles.include?(@style)
|
233
|
+
raise ArgumentError, "Lo stile deve essere uno tra: #{valid_styles.join(', ')}"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module Application
|
3
|
+
module Components
|
4
|
+
module Main
|
5
|
+
module MainHelper
|
6
|
+
# Helper per creare il contenitore principale dell'applicazione
|
7
|
+
#
|
8
|
+
# @param padding [Boolean] Se applicare il padding al contenitore principale, default true
|
9
|
+
# @param inner_padding [Boolean] Se applicare il padding al contenitore interno, default true
|
10
|
+
# @param rounded [Symbol] Tipo di border-radius del contenitore interno (:none, :small, :medium, :large, :full), default :small
|
11
|
+
# @param shadow [Symbol] Tipo di ombra del contenitore interno (:none, :sm, :md, :lg), default :md
|
12
|
+
# @param with_sidebar [Boolean] Se lasciare lo spazio per la sidebar, default true
|
13
|
+
# @param with_navbar [Boolean] Se lasciare lo spazio per la navbar, default true
|
14
|
+
# @param classes [String] Classi CSS aggiuntive per il contenitore principale
|
15
|
+
# @param block [Proc] Blocco contenente il contenuto del main
|
16
|
+
#
|
17
|
+
# @return [String] HTML del componente main
|
18
|
+
def bui_main(
|
19
|
+
padding: true,
|
20
|
+
inner_padding: true,
|
21
|
+
rounded: :small,
|
22
|
+
shadow: :md,
|
23
|
+
with_sidebar: true,
|
24
|
+
with_navbar: true,
|
25
|
+
classes: nil,
|
26
|
+
&block
|
27
|
+
)
|
28
|
+
render BetterUi::Application::Main::Component.new(
|
29
|
+
padding: padding,
|
30
|
+
inner_padding: inner_padding,
|
31
|
+
rounded: rounded,
|
32
|
+
shadow: shadow,
|
33
|
+
with_sidebar: with_sidebar,
|
34
|
+
with_navbar: with_navbar,
|
35
|
+
classes: classes
|
36
|
+
), &block
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module Application
|
3
|
+
module Components
|
4
|
+
module Navbar
|
5
|
+
module NavbarHelper
|
6
|
+
# Helper per creare la navbar dell'applicazione
|
7
|
+
#
|
8
|
+
# @param theme [Symbol] Tema colori (:default, :dark, :light), default :default
|
9
|
+
# @param position [Symbol] Posizione della navbar (:top, :fixed_top, :sticky_top), default :top
|
10
|
+
# @param height [Symbol] Altezza della navbar (:sm, :md, :lg), default :md
|
11
|
+
# @param shadow [Symbol] Tipo di ombra (:none, :sm, :md, :lg, :xl), default :sm
|
12
|
+
# @param border [Boolean] Se mostrare il bordo inferiore, default true
|
13
|
+
# @param brand [Hash] Configurazione brand (logo, title, href)
|
14
|
+
# @param breadcrumb [Hash] Configurazione breadcrumb (items, separator, theme)
|
15
|
+
# @param navigation_items [Array] Array di elementi di navigazione centrali
|
16
|
+
# @param actions [Array] Array di azioni/pulsanti a destra
|
17
|
+
# @param classes [String] Classi CSS aggiuntive
|
18
|
+
# @param block [Proc] Blocco contenente contenuto aggiuntivo della navbar
|
19
|
+
#
|
20
|
+
# @return [String] HTML del componente navbar
|
21
|
+
def bui_navbar(
|
22
|
+
theme: :default,
|
23
|
+
position: :top,
|
24
|
+
height: :md,
|
25
|
+
shadow: :sm,
|
26
|
+
border: true,
|
27
|
+
brand: {},
|
28
|
+
breadcrumb: {},
|
29
|
+
navigation_items: [],
|
30
|
+
actions: [],
|
31
|
+
classes: nil,
|
32
|
+
&block
|
33
|
+
)
|
34
|
+
render BetterUi::Application::Navbar::Component.new(
|
35
|
+
theme: theme,
|
36
|
+
position: position,
|
37
|
+
height: height,
|
38
|
+
shadow: shadow,
|
39
|
+
border: border,
|
40
|
+
brand: brand,
|
41
|
+
breadcrumb: breadcrumb,
|
42
|
+
navigation_items: navigation_items,
|
43
|
+
actions: actions,
|
44
|
+
classes: classes
|
45
|
+
), &block
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module Application
|
3
|
+
module Components
|
4
|
+
module Sidebar
|
5
|
+
module SidebarHelper
|
6
|
+
# Helper per creare la sidebar dell'applicazione
|
7
|
+
#
|
8
|
+
# @param width [Symbol] Larghezza della sidebar (:sm, :md, :lg, :xl), default :md
|
9
|
+
# @param position [Symbol] Posizione della sidebar (:left, :right), default :left
|
10
|
+
# @param theme [Symbol] Tema colori (:default, :dark, :light), default :default
|
11
|
+
# @param shadow [Symbol] Tipo di ombra (:none, :sm, :md, :lg), default :lg
|
12
|
+
# @param border [Boolean] Se mostrare il bordo destro/sinistro, default true
|
13
|
+
# @param header [Hash] Configurazione header (logo, title, subtitle)
|
14
|
+
# @param footer [Hash] Configurazione footer (content, user_info)
|
15
|
+
# @param navigation_sections [Array] Array di sezioni di navigazione
|
16
|
+
# @param collapsible [Boolean] Se abilitare sezioni collassabili, default true
|
17
|
+
# @param classes [String] Classi CSS aggiuntive
|
18
|
+
# @param block [Proc] Blocco contenente contenuto aggiuntivo della sidebar
|
19
|
+
#
|
20
|
+
# @return [String] HTML del componente sidebar
|
21
|
+
def bui_sidebar(
|
22
|
+
width: :md,
|
23
|
+
position: :left,
|
24
|
+
theme: :default,
|
25
|
+
shadow: :lg,
|
26
|
+
border: true,
|
27
|
+
header: {},
|
28
|
+
footer: {},
|
29
|
+
navigation_sections: [],
|
30
|
+
collapsible: true,
|
31
|
+
classes: nil,
|
32
|
+
&block
|
33
|
+
)
|
34
|
+
render BetterUi::Application::Sidebar::Component.new(
|
35
|
+
width: width,
|
36
|
+
position: position,
|
37
|
+
theme: theme,
|
38
|
+
shadow: shadow,
|
39
|
+
border: border,
|
40
|
+
header: header,
|
41
|
+
footer: footer,
|
42
|
+
navigation_sections: navigation_sections,
|
43
|
+
collapsible: collapsible,
|
44
|
+
classes: classes
|
45
|
+
), &block
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module ApplicationHelper
|
3
|
+
# Inclusione dei moduli aggregatori per i componenti application
|
4
|
+
# Questo assicura che tutti gli helper specifici dei componenti siano disponibili.
|
5
|
+
|
6
|
+
include BetterUi::Application::Components::Main if defined?(BetterUi::Application::Components::Main)
|
7
|
+
include BetterUi::Application::Components::Sidebar if defined?(BetterUi::Application::Components::Sidebar)
|
8
|
+
include BetterUi::Application::Components::Navbar if defined?(BetterUi::Application::Components::Navbar)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Alert
|
5
|
+
module AlertHelper
|
6
|
+
# Render un alert con le opzioni specificate
|
7
|
+
#
|
8
|
+
# @param options [Hash] opzioni per il componente
|
9
|
+
#
|
10
|
+
# @option options [String] :title (nil) titolo dell'alert
|
11
|
+
# @option options [String] :message (nil) contenuto dell'alert
|
12
|
+
# @option options [Symbol] :theme (:default) :default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet
|
13
|
+
# @option options [String] :icon (nil) nome dell'icona (usa default se nil)
|
14
|
+
# @option options [Symbol] :icon_position (:left) :left, :right posizione dell'icona
|
15
|
+
# @option options [Boolean] :dismissible (false) se l'alert può essere chiuso
|
16
|
+
# @option options [Symbol] :rounded (:medium) :none, :small, :medium, :large, :full arrotondamento degli angoli
|
17
|
+
# @option options [Symbol] :importance (:medium) :high, :medium, :low livello di importanza per accessibilità
|
18
|
+
# @option options [Boolean] :html_content (false) se il messaggio contiene HTML
|
19
|
+
# @option options [String] :classes (nil) classi CSS aggiuntive
|
20
|
+
#
|
21
|
+
# @return [String] HTML del componente
|
22
|
+
def bui_alert(**options)
|
23
|
+
render BetterUi::General::Alert::Component.new(**options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module Avatar
|
5
|
+
module AvatarHelper
|
6
|
+
# Render un avatar con le opzioni specificate
|
7
|
+
#
|
8
|
+
# @param options [Hash] opzioni per il componente
|
9
|
+
#
|
10
|
+
# @option options [String] :name (nil) nome per le iniziali
|
11
|
+
# @option options [String] :src (nil) URL dell'immagine
|
12
|
+
# @option options [Symbol] :size (:medium) :xxsmall, :xsmall, :small, :medium, :large, :xlarge, :xxlarge
|
13
|
+
# @option options [Symbol] :shape (:circle) :circle, :square, :rounded
|
14
|
+
# @option options [Symbol] :status (nil) :online, :offline, :busy, :away
|
15
|
+
# @option options [Symbol] :status_position (:bottom_right) :bottom_right, :bottom_left, :top_right, :top_left
|
16
|
+
# @option options [Symbol] :theme (:white) :default, :white, :red, :rose, :orange, :green, :blue, :yellow, :violet
|
17
|
+
# @option options [Symbol] :style (:filled) :filled, :outline, :light
|
18
|
+
# @option options [String] :classes (nil) classi CSS aggiuntive
|
19
|
+
# @option options [String] :id (nil) ID HTML
|
20
|
+
#
|
21
|
+
# @return [String] HTML del componente
|
22
|
+
def bui_avatar(**options)
|
23
|
+
render BetterUi::General::Avatar::Component.new(**options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|