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
@@ -5,50 +5,50 @@ module BetterUi
|
|
5
5
|
|
6
6
|
# Temi di colore disponibili
|
7
7
|
AVATAR_THEME = {
|
8
|
-
default: "bui-avatar
|
9
|
-
white: "bui-avatar
|
10
|
-
red: "bui-avatar
|
11
|
-
rose: "bui-avatar
|
12
|
-
orange: "bui-avatar
|
13
|
-
green: "bui-avatar
|
14
|
-
blue: "bui-avatar
|
15
|
-
yellow: "bui-avatar
|
16
|
-
violet: "bui-avatar
|
17
|
-
gray: "bui-avatar
|
8
|
+
default: "bui-avatar--default",
|
9
|
+
white: "bui-avatar--white",
|
10
|
+
red: "bui-avatar--red",
|
11
|
+
rose: "bui-avatar--rose",
|
12
|
+
orange: "bui-avatar--orange",
|
13
|
+
green: "bui-avatar--green",
|
14
|
+
blue: "bui-avatar--blue",
|
15
|
+
yellow: "bui-avatar--yellow",
|
16
|
+
violet: "bui-avatar--violet",
|
17
|
+
gray: "bui-avatar--gray"
|
18
18
|
}
|
19
19
|
|
20
20
|
# Dimensioni disponibili
|
21
21
|
AVATAR_SIZES = {
|
22
|
-
xxsmall: "bui-avatar
|
23
|
-
xsmall: "bui-avatar
|
24
|
-
small: "bui-avatar
|
25
|
-
medium: "bui-avatar
|
26
|
-
large: "bui-avatar
|
27
|
-
xlarge: "bui-avatar
|
28
|
-
xxlarge: "bui-avatar
|
22
|
+
xxsmall: "bui-avatar--xxsmall",
|
23
|
+
xsmall: "bui-avatar--xsmall",
|
24
|
+
small: "bui-avatar--small",
|
25
|
+
medium: "bui-avatar--medium",
|
26
|
+
large: "bui-avatar--large",
|
27
|
+
xlarge: "bui-avatar--xlarge",
|
28
|
+
xxlarge: "bui-avatar--xxlarge"
|
29
29
|
}
|
30
30
|
|
31
31
|
# Forme disponibili
|
32
32
|
AVATAR_SHAPES = {
|
33
|
-
circle: "bui-avatar
|
34
|
-
square: "bui-avatar
|
35
|
-
rounded: "bui-avatar
|
33
|
+
circle: "bui-avatar--circle",
|
34
|
+
square: "bui-avatar--square",
|
35
|
+
rounded: "bui-avatar--rounded"
|
36
36
|
}
|
37
37
|
|
38
38
|
# Stati online disponibili
|
39
39
|
AVATAR_STATUS = {
|
40
|
-
online: "bui-
|
41
|
-
offline: "bui-
|
42
|
-
busy: "bui-
|
43
|
-
away: "bui-
|
40
|
+
online: "bui-avatar__status--online",
|
41
|
+
offline: "bui-avatar__status--offline",
|
42
|
+
busy: "bui-avatar__status--busy",
|
43
|
+
away: "bui-avatar__status--away"
|
44
44
|
}
|
45
45
|
|
46
46
|
# Posizioni dell'indicatore di stato
|
47
47
|
AVATAR_STATUS_POSITION = {
|
48
|
-
bottom_right: "bui-
|
49
|
-
bottom_left: "bui-
|
50
|
-
top_right: "bui-
|
51
|
-
top_left: "bui-
|
48
|
+
bottom_right: "bui-avatar__status--bottom-right",
|
49
|
+
bottom_left: "bui-avatar__status--bottom-left",
|
50
|
+
top_right: "bui-avatar__status--top-right",
|
51
|
+
top_left: "bui-avatar__status--top-left"
|
52
52
|
}
|
53
53
|
|
54
54
|
def initialize(
|
@@ -117,7 +117,7 @@ module BetterUi
|
|
117
117
|
# Restituisce le classi per l'indicatore di stato
|
118
118
|
def status_indicator_classes
|
119
119
|
[
|
120
|
-
"bui-
|
120
|
+
"bui-avatar__status",
|
121
121
|
get_avatar_status_class,
|
122
122
|
get_avatar_status_position_class
|
123
123
|
].compact.join(" ")
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<span <%= badge_attributes.to_s.html_safe %>>
|
2
2
|
<% if @icon && @icon_position == :left %>
|
3
|
-
<span class="
|
3
|
+
<span class="<%= icon_classes %>">
|
4
4
|
<%= render_icon(@icon) %>
|
5
5
|
</span>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% if @label.present? %>
|
9
|
-
<span class="
|
9
|
+
<span class="<%= text_classes %>"><%= @label %></span>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% if @icon && @icon_position == :right %>
|
13
|
-
<span class="
|
13
|
+
<span class="<%= icon_classes %>">
|
14
14
|
<%= render_icon(@icon) %>
|
15
15
|
</span>
|
16
16
|
<% end %>
|
@@ -5,38 +5,38 @@ module BetterUi
|
|
5
5
|
|
6
6
|
# Temi di colore disponibili
|
7
7
|
BADGE_THEME = {
|
8
|
-
default: "bui-badge
|
9
|
-
white: "bui-badge
|
10
|
-
red: "bui-badge
|
11
|
-
rose: "bui-badge
|
12
|
-
orange: "bui-badge
|
13
|
-
green: "bui-badge
|
14
|
-
blue: "bui-badge
|
15
|
-
yellow: "bui-badge
|
16
|
-
violet: "bui-badge
|
17
|
-
gray: "bui-badge
|
8
|
+
default: "bui-badge--default",
|
9
|
+
white: "bui-badge--white",
|
10
|
+
red: "bui-badge--red",
|
11
|
+
rose: "bui-badge--rose",
|
12
|
+
orange: "bui-badge--orange",
|
13
|
+
green: "bui-badge--green",
|
14
|
+
blue: "bui-badge--blue",
|
15
|
+
yellow: "bui-badge--yellow",
|
16
|
+
violet: "bui-badge--violet",
|
17
|
+
gray: "bui-badge--gray"
|
18
18
|
}
|
19
19
|
|
20
20
|
# Dimensioni disponibili
|
21
21
|
BADGE_SIZES = {
|
22
|
-
small: "bui-badge
|
23
|
-
medium: "bui-badge
|
24
|
-
large: "bui-badge
|
22
|
+
small: "bui-badge--small",
|
23
|
+
medium: "bui-badge--medium",
|
24
|
+
large: "bui-badge--large"
|
25
25
|
}
|
26
26
|
|
27
27
|
# Border radius disponibili
|
28
28
|
BADGE_RADIUS = {
|
29
|
-
none: "bui-badge
|
30
|
-
small: "bui-badge
|
31
|
-
medium: "bui-badge
|
32
|
-
large: "bui-badge
|
33
|
-
full: "bui-badge
|
29
|
+
none: "bui-badge--square",
|
30
|
+
small: "bui-badge--square",
|
31
|
+
medium: "bui-badge--square",
|
32
|
+
large: "bui-badge--square",
|
33
|
+
full: "bui-badge--pill"
|
34
34
|
}
|
35
35
|
|
36
36
|
# Stati e varianti
|
37
37
|
BADGE_VARIANTS = {
|
38
|
-
outline: "bui-badge
|
39
|
-
notification: "bui-badge
|
38
|
+
outline: "bui-badge--outline",
|
39
|
+
notification: "bui-badge--notification"
|
40
40
|
}
|
41
41
|
|
42
42
|
# Inizializzazione del componente
|
@@ -99,6 +99,18 @@ module BetterUi
|
|
99
99
|
attrs
|
100
100
|
end
|
101
101
|
|
102
|
+
def icon_classes
|
103
|
+
if @icon_position == :left
|
104
|
+
"bui-badge__icon bui-badge__icon--left"
|
105
|
+
else
|
106
|
+
"bui-badge__icon bui-badge__icon--right"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def text_classes
|
111
|
+
"bui-badge__text"
|
112
|
+
end
|
113
|
+
|
102
114
|
# Helper per renderizzare le icone
|
103
115
|
def render_icon(icon_name)
|
104
116
|
# Mappa le dimensioni del badge alle dimensioni dell'icona
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<nav aria-label="Breadcrumb" class="<%= container_classes %>">
|
2
|
-
<ol class="bui-
|
2
|
+
<ol class="bui-breadcrumb__list">
|
3
3
|
<% @items.each_with_index do |item, index| %>
|
4
|
-
<li class="bui-
|
4
|
+
<li class="bui-breadcrumb__item">
|
5
5
|
<%= render link_for_item(item, active: last_item?(index)) %>
|
6
6
|
|
7
7
|
<% unless last_item?(index) %>
|
@@ -6,48 +6,48 @@ module BetterUi
|
|
6
6
|
# Temi di colore disponibili
|
7
7
|
BREADCRUMB_THEME = {
|
8
8
|
default: {
|
9
|
-
container: "bui-breadcrumb
|
10
|
-
separator: "bui-
|
9
|
+
container: "bui-breadcrumb--default",
|
10
|
+
separator: "bui-breadcrumb__separator--default"
|
11
11
|
},
|
12
12
|
white: {
|
13
|
-
container: "bui-breadcrumb
|
14
|
-
separator: "bui-
|
13
|
+
container: "bui-breadcrumb--white",
|
14
|
+
separator: "bui-breadcrumb__separator--white"
|
15
15
|
},
|
16
16
|
red: {
|
17
|
-
container: "bui-breadcrumb
|
18
|
-
separator: "bui-
|
17
|
+
container: "bui-breadcrumb--red",
|
18
|
+
separator: "bui-breadcrumb__separator--red"
|
19
19
|
},
|
20
20
|
rose: {
|
21
|
-
container: "bui-breadcrumb
|
22
|
-
separator: "bui-
|
21
|
+
container: "bui-breadcrumb--rose",
|
22
|
+
separator: "bui-breadcrumb__separator--rose"
|
23
23
|
},
|
24
24
|
orange: {
|
25
|
-
container: "bui-breadcrumb
|
26
|
-
separator: "bui-
|
25
|
+
container: "bui-breadcrumb--orange",
|
26
|
+
separator: "bui-breadcrumb__separator--orange"
|
27
27
|
},
|
28
28
|
green: {
|
29
|
-
container: "bui-breadcrumb
|
30
|
-
separator: "bui-
|
29
|
+
container: "bui-breadcrumb--green",
|
30
|
+
separator: "bui-breadcrumb__separator--green"
|
31
31
|
},
|
32
32
|
blue: {
|
33
|
-
container: "bui-breadcrumb
|
34
|
-
separator: "bui-
|
33
|
+
container: "bui-breadcrumb--blue",
|
34
|
+
separator: "bui-breadcrumb__separator--blue"
|
35
35
|
},
|
36
36
|
yellow: {
|
37
|
-
container: "bui-breadcrumb
|
38
|
-
separator: "bui-
|
37
|
+
container: "bui-breadcrumb--yellow",
|
38
|
+
separator: "bui-breadcrumb__separator--yellow"
|
39
39
|
},
|
40
40
|
violet: {
|
41
|
-
container: "bui-breadcrumb
|
42
|
-
separator: "bui-
|
41
|
+
container: "bui-breadcrumb--violet",
|
42
|
+
separator: "bui-breadcrumb__separator--violet"
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
46
|
# Dimensioni disponibili
|
47
47
|
BREADCRUMB_SIZES = {
|
48
|
-
small: "bui-breadcrumb
|
49
|
-
medium: "bui-breadcrumb
|
50
|
-
large: "bui-breadcrumb
|
48
|
+
small: "bui-breadcrumb--small",
|
49
|
+
medium: "bui-breadcrumb--medium",
|
50
|
+
large: "bui-breadcrumb--large"
|
51
51
|
}
|
52
52
|
|
53
53
|
# Separatori predefiniti
|
@@ -86,7 +86,7 @@ module BetterUi
|
|
86
86
|
# Genera le classi per il container
|
87
87
|
def container_classes
|
88
88
|
[
|
89
|
-
"bui-breadcrumb
|
89
|
+
"bui-breadcrumb",
|
90
90
|
BREADCRUMB_SIZES.fetch(@size, BREADCRUMB_SIZES[:medium]),
|
91
91
|
BREADCRUMB_THEME.fetch(@theme, BREADCRUMB_THEME[:default])[:container],
|
92
92
|
@classes
|
@@ -96,7 +96,7 @@ module BetterUi
|
|
96
96
|
# Genera le classi per il separatore
|
97
97
|
def separator_classes
|
98
98
|
[
|
99
|
-
"bui-
|
99
|
+
"bui-breadcrumb__separator",
|
100
100
|
BREADCRUMB_THEME.fetch(@theme, BREADCRUMB_THEME[:default])[:separator]
|
101
101
|
].compact.join(" ")
|
102
102
|
end
|
@@ -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="bui-
|
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><%= @label %></span>
|
9
|
+
<span class="bui-button__text"><%= @label %></span>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% if @icon && @icon_position == :right %>
|
13
|
-
<span class="bui-
|
13
|
+
<span class="bui-button__icon bui-button__icon--right"><%= render_icon(@icon) %></span>
|
14
14
|
<% end %>
|
15
15
|
|
16
16
|
<%= content %>
|
@@ -18,15 +18,15 @@
|
|
18
18
|
<% else %>
|
19
19
|
<%= tag.button(**button_attributes) do %>
|
20
20
|
<% if @icon && @icon_position == :left %>
|
21
|
-
<span class="bui-
|
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><%= @label %></span>
|
25
|
+
<span class="bui-button__text"><%= @label %></span>
|
26
26
|
<% end %>
|
27
27
|
|
28
28
|
<% if @icon && @icon_position == :right %>
|
29
|
-
<span class="bui-
|
29
|
+
<span class="bui-button__icon bui-button__icon--right"><%= render_icon(@icon) %></span>
|
30
30
|
<% end %>
|
31
31
|
|
32
32
|
<%= content %>
|
@@ -6,37 +6,37 @@ module BetterUi
|
|
6
6
|
|
7
7
|
# Temi di bottoni disponibili con classi CSS personalizzate
|
8
8
|
BUTTON_THEME = {
|
9
|
-
default: "bui-
|
10
|
-
white: "bui-
|
11
|
-
red: "bui-
|
12
|
-
rose: "bui-
|
13
|
-
orange: "bui-
|
14
|
-
green: "bui-
|
15
|
-
blue: "bui-
|
16
|
-
yellow: "bui-
|
17
|
-
violet: "bui-
|
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
18
|
}
|
19
19
|
|
20
20
|
# Dimensioni disponibili con classi CSS personalizzate
|
21
21
|
BUTTON_SIZES = {
|
22
|
-
small: "bui-
|
23
|
-
medium: "bui-
|
24
|
-
large: "bui-
|
22
|
+
small: "bui-button--small",
|
23
|
+
medium: "bui-button--medium",
|
24
|
+
large: "bui-button--large"
|
25
25
|
}
|
26
26
|
|
27
27
|
# Border radius disponibili con classi CSS personalizzate
|
28
28
|
BUTTON_RADIUS = {
|
29
|
-
none: "bui-
|
30
|
-
small: "bui-
|
31
|
-
medium: "bui-
|
32
|
-
large: "bui-
|
33
|
-
full: "bui-
|
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
34
|
}
|
35
35
|
|
36
36
|
# Stati e comportamenti del bottone
|
37
37
|
BUTTON_STATES = {
|
38
|
-
disabled: "bui-
|
39
|
-
full_width: "bui-
|
38
|
+
disabled: "bui-button--disabled",
|
39
|
+
full_width: "bui-button--full-width"
|
40
40
|
}
|
41
41
|
|
42
42
|
# Layout e stili comuni
|
@@ -84,9 +84,7 @@ module BetterUi
|
|
84
84
|
# Combina tutte le classi
|
85
85
|
def combined_classes
|
86
86
|
[
|
87
|
-
"bui-
|
88
|
-
BUTTON_LAYOUT[:default],
|
89
|
-
BUTTON_LAYOUT[:focus],
|
87
|
+
"bui-button", # Classe base per tutti i bottoni
|
90
88
|
get_border_radius_class,
|
91
89
|
get_button_type_classes,
|
92
90
|
get_button_size_classes,
|
@@ -1,25 +1 @@
|
|
1
|
-
|
2
|
-
<%# Utilizzo di tag heading dinamico in base al livello specificato %>
|
3
|
-
<<%= "h#{@level}" %> class="<%= heading_classes %>">
|
4
|
-
<% if @icon.present? %>
|
5
|
-
<span class="bui-header-icon-container">
|
6
|
-
<span class="bui-header-icon-wrapper">
|
7
|
-
<%= render BetterUi::General::IconComponent.new(name: @icon, size: get_icon_size) %>
|
8
|
-
</span>
|
9
|
-
<%= @text || content %>
|
10
|
-
</span>
|
11
|
-
<% else %>
|
12
|
-
<%= @text || content %>
|
13
|
-
<% end %>
|
14
|
-
</<%= "h#{@level}" %>>
|
15
|
-
|
16
|
-
<% if @subtitle.present? %>
|
17
|
-
<div class="<%= subtitle_classes %>">
|
18
|
-
<%= @subtitle %>
|
19
|
-
</div>
|
20
|
-
<% end %>
|
21
|
-
|
22
|
-
<% if @with_divider %>
|
23
|
-
<div class="<%= divider_classes %>"></div>
|
24
|
-
<% end %>
|
25
|
-
</div>
|
1
|
+
<%= content_tag("h#{@level}", content, class: heading_classes) %>
|
@@ -1,148 +1,49 @@
|
|
1
1
|
module BetterUi
|
2
2
|
module General
|
3
3
|
class HeadingComponent < ViewComponent::Base
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :level, :variant, :align, :classes
|
5
5
|
|
6
6
|
# Varianti di colore disponibili
|
7
7
|
HEADER_THEME = {
|
8
|
-
default:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
},
|
18
|
-
red: {
|
19
|
-
heading: "bui-header-red-heading",
|
20
|
-
subtitle: "bui-header-red-subtitle",
|
21
|
-
divider: "bui-header-red-divider"
|
22
|
-
},
|
23
|
-
rose: {
|
24
|
-
heading: "bui-header-rose-heading",
|
25
|
-
subtitle: "bui-header-rose-subtitle",
|
26
|
-
divider: "bui-header-rose-divider"
|
27
|
-
},
|
28
|
-
orange: {
|
29
|
-
heading: "bui-header-orange-heading",
|
30
|
-
subtitle: "bui-header-orange-subtitle",
|
31
|
-
divider: "bui-header-orange-divider"
|
32
|
-
},
|
33
|
-
green: {
|
34
|
-
heading: "bui-header-green-heading",
|
35
|
-
subtitle: "bui-header-green-subtitle",
|
36
|
-
divider: "bui-header-green-divider"
|
37
|
-
},
|
38
|
-
blue: {
|
39
|
-
heading: "bui-header-blue-heading",
|
40
|
-
subtitle: "bui-header-blue-subtitle",
|
41
|
-
divider: "bui-header-blue-divider"
|
42
|
-
},
|
43
|
-
yellow: {
|
44
|
-
heading: "bui-header-yellow-heading",
|
45
|
-
subtitle: "bui-header-yellow-subtitle",
|
46
|
-
divider: "bui-header-yellow-divider"
|
47
|
-
},
|
48
|
-
violet: {
|
49
|
-
heading: "bui-header-violet-heading",
|
50
|
-
subtitle: "bui-header-violet-subtitle",
|
51
|
-
divider: "bui-header-violet-divider"
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
# Dimensioni disponibili
|
56
|
-
HEADER_SIZES = {
|
57
|
-
small: {
|
58
|
-
heading: "bui-header-small-heading",
|
59
|
-
subtitle: "bui-header-small-subtitle"
|
60
|
-
},
|
61
|
-
medium: {
|
62
|
-
heading: "bui-header-medium-heading",
|
63
|
-
subtitle: "bui-header-medium-subtitle"
|
64
|
-
},
|
65
|
-
large: {
|
66
|
-
heading: "bui-header-large-heading",
|
67
|
-
subtitle: "bui-header-large-subtitle"
|
68
|
-
}
|
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"
|
69
17
|
}
|
70
18
|
|
71
19
|
# Allineamenti disponibili
|
72
20
|
HEADER_ALIGNMENTS = {
|
73
|
-
left: "bui-
|
74
|
-
center: "bui-
|
75
|
-
right: "bui-
|
21
|
+
left: "bui-heading--left",
|
22
|
+
center: "bui-heading--center",
|
23
|
+
right: "bui-heading--right"
|
76
24
|
}
|
77
25
|
|
78
|
-
# Inizializzazione del componente
|
79
26
|
def initialize(
|
80
|
-
text: nil,
|
81
27
|
level: 2,
|
82
28
|
variant: :default,
|
83
|
-
size: :medium,
|
84
29
|
align: :left,
|
85
|
-
classes: nil
|
86
|
-
icon: nil,
|
87
|
-
subtitle: nil,
|
88
|
-
with_divider: false
|
30
|
+
classes: nil
|
89
31
|
)
|
90
|
-
@text = text
|
91
32
|
@level = level.to_i.clamp(1, 6)
|
92
33
|
@variant = variant.to_sym
|
93
|
-
@size = size.to_sym
|
94
34
|
@align = align.to_sym
|
95
35
|
@classes = classes
|
96
|
-
@icon = icon
|
97
|
-
@subtitle = subtitle
|
98
|
-
@with_divider = with_divider
|
99
36
|
end
|
100
37
|
|
101
|
-
# Genera le classi per l'heading
|
102
38
|
def heading_classes
|
103
39
|
[
|
104
|
-
|
105
|
-
|
40
|
+
"bui-heading",
|
41
|
+
"bui-heading--#{@level}",
|
42
|
+
HEADER_THEME.fetch(@variant, HEADER_THEME[:default]),
|
106
43
|
HEADER_ALIGNMENTS.fetch(@align, HEADER_ALIGNMENTS[:left]),
|
107
|
-
"bui-header-heading-base",
|
108
44
|
@classes
|
109
45
|
].compact.join(" ")
|
110
46
|
end
|
111
|
-
|
112
|
-
# Genera le classi per il sottotitolo
|
113
|
-
def subtitle_classes
|
114
|
-
[
|
115
|
-
HEADER_THEME.fetch(@variant, HEADER_THEME[:default])[:subtitle],
|
116
|
-
HEADER_SIZES.fetch(@size, HEADER_SIZES[:medium])[:subtitle],
|
117
|
-
HEADER_ALIGNMENTS.fetch(@align, HEADER_ALIGNMENTS[:left]),
|
118
|
-
"bui-header-subtitle-base"
|
119
|
-
].compact.join(" ")
|
120
|
-
end
|
121
|
-
|
122
|
-
# Genera le classi per il divisore
|
123
|
-
def divider_classes
|
124
|
-
[
|
125
|
-
"bui-header-divider-base",
|
126
|
-
HEADER_THEME.fetch(@variant, HEADER_THEME[:default])[:divider]
|
127
|
-
].compact.join(" ")
|
128
|
-
end
|
129
|
-
|
130
|
-
# Genera le classi per il container
|
131
|
-
def container_classes
|
132
|
-
@with_divider ? "bui-header-container-with-divider" : "bui-header-container-base"
|
133
|
-
end
|
134
|
-
|
135
|
-
# Helper per determinare la dimensione dell'icona in base alla dimensione dell'heading
|
136
|
-
def get_icon_size
|
137
|
-
case @size
|
138
|
-
when :large
|
139
|
-
:medium
|
140
|
-
when :small
|
141
|
-
:xsmall
|
142
|
-
else
|
143
|
-
:small
|
144
|
-
end
|
145
|
-
end
|
146
47
|
end
|
147
48
|
end
|
148
49
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<%# Template per l'icona %>
|
2
|
-
<i class="
|
2
|
+
<i class="<%= combined_classes %>" aria-hidden="true"></i>
|