better_ui 0.5.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.
- checksums.yaml +4 -4
- data/README.md +137 -245
- 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 +3 -1
- 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/general/avatar_component.html.erb +2 -2
- data/app/components/better_ui/general/avatar_component.rb +29 -29
- data/app/components/better_ui/general/badge_component.html.erb +3 -3
- data/app/components/better_ui/general/badge_component.rb +32 -20
- data/app/components/better_ui/general/breadcrumb_component.html.erb +2 -2
- data/app/components/better_ui/general/breadcrumb_component.rb +23 -23
- data/app/components/better_ui/general/button_component.html.erb +6 -6
- data/app/components/better_ui/general/button_component.rb +20 -22
- data/app/components/better_ui/general/heading_component.html.erb +1 -25
- data/app/components/better_ui/general/heading_component.rb +17 -116
- data/app/components/better_ui/general/icon_component.html.erb +1 -1
- data/app/components/better_ui/general/icon_component.rb +33 -56
- data/app/components/better_ui/general/link_component.html.erb +4 -4
- data/app/components/better_ui/general/link_component.rb +28 -28
- data/app/components/better_ui/general/panel_component.rb +30 -41
- data/app/components/better_ui/general/spinner_component.html.erb +3 -3
- data/app/components/better_ui/general/spinner_component.rb +13 -13
- data/app/components/better_ui/general/table_component.rb +35 -59
- 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/config/routes.rb +2 -13
- data/lib/better_ui/engine.rb +67 -11
- data/lib/better_ui/version.rb +1 -1
- data/lib/better_ui.rb +10 -2
- data/lib/generators/better_ui/install_generator.rb +103 -0
- data/lib/generators/better_ui/stylesheet_generator.rb +93 -30
- data/lib/generators/better_ui/templates/README +74 -5
- data/lib/generators/better_ui/templates/components/_avatar.scss +199 -150
- data/lib/generators/better_ui/templates/components/_badge.scss +153 -141
- data/lib/generators/better_ui/templates/components/_breadcrumb.scss +105 -106
- data/lib/generators/better_ui/templates/components/_button.scss +104 -101
- data/lib/generators/better_ui/templates/components/_card.scss +56 -65
- data/lib/generators/better_ui/templates/components/_heading.scss +80 -179
- data/lib/generators/better_ui/templates/components/_icon.scss +133 -89
- data/lib/generators/better_ui/templates/components/_index.scss +17 -0
- data/lib/generators/better_ui/templates/components/_link.scss +99 -129
- data/lib/generators/better_ui/templates/components/_panel.scss +103 -143
- data/lib/generators/better_ui/templates/components/_spinner.scss +127 -130
- data/lib/generators/better_ui/templates/components/_table.scss +156 -105
- data/lib/generators/better_ui/templates/components/_variables.scss +0 -33
- data/lib/generators/better_ui/templates/components_stylesheet.scss +25 -56
- data/lib/generators/better_ui/templates/index.scss +18 -0
- data/lib/generators/better_ui/templates/initializer.rb +41 -0
- metadata +91 -49
- data/app/assets/javascripts/better_ui/controllers/navbar_controller.js +0 -138
- data/app/assets/javascripts/better_ui/controllers/sidebar_controller.js +0 -211
- data/app/assets/javascripts/better_ui/controllers/toast_controller.js +0 -161
- data/app/assets/javascripts/better_ui/index.js +0 -159
- data/app/assets/javascripts/better_ui/toast_manager.js +0 -77
- data/app/components/better_ui/theme_helper.rb +0 -171
- data/app/controllers/better_ui/docs_controller.rb +0 -34
@@ -3,50 +3,53 @@ module BetterUi
|
|
3
3
|
class IconComponent < ViewComponent::Base
|
4
4
|
# Dimensioni disponibili
|
5
5
|
ICON_SIZES = {
|
6
|
-
xsmall: "bui-icon
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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"
|
11
12
|
}
|
12
13
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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"
|
20
25
|
}
|
21
26
|
|
22
27
|
# Inizializzazione del componente
|
23
28
|
def initialize(
|
24
29
|
name:,
|
25
30
|
size: :medium,
|
26
|
-
|
31
|
+
color: :default,
|
27
32
|
fixed_width: false,
|
28
33
|
spin: false,
|
29
34
|
pulse: false,
|
30
|
-
|
31
|
-
|
32
|
-
rotation: nil,
|
35
|
+
solid: false,
|
36
|
+
solid_color: false,
|
33
37
|
classes: nil
|
34
38
|
)
|
35
39
|
@name = name.to_s.gsub('_', '-') # Convertiamo da snake_case a kebab-case per Font Awesome
|
36
40
|
@size = size.to_sym
|
37
|
-
@
|
41
|
+
@color = color.to_sym
|
38
42
|
@fixed_width = fixed_width
|
39
43
|
@spin = spin
|
40
44
|
@pulse = pulse
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@rotation = rotation
|
45
|
+
@solid = solid
|
46
|
+
@solid_color = solid_color
|
44
47
|
@classes = classes
|
45
48
|
end
|
46
49
|
|
47
|
-
# Classe CSS per
|
48
|
-
def
|
49
|
-
|
50
|
+
# Classe CSS per il colore
|
51
|
+
def color_class
|
52
|
+
ICON_THEMES[@color] || ICON_THEMES[:default]
|
50
53
|
end
|
51
54
|
|
52
55
|
# Classe CSS per la dimensione
|
@@ -54,44 +57,18 @@ module BetterUi
|
|
54
57
|
ICON_SIZES[@size] || ICON_SIZES[:medium]
|
55
58
|
end
|
56
59
|
|
57
|
-
# Classe per rotazione
|
58
|
-
def rotation_class
|
59
|
-
return "" unless @rotation
|
60
|
-
"bui-icon-rotate-#{@rotation}"
|
61
|
-
end
|
62
|
-
|
63
|
-
# Classe per rovesciamento
|
64
|
-
def flip_class
|
65
|
-
return "" unless @flip
|
66
|
-
"bui-icon-flip-#{@flip}"
|
67
|
-
end
|
68
|
-
|
69
|
-
# Classi per animazioni
|
70
|
-
def animation_classes
|
71
|
-
classes = []
|
72
|
-
classes << "bui-icon-spin" if @spin
|
73
|
-
classes << "bui-icon-pulse" if @pulse
|
74
|
-
classes.join(" ")
|
75
|
-
end
|
76
|
-
|
77
|
-
# Classi per caratteristiche aggiuntive
|
78
|
-
def feature_classes
|
79
|
-
classes = []
|
80
|
-
classes << "bui-icon-fw" if @fixed_width
|
81
|
-
classes << "bui-icon-border" if @border
|
82
|
-
classes.join(" ")
|
83
|
-
end
|
84
|
-
|
85
60
|
# Combinazione di tutte le classi
|
86
61
|
def combined_classes
|
87
62
|
[
|
88
|
-
|
63
|
+
"bui-icon",
|
89
64
|
"fa-#{@name}", # Questa classe deve rimanere specifica di Font Awesome
|
90
65
|
size_class,
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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,
|
95
72
|
@classes
|
96
73
|
].reject(&:blank?).join(" ")
|
97
74
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
<% if link? %>
|
2
2
|
<%= link_to href, **link_attributes do %>
|
3
3
|
<% if render_icon %>
|
4
|
-
<span class="bui-
|
4
|
+
<span class="bui-link__icon"><%= render_icon %></span>
|
5
5
|
<% end %>
|
6
|
-
<span><%= label %></span>
|
6
|
+
<span class="bui-link__text"><%= label %></span>
|
7
7
|
<%= content if content.present? %>
|
8
8
|
<% end %>
|
9
9
|
<% else %>
|
10
10
|
<span class="<%= component_classes %>" <%= "aria-current='page'" if active? %>>
|
11
11
|
<% if render_icon %>
|
12
|
-
<span class="bui-
|
12
|
+
<span class="bui-link__icon"><%= render_icon %></span>
|
13
13
|
<% end %>
|
14
|
-
<span><%= label %></span>
|
14
|
+
<span class="bui-link__text"><%= label %></span>
|
15
15
|
<%= content if content.present? %>
|
16
16
|
</span>
|
17
17
|
<% end %>
|
@@ -6,49 +6,49 @@ module BetterUi
|
|
6
6
|
# Temi di colore disponibili
|
7
7
|
LINK_THEME = {
|
8
8
|
default: {
|
9
|
-
link: "bui-link
|
10
|
-
active: "bui-link-default
|
11
|
-
text: "bui-link-default
|
9
|
+
link: "bui-link--default",
|
10
|
+
active: "bui-link--active bui-link--default",
|
11
|
+
text: "bui-link--text bui-link--default"
|
12
12
|
},
|
13
13
|
white: {
|
14
|
-
link: "bui-link
|
15
|
-
active: "bui-link-white
|
16
|
-
text: "bui-link-white
|
14
|
+
link: "bui-link--white",
|
15
|
+
active: "bui-link--active bui-link--white",
|
16
|
+
text: "bui-link--text bui-link--white"
|
17
17
|
},
|
18
18
|
red: {
|
19
|
-
link: "bui-link
|
20
|
-
active: "bui-link-red
|
21
|
-
text: "bui-link-red
|
19
|
+
link: "bui-link--red",
|
20
|
+
active: "bui-link--active bui-link--red",
|
21
|
+
text: "bui-link--text bui-link--red"
|
22
22
|
},
|
23
23
|
rose: {
|
24
|
-
link: "bui-link
|
25
|
-
active: "bui-link-rose
|
26
|
-
text: "bui-link-rose
|
24
|
+
link: "bui-link--rose",
|
25
|
+
active: "bui-link--active bui-link--rose",
|
26
|
+
text: "bui-link--text bui-link--rose"
|
27
27
|
},
|
28
28
|
orange: {
|
29
|
-
link: "bui-link
|
30
|
-
active: "bui-link-orange
|
31
|
-
text: "bui-link-orange
|
29
|
+
link: "bui-link--orange",
|
30
|
+
active: "bui-link--active bui-link--orange",
|
31
|
+
text: "bui-link--text bui-link--orange"
|
32
32
|
},
|
33
33
|
green: {
|
34
|
-
link: "bui-link
|
35
|
-
active: "bui-link-green
|
36
|
-
text: "bui-link-green
|
34
|
+
link: "bui-link--green",
|
35
|
+
active: "bui-link--active bui-link--green",
|
36
|
+
text: "bui-link--text bui-link--green"
|
37
37
|
},
|
38
38
|
blue: {
|
39
|
-
link: "bui-link
|
40
|
-
active: "bui-link-blue
|
41
|
-
text: "bui-link-blue
|
39
|
+
link: "bui-link--blue",
|
40
|
+
active: "bui-link--active bui-link--blue",
|
41
|
+
text: "bui-link--text bui-link--blue"
|
42
42
|
},
|
43
43
|
yellow: {
|
44
|
-
link: "bui-link
|
45
|
-
active: "bui-link-yellow
|
46
|
-
text: "bui-link-yellow
|
44
|
+
link: "bui-link--yellow",
|
45
|
+
active: "bui-link--active bui-link--yellow",
|
46
|
+
text: "bui-link--text bui-link--yellow"
|
47
47
|
},
|
48
48
|
violet: {
|
49
|
-
link: "bui-link
|
50
|
-
active: "bui-link-violet
|
51
|
-
text: "bui-link-violet
|
49
|
+
link: "bui-link--violet",
|
50
|
+
active: "bui-link--active bui-link--violet",
|
51
|
+
text: "bui-link--text bui-link--violet"
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
@@ -89,7 +89,7 @@ module BetterUi
|
|
89
89
|
def component_classes
|
90
90
|
theme_classes = LINK_THEME.fetch(@theme, LINK_THEME[:default])
|
91
91
|
|
92
|
-
base_classes = ["bui-link
|
92
|
+
base_classes = ["bui-link"]
|
93
93
|
|
94
94
|
if active?
|
95
95
|
base_classes << theme_classes[:active]
|
@@ -5,45 +5,32 @@ module BetterUi
|
|
5
5
|
|
6
6
|
# Opzioni di padding disponibili
|
7
7
|
PANEL_PADDING = {
|
8
|
-
none: 'bui-panel
|
9
|
-
small: 'bui-panel
|
10
|
-
medium: 'bui-panel
|
11
|
-
large: 'bui-panel
|
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
12
|
}.freeze
|
13
13
|
|
14
|
-
# Temi di colore per
|
15
|
-
|
16
|
-
default: 'bui-panel
|
17
|
-
white: 'bui-panel
|
18
|
-
red: 'bui-panel
|
19
|
-
rose: 'bui-panel
|
20
|
-
orange: 'bui-panel
|
21
|
-
green: 'bui-panel
|
22
|
-
blue: 'bui-panel
|
23
|
-
yellow: 'bui-panel
|
24
|
-
violet: 'bui-panel
|
25
|
-
}.freeze
|
26
|
-
|
27
|
-
# Temi di colore per il footer
|
28
|
-
PANEL_FOOTER_THEME = {
|
29
|
-
default: 'bui-panel-default-footer',
|
30
|
-
white: 'bui-panel-white-footer',
|
31
|
-
red: 'bui-panel-red-footer',
|
32
|
-
rose: 'bui-panel-rose-footer',
|
33
|
-
orange: 'bui-panel-orange-footer',
|
34
|
-
green: 'bui-panel-green-footer',
|
35
|
-
blue: 'bui-panel-blue-footer',
|
36
|
-
yellow: 'bui-panel-yellow-footer',
|
37
|
-
violet: 'bui-panel-violet-footer'
|
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'
|
38
25
|
}.freeze
|
39
26
|
|
40
27
|
# Opzioni di bordi arrotondati standardizzati
|
41
28
|
PANEL_RADIUS = {
|
42
|
-
none: 'bui-panel
|
43
|
-
small: 'bui-panel
|
44
|
-
medium: 'bui-panel
|
45
|
-
large: 'bui-panel
|
46
|
-
full: 'bui-panel
|
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'
|
47
34
|
}.freeze
|
48
35
|
|
49
36
|
def initialize(title: nil, body: nil, header: nil, footer: nil, padding: :medium, variant: :default, rounded: :small)
|
@@ -58,7 +45,8 @@ module BetterUi
|
|
58
45
|
|
59
46
|
def panel_classes
|
60
47
|
[
|
61
|
-
'bui-panel
|
48
|
+
'bui-panel',
|
49
|
+
get_theme_class,
|
62
50
|
get_border_radius_class
|
63
51
|
].compact.join(' ')
|
64
52
|
end
|
@@ -66,33 +54,34 @@ module BetterUi
|
|
66
54
|
def get_border_radius_class
|
67
55
|
PANEL_RADIUS[@rounded] || PANEL_RADIUS[:small]
|
68
56
|
end
|
57
|
+
|
58
|
+
def get_theme_class
|
59
|
+
PANEL_THEME[@variant] || PANEL_THEME[:default]
|
60
|
+
end
|
69
61
|
|
70
62
|
def header_classes
|
71
63
|
[
|
72
|
-
'bui-
|
73
|
-
PANEL_HEADER_THEME[@variant] || PANEL_HEADER_THEME[:default],
|
64
|
+
'bui-panel__header',
|
74
65
|
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
75
66
|
].compact.join(' ')
|
76
67
|
end
|
77
68
|
|
78
69
|
def body_classes
|
79
70
|
[
|
80
|
-
'bui-
|
81
|
-
'bui-panel-body-content',
|
71
|
+
'bui-panel__body',
|
82
72
|
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
83
73
|
].compact.join(' ')
|
84
74
|
end
|
85
75
|
|
86
76
|
def footer_classes
|
87
77
|
[
|
88
|
-
'bui-
|
89
|
-
PANEL_FOOTER_THEME[@variant] || PANEL_FOOTER_THEME[:default],
|
78
|
+
'bui-panel__footer',
|
90
79
|
PANEL_PADDING.fetch(@padding, PANEL_PADDING[:medium])
|
91
80
|
].compact.join(' ')
|
92
81
|
end
|
93
82
|
|
94
83
|
def title_classes
|
95
|
-
'bui-
|
84
|
+
'bui-panel__title'
|
96
85
|
end
|
97
86
|
|
98
87
|
def render?
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<div <%= spinner_attributes.to_s.html_safe %>>
|
2
|
-
<div class="bui-
|
2
|
+
<div class="bui-spinner__animation"></div>
|
3
3
|
|
4
4
|
<% if @label.present? %>
|
5
|
-
<div class="bui-
|
5
|
+
<div class="bui-spinner__label">
|
6
6
|
<%= @label %>
|
7
7
|
</div>
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
<% if content.present? %>
|
11
|
-
<div class="bui-
|
11
|
+
<div class="bui-spinner__content">
|
12
12
|
<%= content %>
|
13
13
|
</div>
|
14
14
|
<% end %>
|
@@ -5,27 +5,27 @@ module BetterUi
|
|
5
5
|
|
6
6
|
# Temi di colore disponibili
|
7
7
|
SPINNER_THEME = {
|
8
|
-
default: "bui-spinner
|
9
|
-
white: "bui-spinner
|
10
|
-
red: "bui-spinner
|
11
|
-
rose: "bui-spinner
|
12
|
-
orange: "bui-spinner
|
13
|
-
green: "bui-spinner
|
14
|
-
blue: "bui-spinner
|
15
|
-
yellow: "bui-spinner
|
16
|
-
violet: "bui-spinner
|
8
|
+
default: "bui-spinner--default",
|
9
|
+
white: "bui-spinner--white",
|
10
|
+
red: "bui-spinner--red",
|
11
|
+
rose: "bui-spinner--rose",
|
12
|
+
orange: "bui-spinner--orange",
|
13
|
+
green: "bui-spinner--green",
|
14
|
+
blue: "bui-spinner--blue",
|
15
|
+
yellow: "bui-spinner--yellow",
|
16
|
+
violet: "bui-spinner--violet"
|
17
17
|
}
|
18
18
|
|
19
19
|
# Dimensioni disponibili
|
20
20
|
SPINNER_SIZES = {
|
21
|
-
small: "bui-spinner
|
22
|
-
medium: "bui-spinner
|
23
|
-
large: "bui-spinner
|
21
|
+
small: "bui-spinner--small",
|
22
|
+
medium: "bui-spinner--medium",
|
23
|
+
large: "bui-spinner--large"
|
24
24
|
}
|
25
25
|
|
26
26
|
# Stati e comportamenti dello spinner
|
27
27
|
SPINNER_STATES = {
|
28
|
-
fullscreen: "bui-spinner
|
28
|
+
fullscreen: "bui-spinner--fullscreen"
|
29
29
|
}
|
30
30
|
|
31
31
|
# Inizializzazione del componente
|
@@ -6,24 +6,24 @@ module BetterUi
|
|
6
6
|
|
7
7
|
# Costanti per configurazione stili
|
8
8
|
TABLE_THEMES = {
|
9
|
-
default:
|
10
|
-
white:
|
11
|
-
red:
|
12
|
-
rose:
|
13
|
-
orange:
|
14
|
-
green:
|
15
|
-
blue:
|
16
|
-
yellow:
|
17
|
-
violet:
|
9
|
+
default: "bui-table--default",
|
10
|
+
white: "bui-table--white",
|
11
|
+
red: "bui-table--red",
|
12
|
+
rose: "bui-table--rose",
|
13
|
+
orange: "bui-table--orange",
|
14
|
+
green: "bui-table--green",
|
15
|
+
blue: "bui-table--blue",
|
16
|
+
yellow: "bui-table--yellow",
|
17
|
+
violet: "bui-table--violet"
|
18
18
|
}.freeze
|
19
19
|
|
20
20
|
# Opzioni di bordi arrotondati standardizzati
|
21
21
|
TABLE_RADIUS = {
|
22
|
-
none: "bui-table
|
23
|
-
small: "bui-table
|
24
|
-
medium: "bui-table
|
25
|
-
large: "bui-table
|
26
|
-
full: "bui-table
|
22
|
+
none: "bui-table--radius-none",
|
23
|
+
small: "bui-table--radius-small",
|
24
|
+
medium: "bui-table--radius-medium",
|
25
|
+
large: "bui-table--radius-large",
|
26
|
+
full: "bui-table--radius-full"
|
27
27
|
}.freeze
|
28
28
|
|
29
29
|
def initialize(data:, headers: nil, caption: nil, striped: false, hoverable: false, bordered: true, compact: false, classes: nil, variant: :default, rounded: :small, footer: nil, header_rows_partial: nil, body_row_partial: nil, footer_rows_partial: nil)
|
@@ -45,15 +45,19 @@ module BetterUi
|
|
45
45
|
|
46
46
|
def table_classes
|
47
47
|
[
|
48
|
-
"bui-table
|
49
|
-
|
48
|
+
"bui-table",
|
49
|
+
get_theme_class,
|
50
|
+
@bordered ? "bui-table--bordered" : nil,
|
51
|
+
@striped ? "bui-table--striped" : nil,
|
52
|
+
@hoverable ? "bui-table--hoverable" : nil,
|
53
|
+
@compact ? "bui-table--compact" : nil,
|
50
54
|
@classes
|
51
55
|
].compact.join(" ")
|
52
56
|
end
|
53
57
|
|
54
58
|
def table_container_classes
|
55
59
|
[
|
56
|
-
"bui-
|
60
|
+
"bui-table__container",
|
57
61
|
get_border_radius_class
|
58
62
|
].compact.join(" ")
|
59
63
|
end
|
@@ -61,76 +65,48 @@ module BetterUi
|
|
61
65
|
def get_border_radius_class
|
62
66
|
TABLE_RADIUS[@rounded] || TABLE_RADIUS[:small]
|
63
67
|
end
|
68
|
+
|
69
|
+
def get_theme_class
|
70
|
+
TABLE_THEMES[@variant] || TABLE_THEMES[:default]
|
71
|
+
end
|
64
72
|
|
65
73
|
def caption_classes
|
66
|
-
|
67
|
-
"bui-table-caption",
|
68
|
-
get_theme_bg_color,
|
69
|
-
get_theme_text_class,
|
70
|
-
@bordered ? "bui-table-caption-bordered #{get_theme_border_color}" : nil
|
71
|
-
].compact.join(" ")
|
74
|
+
"bui-table__caption"
|
72
75
|
end
|
73
76
|
|
74
77
|
def thead_classes
|
75
|
-
"bui-
|
78
|
+
"bui-table__header"
|
76
79
|
end
|
77
80
|
|
78
81
|
def tbody_classes
|
79
|
-
|
82
|
+
"bui-table__body"
|
80
83
|
end
|
81
84
|
|
82
85
|
def tfoot_classes
|
83
|
-
"bui-
|
86
|
+
"bui-table__footer"
|
84
87
|
end
|
85
88
|
|
86
89
|
def tr_classes(index)
|
87
|
-
|
88
|
-
@hoverable ? "bui-table-row-hover" : nil,
|
89
|
-
@striped ? nil : (index.odd? ? "bui-table-row-alternate" : nil)
|
90
|
-
].compact.join(" ")
|
90
|
+
"bui-table__row"
|
91
91
|
end
|
92
92
|
|
93
93
|
def th_classes
|
94
94
|
[
|
95
|
-
|
96
|
-
|
97
|
-
get_theme_text_class,
|
98
|
-
@bordered ? "bui-table-cell-bordered #{get_theme_border_color}" : nil
|
95
|
+
"bui-table__cell",
|
96
|
+
"bui-table__cell--header"
|
99
97
|
].compact.join(" ")
|
100
98
|
end
|
101
99
|
|
102
100
|
def td_classes
|
103
|
-
|
104
|
-
@compact ? "bui-table-cell-compact" : "bui-table-cell",
|
105
|
-
@bordered ? "bui-table-cell-bordered #{get_theme_border_color}" : nil
|
106
|
-
].compact.join(" ")
|
101
|
+
"bui-table__cell"
|
107
102
|
end
|
108
103
|
|
109
104
|
def tf_classes
|
110
105
|
[
|
111
|
-
|
112
|
-
"bui-
|
113
|
-
get_theme_bg_color,
|
114
|
-
get_theme_text_class,
|
115
|
-
@bordered ? "bui-table-cell-bordered #{get_theme_border_color}" : nil
|
106
|
+
"bui-table__cell",
|
107
|
+
"bui-table__cell--footer"
|
116
108
|
].compact.join(" ")
|
117
109
|
end
|
118
|
-
|
119
|
-
def get_theme_base_class
|
120
|
-
TABLE_THEMES[@variant][:base] || TABLE_THEMES[:default][:base]
|
121
|
-
end
|
122
|
-
|
123
|
-
def get_theme_border_color
|
124
|
-
TABLE_THEMES[@variant][:border] || TABLE_THEMES[:default][:border]
|
125
|
-
end
|
126
|
-
|
127
|
-
def get_theme_bg_color
|
128
|
-
TABLE_THEMES[@variant][:bg] || TABLE_THEMES[:default][:bg]
|
129
|
-
end
|
130
|
-
|
131
|
-
def get_theme_text_class
|
132
|
-
TABLE_THEMES[@variant][:text] || TABLE_THEMES[:default][:text]
|
133
|
-
end
|
134
110
|
|
135
111
|
def headers_for_display
|
136
112
|
return @headers if @headers.present?
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module AvatarHelper
|
5
|
+
def bui_avatar(image = nil, **options)
|
6
|
+
render BetterUi::General::AvatarComponent.new(
|
7
|
+
image: image,
|
8
|
+
**options
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Supporto per la sintassi originale per compatibilità
|
13
|
+
alias_method :better_ui_general_avatar, :bui_avatar
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module BadgeHelper
|
5
|
+
def bui_badge(label = nil, **options)
|
6
|
+
render BetterUi::General::BadgeComponent.new(
|
7
|
+
label: label,
|
8
|
+
**options
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Supporto per la sintassi originale per compatibilità
|
13
|
+
alias_method :better_ui_general_badge, :bui_badge
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module BreadcrumbHelper
|
5
|
+
def bui_breadcrumb(items = nil, **options)
|
6
|
+
render BetterUi::General::BreadcrumbComponent.new(
|
7
|
+
items: items,
|
8
|
+
**options
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Supporto per la sintassi originale per compatibilità
|
13
|
+
alias_method :better_ui_general_breadcrumb, :bui_breadcrumb
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module ButtonHelper
|
5
|
+
def bui_button(label = nil, **options)
|
6
|
+
render BetterUi::General::ButtonComponent.new(
|
7
|
+
label: label,
|
8
|
+
**options
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Supporto per la sintassi originale per compatibilità
|
13
|
+
alias_method :better_ui_general_button, :bui_button
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BetterUi
|
2
|
+
module General
|
3
|
+
module Components
|
4
|
+
module HeadingHelper
|
5
|
+
def bui_heading(title = nil, **options)
|
6
|
+
render BetterUi::General::HeadingComponent.new(
|
7
|
+
title: title,
|
8
|
+
**options
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Supporto per la sintassi originale per compatibilità
|
13
|
+
alias_method :better_ui_general_heading, :bui_heading
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|