iron_admin 0.7.0 → 0.8.0
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/CHANGELOG.md +129 -1
- data/README.md +48 -1
- data/UPGRADING.md +495 -8
- data/app/assets/tailwind/iron_admin/engine.css +79 -4
- data/app/components/iron_admin/dashboards/activity_feed_component/item_component.html.haml +6 -9
- data/app/components/iron_admin/dashboards/activity_feed_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/activity_feed_component.rb +21 -24
- data/app/components/iron_admin/dashboards/chart_component.html.haml +3 -5
- data/app/components/iron_admin/dashboards/chart_component.rb +86 -24
- data/app/components/iron_admin/dashboards/concerns/themed_card.rb +39 -0
- data/app/components/iron_admin/dashboards/metric_card_component.html.haml +8 -7
- data/app/components/iron_admin/dashboards/metric_card_component.rb +2 -0
- data/app/components/iron_admin/dashboards/progress_component.html.haml +11 -7
- data/app/components/iron_admin/dashboards/progress_component.rb +11 -6
- data/app/components/iron_admin/dashboards/quick_links_component/link_component.html.haml +8 -9
- data/app/components/iron_admin/dashboards/quick_links_component.html.haml +6 -5
- data/app/components/iron_admin/dashboards/quick_links_component.rb +4 -12
- data/app/components/iron_admin/dashboards/recent_table_component.html.haml +15 -10
- data/app/components/iron_admin/dashboards/recent_table_component.rb +49 -0
- data/app/components/iron_admin/dashboards/stats_grid_component/stat_component.html.haml +13 -14
- data/app/components/iron_admin/dashboards/stats_grid_component.html.haml +1 -0
- data/app/components/iron_admin/dashboards/stats_grid_component.rb +9 -11
- data/app/components/iron_admin/filters/bar_component.html.haml +8 -6
- data/app/components/iron_admin/filters/bar_component.rb +56 -9
- data/app/components/iron_admin/filters/control_styles.rb +82 -0
- data/app/components/iron_admin/filters/date_range_component.html.haml +9 -4
- data/app/components/iron_admin/filters/date_range_component.rb +10 -6
- data/app/components/iron_admin/filters/search_component.html.haml +4 -4
- data/app/components/iron_admin/filters/search_component.rb +3 -5
- data/app/components/iron_admin/filters/select_filter_component.html.haml +1 -1
- data/app/components/iron_admin/filters/select_filter_component.rb +5 -16
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.html.haml +9 -5
- data/app/components/iron_admin/form/belongs_to_autocomplete_component.rb +10 -8
- data/app/components/iron_admin/form/belongs_to_component.html.haml +2 -2
- data/app/components/iron_admin/form/belongs_to_component.rb +4 -18
- data/app/components/iron_admin/form/checkbox_component.rb +2 -3
- data/app/components/iron_admin/form/concerns/form_input_behavior.rb +1 -1
- data/app/components/iron_admin/form/control_classes.rb +108 -0
- data/app/components/iron_admin/form/date_picker_component.rb +3 -7
- data/app/components/iron_admin/form/field_wrapper_component.html.haml +3 -3
- data/app/components/iron_admin/form/field_wrapper_component.rb +3 -3
- data/app/components/iron_admin/form/nested_form_component.html.haml +4 -5
- data/app/components/iron_admin/form/nested_form_component.rb +12 -2
- data/app/components/iron_admin/form/select_component.html.haml +1 -1
- data/app/components/iron_admin/form/select_component.rb +2 -16
- data/app/components/iron_admin/form/text_input_component.rb +1 -5
- data/app/components/iron_admin/form/textarea_component.rb +1 -5
- data/app/components/iron_admin/layout/flash_component.html.haml +1 -1
- data/app/components/iron_admin/layout/flash_component.rb +4 -3
- data/app/components/iron_admin/layout/navbar_component.html.haml +15 -9
- data/app/components/iron_admin/layout/navbar_component.rb +29 -1
- data/app/components/iron_admin/layout/shell_component.html.haml +4 -4
- data/app/components/iron_admin/layout/shell_component.rb +16 -3
- data/app/components/iron_admin/layout/sidebar_component.html.haml +21 -25
- data/app/components/iron_admin/layout/sidebar_component.rb +76 -1
- data/app/components/iron_admin/layout/theme_switcher_component.html.haml +15 -0
- data/app/components/iron_admin/layout/theme_switcher_component.rb +74 -0
- data/app/components/iron_admin/resources/actions_component.html.haml +15 -8
- data/app/components/iron_admin/resources/actions_component.rb +34 -2
- data/app/components/iron_admin/resources/breadcrumb_component.html.haml +3 -3
- data/app/components/iron_admin/resources/breadcrumb_component.rb +8 -7
- data/app/components/iron_admin/resources/bulk_actions_component.html.haml +9 -8
- data/app/components/iron_admin/resources/bulk_actions_component.rb +47 -4
- data/app/components/iron_admin/resources/data_table_component.html.haml +15 -15
- data/app/components/iron_admin/resources/data_table_component.rb +34 -3
- data/app/components/iron_admin/resources/related_list_component.html.haml +7 -7
- data/app/components/iron_admin/resources/related_list_component.rb +26 -2
- data/app/components/iron_admin/resources/show_field_component.html.haml +3 -3
- data/app/components/iron_admin/resources/show_field_component.rb +10 -4
- data/app/components/iron_admin/resources/styles.rb +136 -0
- data/app/components/iron_admin/ui/alert_component.html.haml +2 -2
- data/app/components/iron_admin/ui/alert_component.rb +27 -31
- data/app/components/iron_admin/ui/badge_component.rb +40 -20
- data/app/components/iron_admin/ui/button_component.rb +37 -11
- data/app/components/iron_admin/ui/card_component.rb +3 -3
- data/app/components/iron_admin/ui/dropdown_component.html.haml +1 -1
- data/app/components/iron_admin/ui/dropdown_component.rb +34 -13
- data/app/components/iron_admin/ui/empty_state_component.html.haml +4 -5
- data/app/components/iron_admin/ui/empty_state_component.rb +2 -2
- data/app/components/iron_admin/ui/modal_component.html.haml +5 -5
- data/app/components/iron_admin/ui/modal_component.rb +6 -4
- data/app/components/iron_admin/ui/pagination_component.html.haml +14 -14
- data/app/components/iron_admin/ui/pagination_component.rb +26 -9
- data/app/components/iron_admin/ui/scopes_component.html.haml +2 -2
- data/app/components/iron_admin/ui/scopes_component.rb +44 -11
- data/app/components/iron_admin/ui/tooltip_component.rb +11 -4
- data/app/controllers/iron_admin/application_controller.rb +58 -4
- data/app/controllers/iron_admin/audit_controller.rb +30 -6
- data/app/controllers/iron_admin/concerns/action_executable.rb +37 -0
- data/app/controllers/iron_admin/concerns/assignable_references.rb +149 -0
- data/app/controllers/iron_admin/concerns/authorizable.rb +11 -0
- data/app/controllers/iron_admin/concerns/blank_password_filterable.rb +21 -0
- data/app/controllers/iron_admin/concerns/event_emittable.rb +47 -7
- data/app/controllers/iron_admin/concerns/filterable.rb +34 -9
- data/app/controllers/iron_admin/concerns/nested_permittable.rb +5 -3
- data/app/controllers/iron_admin/concerns/nested_tenant_check.rb +159 -0
- data/app/controllers/iron_admin/concerns/polymorphic_references.rb +131 -0
- data/app/controllers/iron_admin/concerns/scopeable.rb +54 -7
- data/app/controllers/iron_admin/concerns/searchable.rb +3 -3
- data/app/controllers/iron_admin/concerns/tenant_assignable.rb +118 -0
- data/app/controllers/iron_admin/concerns/tenant_containment.rb +146 -0
- data/app/controllers/iron_admin/exports_controller.rb +2 -2
- data/app/controllers/iron_admin/imports_controller.rb +1 -1
- data/app/controllers/iron_admin/resources_controller.rb +48 -41
- data/app/controllers/iron_admin/search_controller.rb +1 -2
- data/app/controllers/iron_admin/themes_controller.rb +50 -0
- data/app/controllers/iron_admin/tools_controller.rb +58 -5
- data/app/helpers/iron_admin/action_form_helper.rb +19 -0
- data/app/helpers/iron_admin/application_helper.rb +93 -16
- data/app/helpers/iron_admin/assignable_records_helper.rb +32 -0
- data/app/helpers/iron_admin/component_overrides_helper.rb +9 -4
- data/app/helpers/iron_admin/field_display_helper.rb +88 -43
- data/app/helpers/iron_admin/related_records_helper.rb +51 -0
- data/app/helpers/iron_admin/theme_helper.rb +56 -46
- data/app/javascript/iron_admin/controllers/cp_bulk_select_controller.js +12 -0
- data/app/javascript/iron_admin/controllers/cp_chart_controller.js +4 -0
- data/app/javascript/iron_admin/controllers/cp_disclosure_controller.js +19 -0
- data/app/javascript/iron_admin/controllers/cp_search_shortcut_controller.js +39 -0
- data/app/javascript/iron_admin/index.js +4 -0
- data/app/views/iron_admin/audit/index.html.haml +78 -81
- data/app/views/iron_admin/dashboard/index.html.haml +10 -9
- data/app/views/iron_admin/form/_action_field.html.haml +50 -0
- data/app/views/iron_admin/form/_nested_row.html.haml +18 -13
- data/app/views/iron_admin/imports/new.html.haml +14 -13
- data/app/views/iron_admin/imports/preview.html.haml +24 -21
- data/app/views/iron_admin/resources/_form.html.haml +70 -68
- data/app/views/iron_admin/resources/action_form.html.haml +16 -59
- data/app/views/iron_admin/resources/bulk_action_form.html.haml +20 -58
- data/app/views/iron_admin/resources/edit.html.haml +3 -3
- data/app/views/iron_admin/resources/index.html.haml +87 -74
- data/app/views/iron_admin/resources/new.html.haml +2 -2
- data/app/views/iron_admin/resources/show.html.haml +53 -41
- data/app/views/iron_admin/search/index.html.haml +17 -9
- data/app/views/iron_admin/shared/_pagination.html.haml +13 -10
- data/app/views/iron_admin/shared/error.html.haml +16 -12
- data/app/views/iron_admin/tools/action_form.html.haml +9 -55
- data/app/views/iron_admin/tools/show.html.haml +4 -5
- data/app/views/layouts/iron_admin/_document_head.html.haml +24 -0
- data/app/views/layouts/iron_admin/application.html.haml +4 -17
- data/app/views/layouts/iron_admin/minimal.html.haml +7 -0
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +1 -0
- data/docs/FAQ.md +87 -37
- data/docs/README.md +8 -2
- data/docs/components/README.md +6 -2
- data/docs/components/dashboard-components.md +24 -35
- data/docs/components/filter-components.md +44 -92
- data/docs/components/form-components.md +16 -32
- data/docs/components/resource-components.md +46 -27
- data/docs/components/ui-components.md +44 -26
- data/docs/getting-started/installation.md +5 -1
- data/docs/getting-started/quick-start.md +36 -23
- data/docs/guides/authentication.md +182 -42
- data/docs/guides/components.md +97 -15
- data/docs/guides/custom-adapters.md +24 -4
- data/docs/guides/dashboard.md +68 -44
- data/docs/guides/export.md +24 -8
- data/docs/guides/extending.md +206 -51
- data/docs/guides/fields.md +229 -70
- data/docs/guides/imports.md +33 -18
- data/docs/guides/resources.md +333 -111
- data/docs/guides/theming.md +930 -58
- data/docs/guides/troubleshooting.md +7 -3
- data/docs/plugin-system-design.md +8 -7
- data/docs/reference/configuration.md +51 -16
- data/docs/reference/routes.md +1 -0
- data/docs/reference/theme-properties.md +101 -38
- data/lib/generators/iron_admin/install/templates/initializer.rb.tt +7 -2
- data/lib/generators/iron_admin/install_audit/templates/create_iron_admin_audit_entries.rb.tt +2 -0
- data/lib/iron_admin/action_field.rb +11 -0
- data/lib/iron_admin/adapters/active_record.rb +95 -0
- data/lib/iron_admin/adapters/base.rb +107 -0
- data/lib/iron_admin/adapters/http/query.rb +21 -0
- data/lib/iron_admin/adapters/http.rb +84 -4
- data/lib/iron_admin/adapters/mongoid.rb +96 -2
- data/lib/iron_admin/audit_log.rb +64 -6
- data/lib/iron_admin/authentication_warning.rb +31 -0
- data/lib/iron_admin/concerns/filter_definable.rb +15 -1
- data/lib/iron_admin/concerns/nestable.rb +25 -0
- data/lib/iron_admin/concerns/scope_countable.rb +56 -0
- data/lib/iron_admin/concerns/soft_deletable.rb +28 -9
- data/lib/iron_admin/configuration/components.rb +14 -3
- data/lib/iron_admin/configuration/theme/neutral_defaults.rb +179 -0
- data/lib/iron_admin/configuration/theme.rb +292 -87
- data/lib/iron_admin/configuration.rb +340 -45
- data/lib/iron_admin/dashboard.rb +22 -38
- data/lib/iron_admin/engine.rb +16 -2
- data/lib/iron_admin/errors.rb +3 -0
- data/lib/iron_admin/field.rb +78 -17
- data/lib/iron_admin/field_inferrer.rb +61 -3
- data/lib/iron_admin/field_override_warning.rb +67 -0
- data/lib/iron_admin/import/import_preview.rb +56 -7
- data/lib/iron_admin/import/importer.rb +91 -14
- data/lib/iron_admin/import/tenant_precheck.rb +67 -0
- data/lib/iron_admin/plugin/registration.rb +64 -0
- data/lib/iron_admin/plugin_registry.rb +3 -2
- data/lib/iron_admin/policy.rb +22 -12
- data/lib/iron_admin/policy_coverage_warning.rb +46 -0
- data/lib/iron_admin/request_context.rb +18 -0
- data/lib/iron_admin/resource.rb +218 -77
- data/lib/iron_admin/resource_registry.rb +86 -13
- data/lib/iron_admin/scope_counts.rb +73 -0
- data/lib/iron_admin/tenant_scope.rb +30 -0
- data/lib/iron_admin/tool.rb +61 -12
- data/lib/iron_admin/tool_context.rb +10 -6
- data/lib/iron_admin/version.rb +1 -1
- data/lib/iron_admin.rb +29 -2
- metadata +37 -7
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "theme/neutral_defaults"
|
|
4
|
+
|
|
3
5
|
module IronAdmin
|
|
4
6
|
class Configuration
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# complete customization of colors, spacing, and visual styles.
|
|
9
|
-
#
|
|
10
|
-
# @example Customizing the theme
|
|
11
|
-
# IronAdmin.configure do |config|
|
|
12
|
-
# config.theme do |t|
|
|
13
|
-
# t.btn_primary = "bg-blue-600 text-white hover:bg-blue-700"
|
|
14
|
-
# t.sidebar_bg = "bg-slate-900"
|
|
15
|
-
# t.link = "text-blue-600 hover:text-blue-800"
|
|
16
|
-
# end
|
|
17
|
-
# end
|
|
7
|
+
# A named look of the admin panel. A new Theme holds the values of the built-in
|
|
8
|
+
# Neutral look. Properties hold Tailwind classes, except the chart properties (CSS
|
|
9
|
+
# colors, a Chart.js point style and a width), the font stylesheet URL and the color scheme.
|
|
18
10
|
#
|
|
19
11
|
# @see IronAdmin::Configuration#theme
|
|
12
|
+
# @see IronAdmin::Configuration#register_theme
|
|
20
13
|
class Theme
|
|
14
|
+
# Tailwind class that sets the CSS +color-scheme+ of each {#color_scheme}.
|
|
15
|
+
# @return [Hash{String => String}]
|
|
16
|
+
SCHEME_CLASSES = { "light" => "scheme-light", "dark" => "scheme-dark" }.freeze
|
|
17
|
+
|
|
18
|
+
# @return [Symbol] Name the theme is registered under (and the value of the theme cookie)
|
|
19
|
+
attr_reader :name
|
|
20
|
+
|
|
21
|
+
# @return [String] Human name shown in the theme switcher
|
|
22
|
+
attr_reader :label
|
|
23
|
+
|
|
21
24
|
# @!group Button Styles
|
|
22
25
|
|
|
23
|
-
# @return [String] Primary button
|
|
26
|
+
# @return [String] Primary button colors and focus outline
|
|
24
27
|
attr_accessor :btn_primary
|
|
25
28
|
|
|
26
|
-
# @return [String] Secondary button
|
|
29
|
+
# @return [String] Secondary button colors and border
|
|
27
30
|
attr_accessor :btn_secondary
|
|
28
31
|
|
|
29
|
-
# @return [String] Danger/destructive button
|
|
32
|
+
# @return [String] Danger/destructive button colors
|
|
30
33
|
attr_accessor :btn_danger
|
|
31
34
|
|
|
32
|
-
# @return [String] Ghost button
|
|
35
|
+
# @return [String] Ghost button colors
|
|
33
36
|
attr_accessor :btn_ghost
|
|
34
37
|
|
|
35
38
|
# @!endgroup
|
|
@@ -46,18 +49,62 @@ module IronAdmin
|
|
|
46
49
|
|
|
47
50
|
# @!group Form Styles
|
|
48
51
|
|
|
49
|
-
# @return [String] Focus
|
|
52
|
+
# @return [String] Focus indicator of interactive elements other than inputs
|
|
50
53
|
attr_accessor :focus_ring
|
|
51
54
|
|
|
52
|
-
# @return [String]
|
|
55
|
+
# @return [String] Border color, with hover, of inputs, selects, textareas, the file input and
|
|
56
|
+
# the navbar search. An empty input shows nothing but this outline, so keep 3:1 against
|
|
57
|
+
# {#card_bg} (WCAG 1.4.11): Neutral's zinc-500 at 80% is 3.3:1 on white, while zinc-200 to
|
|
58
|
+
# zinc-400 are below 3:1
|
|
53
59
|
attr_accessor :input_border
|
|
54
60
|
|
|
55
61
|
# @return [String] Input focus state classes
|
|
56
62
|
attr_accessor :input_focus
|
|
57
63
|
|
|
58
|
-
# @return [String]
|
|
64
|
+
# @return [String] Border and background color of checked checkboxes and radio buttons, and
|
|
65
|
+
# their focus ring. The check mark and the radio dot are always white (engine.css), in
|
|
66
|
+
# every color_scheme, so the checked background needs 3:1 contrast against white
|
|
67
|
+
# (WCAG 1.4.11)
|
|
59
68
|
attr_accessor :checkbox_checked
|
|
60
69
|
|
|
70
|
+
# @return [String] Border color of unchecked checkboxes and radio buttons. It is all that
|
|
71
|
+
# shows an unchecked control, so keep 3:1 against {#card_bg} (WCAG 1.4.11): Neutral's
|
|
72
|
+
# zinc-500 is 4.8:1 on white, while zinc-300 and zinc-400 are below 3:1
|
|
73
|
+
attr_accessor :checkbox_border
|
|
74
|
+
|
|
75
|
+
# @return [String] Radius of checkboxes (radio buttons are always round)
|
|
76
|
+
attr_accessor :checkbox_radius
|
|
77
|
+
|
|
78
|
+
# @return [String] Border color and focus state (ring width included) of inputs with
|
|
79
|
+
# validation errors, used instead of {#input_border} and {#input_focus}. Keep the border at
|
|
80
|
+
# 3:1 too: Neutral's red-500 is 3.8:1 on white, red-400 is 2.9:1
|
|
81
|
+
attr_accessor :input_error
|
|
82
|
+
|
|
83
|
+
# @return [String] Color of input placeholders (with the +placeholder:+ variant)
|
|
84
|
+
attr_accessor :placeholder_text
|
|
85
|
+
|
|
86
|
+
# @return [String] Color of disabled pagination links and controls
|
|
87
|
+
attr_accessor :disabled_text
|
|
88
|
+
|
|
89
|
+
# @return [String] Radius of inputs, buttons, selects and dropdown items
|
|
90
|
+
attr_accessor :control_radius
|
|
91
|
+
|
|
92
|
+
# @return [String] Shadow of inputs, selects, textareas and buttons other than ghost ones (empty = none)
|
|
93
|
+
attr_accessor :control_shadow
|
|
94
|
+
|
|
95
|
+
# @return [String] Classes of the rich text editor box (Action Text's +<trix-editor>+): border
|
|
96
|
+
# width and color, radius, background, text color, shadow and focus state, as for an input
|
|
97
|
+
# (Neutral outlines it like its inputs). Empty = the look of Trix's own stylesheet; when set,
|
|
98
|
+
# the engine's stylesheet hands Trix's border and radius back to these classes
|
|
99
|
+
attr_accessor :rich_text_editor
|
|
100
|
+
|
|
101
|
+
# @return [String] Classes of the box around the rich text toolbar and editor, which style
|
|
102
|
+
# the toolbar's parts with descendant variants and the important modifier, such as
|
|
103
|
+
# +[&_.trix-button-group]:border-zinc-700!+ (Trix's stylesheet is not in a cascade layer,
|
|
104
|
+
# so it wins over utilities without +!+). Neutral gives the groups its borders and radii.
|
|
105
|
+
# Empty = Trix's look
|
|
106
|
+
attr_accessor :rich_text_toolbar
|
|
107
|
+
|
|
61
108
|
# @!endgroup
|
|
62
109
|
|
|
63
110
|
# @!group Tab/Scope Styles
|
|
@@ -78,6 +125,9 @@ module IronAdmin
|
|
|
78
125
|
# @return [String] Sidebar background classes
|
|
79
126
|
attr_accessor :sidebar_bg
|
|
80
127
|
|
|
128
|
+
# @return [String] Sidebar edge (border side and color) on large screens
|
|
129
|
+
attr_accessor :sidebar_border
|
|
130
|
+
|
|
81
131
|
# @return [String] Sidebar title text classes
|
|
82
132
|
attr_accessor :sidebar_title
|
|
83
133
|
|
|
@@ -87,6 +137,11 @@ module IronAdmin
|
|
|
87
137
|
# @return [String] Sidebar link hover classes
|
|
88
138
|
attr_accessor :sidebar_link_hover
|
|
89
139
|
|
|
140
|
+
# @return [String] Classes of the sidebar link for the current page, used instead of
|
|
141
|
+
# {#sidebar_link} and {#sidebar_link_hover}. The link is +relative+, so
|
|
142
|
+
# +before:+ utilities can draw an accent bar.
|
|
143
|
+
attr_accessor :sidebar_link_active
|
|
144
|
+
|
|
90
145
|
# @return [String] Sidebar group label classes
|
|
91
146
|
attr_accessor :sidebar_group_label
|
|
92
147
|
|
|
@@ -100,12 +155,24 @@ module IronAdmin
|
|
|
100
155
|
# @return [String] Navbar border classes
|
|
101
156
|
attr_accessor :navbar_border
|
|
102
157
|
|
|
158
|
+
# @return [String] Side and width of the navbar's border (the color is {#navbar_border})
|
|
159
|
+
attr_accessor :navbar_border_width
|
|
160
|
+
|
|
103
161
|
# @return [String] Navbar search input background
|
|
104
162
|
attr_accessor :navbar_search_bg
|
|
105
163
|
|
|
106
164
|
# @return [String] Navbar search input focus background
|
|
107
165
|
attr_accessor :navbar_search_focus_bg
|
|
108
166
|
|
|
167
|
+
# @return [String] Color of the user name and other navbar text
|
|
168
|
+
attr_accessor :navbar_text
|
|
169
|
+
|
|
170
|
+
# @return [String] Keyboard hint (such as the search shortcut): border, background and text color
|
|
171
|
+
attr_accessor :kbd
|
|
172
|
+
|
|
173
|
+
# @return [String] Skip link once it receives focus (with the +focus:+ variant)
|
|
174
|
+
attr_accessor :skip_link
|
|
175
|
+
|
|
109
176
|
# @!endgroup
|
|
110
177
|
|
|
111
178
|
# @!group Table Styles
|
|
@@ -113,12 +180,36 @@ module IronAdmin
|
|
|
113
180
|
# @return [String] Table header background classes
|
|
114
181
|
attr_accessor :table_header_bg
|
|
115
182
|
|
|
116
|
-
# @return [String] Table
|
|
183
|
+
# @return [String] Table header cells: size, weight and color
|
|
184
|
+
attr_accessor :table_header_text
|
|
185
|
+
|
|
186
|
+
# @return [String] Padding (density) of table body and header cells
|
|
187
|
+
attr_accessor :table_cell_padding
|
|
188
|
+
|
|
189
|
+
# @return [String] Extra classes of the table container (empty = none)
|
|
190
|
+
attr_accessor :table_frame
|
|
191
|
+
|
|
192
|
+
# @return [String] Edge shadow of the sticky actions column of index tables, cast by a box
|
|
193
|
+
# over each sticky cell (see Resources::Styles.sticky_edge); empty = none
|
|
194
|
+
attr_accessor :table_sticky_shadow
|
|
195
|
+
|
|
196
|
+
# @return [String] Hover of table rows and of the dashboard's quick links and activity feed
|
|
197
|
+
# rows. These rows hold {#muted_text}, so keep AA contrast for it on this background
|
|
117
198
|
attr_accessor :table_row_hover
|
|
118
199
|
|
|
200
|
+
# @return [String] Background of the sticky actions cell of index tables while its row is
|
|
201
|
+
# hovered: the row is the +group/row+, so use +group-hover/row:+ variants in the color of
|
|
202
|
+
# {#table_row_hover} (empty = the cell keeps {#card_bg})
|
|
203
|
+
attr_accessor :table_sticky_row_hover
|
|
204
|
+
|
|
119
205
|
# @return [String] Table border/divider classes
|
|
120
206
|
attr_accessor :table_border
|
|
121
207
|
|
|
208
|
+
# @return [String, nil] Color of the line between a table's head and its body, such as a
|
|
209
|
+
# darker rule above hairline row dividers (+divide-*+ classes; empty = {#table_border};
|
|
210
|
+
# read it through {#table_head_divider})
|
|
211
|
+
attr_accessor :table_head_border
|
|
212
|
+
|
|
122
213
|
# @!endgroup
|
|
123
214
|
|
|
124
215
|
# @!group Card Styles
|
|
@@ -126,22 +217,50 @@ module IronAdmin
|
|
|
126
217
|
# @return [String] Card background classes
|
|
127
218
|
attr_accessor :card_bg
|
|
128
219
|
|
|
129
|
-
# @return [String] Card border classes
|
|
220
|
+
# @return [String] Card border color classes
|
|
130
221
|
attr_accessor :card_border
|
|
131
222
|
|
|
132
223
|
# @return [String] Card shadow classes
|
|
133
224
|
attr_accessor :card_shadow
|
|
134
225
|
|
|
226
|
+
# @return [String] Shadow of floating surfaces: dropdown menus, the filter panel, belongs-to
|
|
227
|
+
# autocomplete results, the theme switcher panel and modals (empty = none)
|
|
228
|
+
attr_accessor :popover_shadow
|
|
229
|
+
|
|
230
|
+
# @return [String, nil] Background of those floating surfaces, such as a raised tone in a dark
|
|
231
|
+
# theme (empty = {#card_bg}; read it through {#popover_background})
|
|
232
|
+
attr_accessor :popover_bg
|
|
233
|
+
|
|
234
|
+
# @return [String] Card and section titles (h2): size, weight and color
|
|
235
|
+
attr_accessor :card_title
|
|
236
|
+
|
|
135
237
|
# @!endgroup
|
|
136
238
|
|
|
137
239
|
# @!group Typography
|
|
138
240
|
|
|
139
|
-
# @return [String] Font family classes (empty = system default)
|
|
241
|
+
# @return [String] Font family classes of the page (empty = system default)
|
|
140
242
|
attr_accessor :font_family
|
|
141
243
|
|
|
244
|
+
# @return [String, nil] Stylesheet the layout links for the theme's fonts (nil = none)
|
|
245
|
+
attr_accessor :font_stylesheet_url
|
|
246
|
+
|
|
247
|
+
# @return [String] Extra font family classes of page and card titles (empty = {#font_family})
|
|
248
|
+
attr_accessor :heading_font
|
|
249
|
+
|
|
142
250
|
# @return [String] Heading weight classes
|
|
143
251
|
attr_accessor :heading_weight
|
|
144
252
|
|
|
253
|
+
# @return [String] Page title (h1): size, weight, tracking and color
|
|
254
|
+
attr_accessor :page_title
|
|
255
|
+
|
|
256
|
+
# @return [String] Text transform and letter spacing of small labels (sidebar groups,
|
|
257
|
+
# table headers, metric labels); empty = as written
|
|
258
|
+
attr_accessor :label_transform
|
|
259
|
+
|
|
260
|
+
# @return [String] Text transform and letter spacing of field labels: form and import form
|
|
261
|
+
# labels, action form labels and the field names of show pages; empty = as written
|
|
262
|
+
attr_accessor :field_label_transform
|
|
263
|
+
|
|
145
264
|
# @return [String] Body text color classes
|
|
146
265
|
attr_accessor :body_text
|
|
147
266
|
|
|
@@ -151,6 +270,12 @@ module IronAdmin
|
|
|
151
270
|
# @return [String] Label text color classes
|
|
152
271
|
attr_accessor :label_text
|
|
153
272
|
|
|
273
|
+
# @return [String] Color of validation messages, required marks and negative deltas
|
|
274
|
+
attr_accessor :error_text
|
|
275
|
+
|
|
276
|
+
# @return [String] Color of positive deltas and true booleans
|
|
277
|
+
attr_accessor :success_text
|
|
278
|
+
|
|
154
279
|
# @!endgroup
|
|
155
280
|
|
|
156
281
|
# @!group Layout
|
|
@@ -158,98 +283,178 @@ module IronAdmin
|
|
|
158
283
|
# @return [String] Main content area background classes
|
|
159
284
|
attr_accessor :main_bg
|
|
160
285
|
|
|
161
|
-
# @return [String] Border radius
|
|
286
|
+
# @return [String] Border radius of cards and panels (inputs and buttons use {#control_radius})
|
|
162
287
|
attr_accessor :border_radius
|
|
163
288
|
|
|
289
|
+
# @return [String] Border width of the outline of cards, panels, popovers, modals, alerts, inputs,
|
|
290
|
+
# checkboxes and pagination links. One-sided dividers (panel and modal headers, form and
|
|
291
|
+
# bulk action footers, table rows, scope tabs) keep the width their template sets,
|
|
292
|
+
# {#sidebar_border} and {#btn_secondary} carry their own width, and {#navbar_border_width}
|
|
293
|
+
# sets the navbar's
|
|
294
|
+
attr_accessor :border_width
|
|
295
|
+
|
|
296
|
+
# @return [String] "light" or "dark": the CSS color scheme of browser UI and scrollbars
|
|
297
|
+
# (charts take {#chart_grid_color} and {#chart_text_color})
|
|
298
|
+
attr_accessor :color_scheme
|
|
299
|
+
|
|
300
|
+
# @return [String] Classes of this theme's 12px swatch in the theme switcher: shape, fill and ring
|
|
301
|
+
attr_accessor :swatch
|
|
302
|
+
|
|
303
|
+
# @return [String] Secondary backgrounds: readonly and disabled inputs, nested form rows,
|
|
304
|
+
# file previews, the empty state icon and audit change details
|
|
305
|
+
attr_accessor :surface_muted
|
|
306
|
+
|
|
307
|
+
# @return [String] Hover of dropdown and switcher items, search result rows and pagination
|
|
308
|
+
# links. Rows that hold {#muted_text} use {#table_row_hover}, a lighter background
|
|
309
|
+
attr_accessor :item_hover
|
|
310
|
+
|
|
311
|
+
# @return [String] Background of the listbox option that the arrow keys highlight
|
|
312
|
+
# (belongs-to autocomplete results)
|
|
313
|
+
attr_accessor :item_active
|
|
314
|
+
|
|
315
|
+
# @return [String] Color of decorative icons
|
|
316
|
+
attr_accessor :icon_muted
|
|
317
|
+
|
|
318
|
+
# @return [String] Backdrop of modals and drawers
|
|
319
|
+
attr_accessor :overlay_bg
|
|
320
|
+
|
|
164
321
|
# @!endgroup
|
|
165
322
|
|
|
166
|
-
# @!group
|
|
323
|
+
# @!group Feedback Styles
|
|
167
324
|
|
|
168
|
-
# @return [
|
|
169
|
-
|
|
325
|
+
# @return [Hash{Symbol => String}] Alert, flash and warning panel classes (background, border
|
|
326
|
+
# color, text color) by type: +:success+, +:error+, +:warning+, +:info+
|
|
327
|
+
attr_accessor :alert_palette
|
|
170
328
|
|
|
171
|
-
# @return [String]
|
|
172
|
-
attr_accessor :
|
|
329
|
+
# @return [String] Shadow of alerts, flash messages and warning panels (empty = none)
|
|
330
|
+
attr_accessor :alert_shadow
|
|
331
|
+
|
|
332
|
+
# @return [Hash{Symbol => String}] Badge classes by color name (+:green+, +:red+, +:yellow+,
|
|
333
|
+
# +:blue+, +:indigo+, +:purple+, +:pink+, +:orange+, +:teal+, +:gray+)
|
|
334
|
+
attr_accessor :badge_palette
|
|
335
|
+
|
|
336
|
+
# @return [Hash{Symbol => String}] Badge dot classes by color name ({#badge_palette} keys);
|
|
337
|
+
# an empty Hash renders badges without a dot
|
|
338
|
+
attr_accessor :badge_dot_palette
|
|
339
|
+
|
|
340
|
+
# @return [String] Radius and font weight of badges
|
|
341
|
+
attr_accessor :badge_shape
|
|
342
|
+
|
|
343
|
+
# @return [String] Tags and has-many chips
|
|
344
|
+
attr_accessor :chip
|
|
345
|
+
|
|
346
|
+
# @return [String] Color of destructive dropdown items, with their hover
|
|
347
|
+
attr_accessor :danger_item
|
|
348
|
+
|
|
349
|
+
# @return [String] Tooltip background and text color
|
|
350
|
+
attr_accessor :tooltip
|
|
351
|
+
|
|
352
|
+
# @return [String] JSON/code display background and text color
|
|
353
|
+
attr_accessor :code_block
|
|
354
|
+
|
|
355
|
+
# @return [String] Font family of code-like text: code blocks, code, JSON, key/value, markdown
|
|
356
|
+
# and hex color inputs, and audit change details
|
|
357
|
+
attr_accessor :code_font
|
|
358
|
+
|
|
359
|
+
# @return [String] Progress bar track
|
|
360
|
+
attr_accessor :progress_track
|
|
361
|
+
|
|
362
|
+
# @return [String] Current page of the pagination
|
|
363
|
+
attr_accessor :pagination_active
|
|
173
364
|
|
|
174
365
|
# @!endgroup
|
|
175
366
|
|
|
176
|
-
#
|
|
177
|
-
def initialize
|
|
178
|
-
# --- Buttons ---
|
|
179
|
-
@btn_primary = "bg-indigo-600 text-white hover:bg-indigo-700 focus:ring-2 focus:ring-indigo-500/20 focus:ring-offset-1"
|
|
180
|
-
@btn_secondary = "bg-white text-gray-700 border border-gray-300 hover:bg-gray-50 hover:border-gray-400"
|
|
181
|
-
@btn_danger = "bg-red-600 text-white hover:bg-red-700"
|
|
182
|
-
@btn_ghost = "bg-gray-100 text-gray-700 hover:bg-gray-200"
|
|
367
|
+
# @!group Dashboard Styles
|
|
183
368
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
@link_muted = "text-gray-500 hover:text-gray-700"
|
|
369
|
+
# @return [String] Dashboard metric label: size, weight and color
|
|
370
|
+
attr_accessor :metric_label
|
|
187
371
|
|
|
188
|
-
|
|
189
|
-
|
|
372
|
+
# @return [String] Dashboard metric figure: size, weight, tracking and color
|
|
373
|
+
attr_accessor :metric_value
|
|
190
374
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
@input_focus = "focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500/20"
|
|
375
|
+
# @return [String] Dashboard metric icon tile: background and icon color
|
|
376
|
+
attr_accessor :metric_icon
|
|
194
377
|
|
|
195
|
-
|
|
196
|
-
@checkbox_checked = "checked:border-indigo-600 checked:bg-indigo-600 focus:ring-2 focus:ring-indigo-500/20"
|
|
378
|
+
# @!endgroup
|
|
197
379
|
|
|
198
|
-
|
|
199
|
-
@scope_active = "border-indigo-600 text-indigo-600"
|
|
200
|
-
@scope_inactive = "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
|
380
|
+
# @!group Chart Styles
|
|
201
381
|
|
|
202
|
-
|
|
203
|
-
|
|
382
|
+
# @return [Array<String>] Default chart color palette (CSS color values: hex, rgb, rgba): the
|
|
383
|
+
# slices of pie, doughnut and polar area charts in order; bar charts fill every bar with the
|
|
384
|
+
# first color
|
|
385
|
+
attr_accessor :chart_colors
|
|
204
386
|
|
|
205
|
-
|
|
387
|
+
# @return [String] Default chart border/line color (CSS color value)
|
|
388
|
+
attr_accessor :chart_border_color
|
|
389
|
+
|
|
390
|
+
# @return [String] Chart grid lines (CSS color value)
|
|
391
|
+
attr_accessor :chart_grid_color
|
|
206
392
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
@navbar_border = "border-gray-200"
|
|
210
|
-
@navbar_search_bg = "bg-gray-50"
|
|
211
|
-
@navbar_search_focus_bg = "focus:bg-white"
|
|
393
|
+
# @return [String] Chart ticks and legend (CSS color value)
|
|
394
|
+
attr_accessor :chart_text_color
|
|
212
395
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
@table_border = "divide-gray-200"
|
|
396
|
+
# @return [String] Chart.js point style of the legend markers ("circle", "rect", "rectRounded",
|
|
397
|
+
# "triangle" and so on)
|
|
398
|
+
attr_accessor :chart_point_style
|
|
217
399
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@card_shadow = "shadow"
|
|
400
|
+
# @return [String, nil] Outline of pie, doughnut and polar area slices (CSS color value;
|
|
401
|
+
# nil = each slice in its own color)
|
|
402
|
+
attr_accessor :chart_slice_border_color
|
|
222
403
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
@body_text = "text-gray-900"
|
|
227
|
-
@muted_text = "text-gray-500"
|
|
228
|
-
@label_text = "text-gray-700"
|
|
404
|
+
# @return [Integer, nil] Width in pixels of slice and bar outlines and of lines (nil = the
|
|
405
|
+
# Chart.js defaults)
|
|
406
|
+
attr_accessor :chart_border_width
|
|
229
407
|
|
|
230
|
-
|
|
231
|
-
@main_bg = "bg-gray-50"
|
|
232
|
-
@border_radius = "rounded-lg"
|
|
408
|
+
# @!endgroup
|
|
233
409
|
|
|
410
|
+
# Creates a Theme with the values of the Neutral look.
|
|
411
|
+
#
|
|
412
|
+
# @param name [Symbol, String] Name the theme is registered under
|
|
413
|
+
# @param label [String, nil] Name shown in the theme switcher (default: the titleized name)
|
|
414
|
+
def initialize(name: :neutral, label: nil)
|
|
415
|
+
@name = name.to_sym
|
|
416
|
+
@label = (label || @name.to_s.titleize).to_s
|
|
417
|
+
init_control_defaults
|
|
418
|
+
init_form_defaults
|
|
419
|
+
init_navigation_defaults
|
|
420
|
+
init_surface_defaults
|
|
421
|
+
init_typography_defaults
|
|
422
|
+
init_feedback_defaults
|
|
423
|
+
init_palette_defaults
|
|
234
424
|
init_chart_defaults
|
|
235
425
|
end
|
|
236
426
|
|
|
237
|
-
|
|
427
|
+
# Copies Array and Hash values (chart colors, palettes) too, so a copy never shares them.
|
|
428
|
+
#
|
|
429
|
+
# @param source [Theme] The theme being copied
|
|
430
|
+
# @return [void]
|
|
431
|
+
def initialize_copy(source)
|
|
432
|
+
super
|
|
433
|
+
instance_variables.each do |variable|
|
|
434
|
+
value = instance_variable_get(variable)
|
|
435
|
+
instance_variable_set(variable, value.deep_dup) if value.is_a?(Array) || value.is_a?(Hash)
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
# @return [String] Background of floating surfaces: {#popover_bg}, or {#card_bg} while it is empty
|
|
440
|
+
def popover_background
|
|
441
|
+
popover_bg.presence || card_bg
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# @return [String] Color of the line between a table's head and body: {#table_head_border},
|
|
445
|
+
# or {#table_border} while it is empty
|
|
446
|
+
def table_head_divider
|
|
447
|
+
table_head_border.presence || table_border
|
|
448
|
+
end
|
|
238
449
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
@sidebar_link = "text-gray-300"
|
|
243
|
-
@sidebar_link_hover = "hover:bg-gray-800 hover:text-white"
|
|
244
|
-
@sidebar_group_label = "text-gray-400"
|
|
450
|
+
# @return [Boolean] Whether {#color_scheme} is "dark"
|
|
451
|
+
def dark?
|
|
452
|
+
color_scheme.to_s == "dark"
|
|
245
453
|
end
|
|
246
454
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
rgba(245,158,11,0.8) rgba(239,68,68,0.8) rgba(139,92,246,0.8)
|
|
251
|
-
]
|
|
252
|
-
@chart_border_color = "rgb(99, 102, 241)"
|
|
455
|
+
# @return [String] Tailwind class of the +<html>+ element for {#color_scheme}
|
|
456
|
+
def scheme_class
|
|
457
|
+
SCHEME_CLASSES.fetch(dark? ? "dark" : "light")
|
|
253
458
|
end
|
|
254
459
|
end
|
|
255
460
|
end
|