solidus_admin 0.0.2 → 0.2.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/.eslintrc.json +7 -0
- data/README.md +2 -2
- data/Rakefile +26 -0
- data/app/assets/builds/.keep +0 -0
- data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
- data/app/assets/config/solidus_admin_manifest.js +1 -0
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
- data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
- data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +43 -0
- data/app/components/solidus_admin/base_component.rb +29 -1
- data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
- data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
- data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
- data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
- data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
- data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
- data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
- data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
- data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
- data/app/components/solidus_admin/option_types/index/component.rb +71 -0
- data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
- data/app/components/solidus_admin/orders/cart/component.js +37 -0
- data/app/components/solidus_admin/orders/cart/component.rb +7 -0
- data/app/components/solidus_admin/orders/cart/component.yml +3 -0
- data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
- data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/index/component.rb +92 -23
- data/app/components/solidus_admin/orders/index/component.yml +10 -4
- data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
- data/app/components/solidus_admin/orders/show/address/component.js +9 -0
- data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
- data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
- data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
- data/app/components/solidus_admin/orders/show/component.js +7 -0
- data/app/components/solidus_admin/orders/show/component.rb +40 -0
- data/app/components/solidus_admin/orders/show/component.yml +21 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
- data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
- data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
- data/app/components/solidus_admin/payment_methods/index/component.rb +103 -0
- data/app/components/solidus_admin/payment_methods/index/component.yml +10 -0
- data/app/components/solidus_admin/products/index/component.rb +48 -41
- data/app/components/solidus_admin/products/index/component.yml +8 -7
- data/app/components/solidus_admin/products/show/component.html.erb +32 -38
- data/app/components/solidus_admin/products/show/component.rb +2 -0
- data/app/components/solidus_admin/products/show/component.yml +5 -5
- data/app/components/solidus_admin/products/status/component.rb +20 -18
- data/app/components/solidus_admin/products/status/component.yml +1 -0
- data/app/components/solidus_admin/products/stock/component.rb +38 -0
- data/app/components/solidus_admin/products/stock/component.yml +5 -0
- data/app/components/solidus_admin/promotion_categories/index/component.rb +56 -0
- data/app/components/solidus_admin/promotions/index/component.rb +104 -0
- data/app/components/solidus_admin/promotions/index/component.yml +10 -0
- data/app/components/solidus_admin/properties/index/component.rb +64 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +40 -0
- data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +27 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +42 -0
- data/app/components/solidus_admin/shipping/component.rb +30 -0
- data/app/components/solidus_admin/shipping/component.yml +3 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
- data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
- data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
- data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
- data/app/components/solidus_admin/stock_items/index/component.rb +174 -0
- data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
- data/app/components/solidus_admin/stock_locations/index/component.rb +89 -0
- data/app/components/solidus_admin/stock_locations/index/component.yml +3 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/stores/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +88 -0
- data/app/components/solidus_admin/taxes/component.rb +25 -0
- data/app/components/solidus_admin/taxes/component.yml +3 -0
- data/app/components/solidus_admin/taxonomies/index/component.rb +53 -0
- data/app/components/solidus_admin/ui/badge/component.rb +18 -8
- data/app/components/solidus_admin/ui/badge/component.yml +3 -0
- data/app/components/solidus_admin/ui/button/component.rb +32 -32
- data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
- data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
- data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
- data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
- data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
- data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
- data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
- data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
- data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
- data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
- data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
- data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
- data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
- data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
- data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
- data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
- data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
- data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
- data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
- data/app/components/solidus_admin/ui/icon/component.rb +4 -0
- data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
- data/app/components/solidus_admin/ui/modal/component.rb +12 -0
- data/app/components/solidus_admin/ui/modal/component.yml +2 -0
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +30 -0
- data/app/components/solidus_admin/ui/pages/index/component.rb +119 -0
- data/app/components/solidus_admin/ui/pages/index/component.yml +4 -0
- data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
- data/app/components/solidus_admin/ui/panel/component.rb +17 -0
- data/app/components/solidus_admin/ui/panel/component.yml +1 -3
- data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
- data/app/components/solidus_admin/ui/tab/component.rb +9 -8
- data/app/components/solidus_admin/ui/table/component.html.erb +147 -135
- data/app/components/solidus_admin/ui/table/component.js +56 -17
- data/app/components/solidus_admin/ui/table/component.rb +94 -70
- data/app/components/solidus_admin/ui/table/component.yml +0 -1
- data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
- data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
- data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
- data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
- data/app/components/solidus_admin/ui/toast/component.js +9 -6
- data/app/components/solidus_admin/ui/toast/component.rb +2 -2
- data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
- data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
- data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
- data/app/components/solidus_admin/users/index/component.rb +96 -0
- data/app/components/solidus_admin/users/index/component.yml +15 -0
- data/app/components/solidus_admin/zones/index/component.rb +63 -0
- data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/base_controller.rb +1 -0
- data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
- data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
- data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
- data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
- data/app/controllers/solidus_admin/countries_controller.rb +12 -0
- data/app/controllers/solidus_admin/customers_controller.rb +29 -0
- data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
- data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
- data/app/controllers/solidus_admin/orders_controller.rb +104 -7
- data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
- data/app/controllers/solidus_admin/products_controller.rb +26 -17
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +29 -0
- data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
- data/app/controllers/solidus_admin/properties_controller.rb +33 -0
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
- data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
- data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
- data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/stores_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
- data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
- data/app/controllers/solidus_admin/users_controller.rb +50 -0
- data/app/controllers/solidus_admin/zones_controller.rb +40 -0
- data/app/javascript/solidus_admin/controllers/components.js +3 -1
- data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
- data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
- data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
- data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
- data/app/views/layouts/solidus_admin/application.html.erb +16 -10
- data/app/views/layouts/solidus_admin/preview.html.erb +2 -1
- data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
- data/config/importmap.rb +2 -0
- data/config/initializers/view_component.rb +20 -0
- data/config/locales/adjustment_reasons.en.yml +6 -0
- data/config/locales/customers.en.yml +7 -0
- data/config/locales/errors.en.yml +7 -0
- data/config/locales/line_items.en.yml +9 -0
- data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
- data/config/locales/option_types.en.yml +6 -0
- data/config/locales/orders.en.yml +9 -0
- data/config/locales/payment_methods.en.yml +6 -0
- data/config/locales/promotion_categories.en.yml +6 -0
- data/config/locales/promotions.en.yml +6 -0
- data/config/locales/properties.en.yml +6 -0
- data/config/locales/refund_reasons_.en.yml +6 -0
- data/config/locales/reimbursement_types.en.yml +4 -0
- data/config/locales/return_reasons.en.yml +6 -0
- data/config/locales/shipping_categories.en.yml +6 -0
- data/config/locales/shipping_methods.en.yml +6 -0
- data/config/locales/stock_items.en.yml +4 -0
- data/config/locales/stock_locations.en.yml +6 -0
- data/config/locales/store_credit_reasons.en.yml +6 -0
- data/config/locales/stores.en.yml +6 -0
- data/config/locales/tax_categories.en.yml +6 -0
- data/config/locales/tax_rates.en.yml +6 -0
- data/config/locales/taxonomies.en.yml +6 -0
- data/config/locales/users.en.yml +6 -0
- data/config/locales/zones.en.yml +6 -0
- data/config/routes.rb +50 -3
- data/config/tailwind.config.js +119 -0
- data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
- data/docs/customizing_tailwindcss.md +57 -0
- data/docs/customizing_view_components.md +17 -38
- data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
- data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
- data/lib/solidus_admin/admin_resources.rb +23 -0
- data/lib/solidus_admin/configuration.rb +95 -67
- data/lib/solidus_admin/install_tailwindcss.rb +102 -0
- data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
- data/lib/solidus_admin/version.rb +1 -1
- data/lib/solidus_admin.rb +1 -2
- data/lib/tasks/tailwind.rake +10 -0
- data/solidus_admin.gemspec +3 -4
- metadata +193 -50
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
- data/app/components/solidus_admin/feedback/component.html.erb +0 -11
- data/app/components/solidus_admin/feedback/component.rb +0 -4
- data/app/components/solidus_admin/feedback/component.yml +0 -5
- data/app/components/solidus_admin/orders/index/component.html.erb +0 -31
- data/app/components/solidus_admin/products/index/component.html.erb +0 -30
- data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
- data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
- data/app/components/solidus_admin/sidebar/component.rb +0 -21
- data/app/components/solidus_admin/ui/panel/component.js +0 -14
- data/config/solidus_admin/tailwind.config.js.erb +0 -95
- data/docs/customizing_tailwind.md +0 -78
- data/lib/solidus_admin/tailwindcss.rb +0 -58
- data/lib/tasks/tailwindcss.rake +0 -55
- /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
- /data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.yml +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const defaultTheme = require('tailwindcss/defaultTheme')
|
|
2
|
+
const plugin = require('tailwindcss/plugin')
|
|
3
|
+
const adminRoot = __dirname.replace(/\/config$/, '')
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
content: [
|
|
7
|
+
`${adminRoot}/{app/helpers,app/views,app/components,app/assets/javascripts,spec/components/previews}/**/*`,
|
|
8
|
+
],
|
|
9
|
+
theme: {
|
|
10
|
+
extend: {
|
|
11
|
+
aria: {
|
|
12
|
+
current: 'current="true"',
|
|
13
|
+
},
|
|
14
|
+
fontFamily: {
|
|
15
|
+
sans: ["Inter var", ...defaultTheme.fontFamily.sans],
|
|
16
|
+
},
|
|
17
|
+
colors: {
|
|
18
|
+
transparent: "transparent",
|
|
19
|
+
current: "currentColor",
|
|
20
|
+
|
|
21
|
+
// Primary palette
|
|
22
|
+
"solidus-red": "#ef3023",
|
|
23
|
+
black: "#222222",
|
|
24
|
+
graphite: "#c7ccc7",
|
|
25
|
+
"graphite-light": "#d8dad8",
|
|
26
|
+
sand: "#f5f3f0",
|
|
27
|
+
white: "#ffffff",
|
|
28
|
+
|
|
29
|
+
// Secondary palette
|
|
30
|
+
yellow: "#fdc071",
|
|
31
|
+
orange: "#f68050",
|
|
32
|
+
blue: "#2554b1",
|
|
33
|
+
moss: "#2d3925",
|
|
34
|
+
forest: "#096756",
|
|
35
|
+
midnight: "#163449",
|
|
36
|
+
pink: "#f6d7e2",
|
|
37
|
+
plum: "#3a0e31",
|
|
38
|
+
sky: "#cbdff1",
|
|
39
|
+
seafoam: "#c1e0de",
|
|
40
|
+
dune: "#e6bf9b",
|
|
41
|
+
"full-black": "#000000",
|
|
42
|
+
|
|
43
|
+
// Extra colors (not part of the original palette)
|
|
44
|
+
"papaya-whip": "#f9e3d9",
|
|
45
|
+
|
|
46
|
+
// UI Red
|
|
47
|
+
red: {
|
|
48
|
+
100: "#f8d6d3",
|
|
49
|
+
200: "#f1ada7",
|
|
50
|
+
300: "#ea8980",
|
|
51
|
+
400: "#e36054",
|
|
52
|
+
500: "#dc3728",
|
|
53
|
+
600: "#b12c20",
|
|
54
|
+
700: "#862219",
|
|
55
|
+
800: "#561610",
|
|
56
|
+
900: "#2b0b08",
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// Grayscale
|
|
60
|
+
gray: {
|
|
61
|
+
15: "#fafafa",
|
|
62
|
+
25: "#f5f5f5",
|
|
63
|
+
50: "#f0f0f0",
|
|
64
|
+
100: "#dedede",
|
|
65
|
+
200: "#cfcfcf",
|
|
66
|
+
300: "#bababa",
|
|
67
|
+
400: "#a3a3a3",
|
|
68
|
+
500: "#737373",
|
|
69
|
+
600: "#616161",
|
|
70
|
+
700: "#4a4a4a",
|
|
71
|
+
800: "#333333",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
borderRadius: {
|
|
75
|
+
sm: "4px",
|
|
76
|
+
},
|
|
77
|
+
backgroundImage: {
|
|
78
|
+
"arrow-right-up-line": "url('solidus_admin/arrow_right_up_line.svg')",
|
|
79
|
+
"arrow-down-s-fill-gray-700": "url('solidus_admin/arrow_down_s_fill_gray_700.svg')",
|
|
80
|
+
"arrow-down-s-fill-red-400": "url('solidus_admin/arrow_down_s_fill_red_400.svg')",
|
|
81
|
+
},
|
|
82
|
+
boxShadow: {
|
|
83
|
+
sm: "0px 1px 2px 0px rgba(0, 0, 0, 0.04)",
|
|
84
|
+
base: "0px 4px 8px 0px rgba(0, 0, 0, 0.08), 0px 2px 4px -1px rgba(0, 0, 0, 0.04)",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
plugins: [
|
|
89
|
+
require("@tailwindcss/forms")({ strategy: "class" }),
|
|
90
|
+
require("@tailwindcss/aspect-ratio"),
|
|
91
|
+
require("@tailwindcss/typography"),
|
|
92
|
+
require("@tailwindcss/container-queries"),
|
|
93
|
+
plugin(({ addVariant, addBase, addComponents, theme }) => {
|
|
94
|
+
// Support the "hidden" attribute
|
|
95
|
+
addVariant("hidden", "&([hidden])")
|
|
96
|
+
addVariant("visible", "&:not([hidden])")
|
|
97
|
+
|
|
98
|
+
// Support the "search-cancel" pseudo-element
|
|
99
|
+
addVariant("search-cancel", "&::-webkit-search-cancel-button")
|
|
100
|
+
|
|
101
|
+
// Reset the <summary> marker
|
|
102
|
+
addBase({
|
|
103
|
+
"summary::-webkit-details-marker": { display: "none" },
|
|
104
|
+
"summary::marker": { display: "none" },
|
|
105
|
+
summary: { listStyle: "none" },
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
// Add a text style for links
|
|
109
|
+
addComponents({
|
|
110
|
+
".body-link": {
|
|
111
|
+
color: theme("colors.blue"),
|
|
112
|
+
"&:hover": {
|
|
113
|
+
textDecoration: "underline",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Customizing the main navigation
|
|
2
2
|
|
|
3
|
-
You are allowed to add your custom links to the main navigation. To do so, you can access `SolidusAdmin::Config.
|
|
3
|
+
You are allowed to add your custom links to the main navigation. To do so, you can access `SolidusAdmin::Config.menu_items` in an initializer:
|
|
4
4
|
|
|
5
5
|
```ruby
|
|
6
6
|
# config/initializers/solidus_admin.rb
|
|
@@ -13,7 +13,7 @@ SolidusAdmin::Config.menu_items << {
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
- The key you provide will be used to translate the link's label under the
|
|
16
|
-
`solidus_admin.
|
|
16
|
+
`solidus_admin.menu_item.#{key}` key.
|
|
17
17
|
- Icon needs to be an icon name from [Remixicon](https://remixicon.com/).
|
|
18
18
|
- Position tells Solidus where to place the link in the main navigation. The
|
|
19
19
|
default items are placed with 10 points of difference between them.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Customizing TailwindCSS
|
|
2
|
+
|
|
3
|
+
Solidus Admin uses [Tailwind CSS](https://tailwindcss.com/) for styling. The
|
|
4
|
+
benefit of using Tailwind is that it allows you to customize the look and feel
|
|
5
|
+
of the admin without having to write any CSS. By leveraging utility classes,
|
|
6
|
+
you can easily change the colors, fonts, and spacing in use.
|
|
7
|
+
|
|
8
|
+
Solidus Admin provides a precompiled CSS file that includes all the necessary
|
|
9
|
+
Tailwind classes for the admin to work out of the box.
|
|
10
|
+
|
|
11
|
+
In case you need to customize the admin's look and feel, or create custom
|
|
12
|
+
components, you can do so by running Tailwind's build process in your host
|
|
13
|
+
application.
|
|
14
|
+
|
|
15
|
+
This process presumes that you have a working knowledge of Tailwind CSS. If you
|
|
16
|
+
are not familiar with Tailwind, please refer to the [Tailwind
|
|
17
|
+
documentation](https://tailwindcss.com/docs) for more information.
|
|
18
|
+
|
|
19
|
+
## Setting up a local TailwindCSS build for Solidus Admin
|
|
20
|
+
|
|
21
|
+
In order to customize the admin's look and feel, you'll need to set up a local
|
|
22
|
+
Tailwind build. This is a two-step process:
|
|
23
|
+
|
|
24
|
+
Add Tailwind configuration files to your application:
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
bin/rails solidus_admin:tailwindcss:install
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This will create all the necessary files for you to customize TailwindCSS,
|
|
31
|
+
including:
|
|
32
|
+
- A `config/solidus_admin/tailwind.config.js` configuration file
|
|
33
|
+
that will automatically import the Solidus Admin's default configuration.
|
|
34
|
+
- An `app/assets/stylesheets/solidus_admin/application.tailwind.css` file
|
|
35
|
+
in which you can add your own customizations.
|
|
36
|
+
- Tasks to build the CSS file once or watch for changes and automatically
|
|
37
|
+
rebuild the target `app/assets/builds/solidus_admin/application.css` file.
|
|
38
|
+
|
|
39
|
+
In order to manually build the CSS file, run:
|
|
40
|
+
|
|
41
|
+
```shell
|
|
42
|
+
bin/rails solidus_admin:tailwindcss:build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or, to watch for changes and automatically rebuild the CSS file, run:
|
|
46
|
+
|
|
47
|
+
```shell
|
|
48
|
+
bin/rails solidus_admin:tailwindcss:watch
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Caveats
|
|
52
|
+
|
|
53
|
+
### Conflict with sassc-rails
|
|
54
|
+
|
|
55
|
+
Tailwind uses modern CSS features that are not recognized by the sassc-rails extension that was included by default in the Gemfile for Rails 6. In order to avoid any errors like SassC::SyntaxError, you must remove that gem from your Gemfile.
|
|
56
|
+
|
|
57
|
+
*See https://github.com/rails/tailwindcss-rails#conflict-with-sassc-rails.*
|
|
@@ -11,18 +11,12 @@ All the components Solidus Admin uses are located in the [`app/components`](../a
|
|
|
11
11
|
- They are grouped in sidecar directories, where the main component file and
|
|
12
12
|
all its related files (assets, i18n files, etc.) live together.
|
|
13
13
|
|
|
14
|
-
For instance, the component for the main navigation is located in
|
|
15
|
-
[`app/components/solidus_admin/main_nav/component.rb`](../app/components/solidus_admin/main_nav/component.rb).
|
|
16
|
-
|
|
17
14
|
Solidus Admin components are designed to be easily customizable by the host
|
|
18
15
|
application. Because of that, if you look at how they are designed, you'll find
|
|
19
16
|
a series of patterns are followed consistently:
|
|
20
17
|
|
|
21
18
|
- Components are always resolved from a global registry in
|
|
22
|
-
`SolidusAdmin::Config.components` instead of being referenced by their constant.
|
|
23
|
-
example, we call `component('main_nav')` instead of referencing
|
|
24
|
-
`SolidusAdmin::MainNav::Component` directly. As you'll see later, this makes
|
|
25
|
-
it easy to replace or tweak a component.
|
|
19
|
+
`SolidusAdmin::Config.components` instead of being referenced by their constant.
|
|
26
20
|
- It's possible to override the registry locally inside a component by redefining
|
|
27
21
|
the `#component` method. This is useful when you need to use a component that
|
|
28
22
|
is not registered in the global registry or need to address some edge case.
|
|
@@ -50,37 +44,22 @@ end
|
|
|
50
44
|
# render component('foo').new
|
|
51
45
|
```
|
|
52
46
|
|
|
53
|
-
## Customizing components
|
|
54
|
-
|
|
55
|
-
Some of the customizations detailed below require you to match Solidus Admin's
|
|
56
|
-
component paths in your application. For instance, if we talk about the
|
|
57
|
-
component in `solidus_admin` gem's
|
|
58
|
-
`app/components/solidus_admin/main_nav/component.rb`, the matching path in your
|
|
59
|
-
application would be
|
|
60
|
-
`app/components/my_application/solidus_admin/main_nav/component.rb`, where
|
|
61
|
-
`my_application` is the underscored name of your application (you can get it by
|
|
62
|
-
running `Rails.application.class.module_parent_name`).
|
|
63
|
-
|
|
64
47
|
### Replacing a component's template
|
|
65
48
|
|
|
66
49
|
In the most typical case, you'll only need to replace the template used by a
|
|
67
50
|
component. You can do that by creating a new component with a maching path in
|
|
68
51
|
your application, inheriting from the default one. Then, you can create a new
|
|
69
|
-
template for it. For example, to replace the
|
|
52
|
+
template for it. For example, to replace the menu item template:
|
|
70
53
|
|
|
71
|
-
```
|
|
72
|
-
# app/components/
|
|
73
|
-
class
|
|
54
|
+
```rb
|
|
55
|
+
# app/components/my_admin/navigation/item/component.rb
|
|
56
|
+
class MyAdmin::Navigation::Item::Component < SolidusAdmin::Layout::Navigation::Item::Component
|
|
74
57
|
end
|
|
58
|
+
```
|
|
75
59
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
render main_nav_item_component.with_collection(
|
|
80
|
-
sorted_items
|
|
81
|
-
)
|
|
82
|
-
%>
|
|
83
|
-
</nav>
|
|
60
|
+
```erb
|
|
61
|
+
<%# app/components/my_admin/navigation/item/component.html.erb %>
|
|
62
|
+
<li><%= link_to @item.name, path %></li>
|
|
84
63
|
```
|
|
85
64
|
|
|
86
65
|
### Prepending or appending to a component's template
|
|
@@ -90,9 +69,9 @@ component. You can easily do that by rendering the Solidus Admin component and
|
|
|
90
69
|
adding your markup before or after it.
|
|
91
70
|
|
|
92
71
|
```erb
|
|
93
|
-
<%# app/components/
|
|
72
|
+
<%# app/components/my_admin/menu_item/component.html.erb %>
|
|
94
73
|
<h1>MY STORE ADMINISTRATION</h1>
|
|
95
|
-
<%= render SolidusAdmin::
|
|
74
|
+
<%= render SolidusAdmin::MenuItem::Component.new %>
|
|
96
75
|
```
|
|
97
76
|
|
|
98
77
|
### Replacing a component
|
|
@@ -109,12 +88,12 @@ There are two considerations to keep in mind:
|
|
|
109
88
|
[SolidusAdmin::BaseComponent](../app/components/solidus_admin/base_component.rb).
|
|
110
89
|
You can consider doing the same if you need to use one of its helpers.
|
|
111
90
|
|
|
112
|
-
For example, the following replaces the
|
|
91
|
+
For example, the following replaces the menu item component:
|
|
113
92
|
|
|
114
93
|
```ruby
|
|
115
|
-
# app/components/
|
|
116
|
-
class
|
|
117
|
-
#
|
|
94
|
+
# app/components/my_admin/menu_item/component.rb
|
|
95
|
+
class MyAdmin::MenuItem::Component < SolidusAdmin::BaseComponent
|
|
96
|
+
# Here goes your code
|
|
118
97
|
end
|
|
119
98
|
```
|
|
120
99
|
|
|
@@ -138,8 +117,8 @@ matching path from within your application (or manually add it to the
|
|
|
138
117
|
registry) and override the methods you need to change:
|
|
139
118
|
|
|
140
119
|
```ruby
|
|
141
|
-
# app/components/
|
|
142
|
-
class
|
|
120
|
+
# app/components/my_admin/menu_item/component.rb
|
|
121
|
+
class MyAdmin::MenuItem::Component < SolidusAdmin::MenuItem::Component
|
|
143
122
|
def sorted_items
|
|
144
123
|
super.reverse
|
|
145
124
|
end
|
|
@@ -4,12 +4,13 @@ module SolidusAdmin
|
|
|
4
4
|
module Generators
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
|
6
6
|
class_option :lookbook, type: :boolean, default: !!ENV['SOLIDUS_ADMIN_LOOKBOOK'], desc: 'Install Lookbook for component previews'
|
|
7
|
+
class_option :tailwind, type: :boolean, default: false, desc: 'Install TailwindCSS for custom components'
|
|
7
8
|
|
|
8
9
|
source_root "#{__dir__}/templates"
|
|
9
10
|
|
|
10
11
|
def install_solidus_core_support
|
|
11
12
|
route <<~RUBY
|
|
12
|
-
mount SolidusAdmin::Engine, at: '
|
|
13
|
+
mount SolidusAdmin::Engine, at: '#{solidus_mount_point}admin', constraints: ->(req) {
|
|
13
14
|
req.cookies['solidus_admin'] != 'false' &&
|
|
14
15
|
req.params['solidus_admin'] != 'false'
|
|
15
16
|
}
|
|
@@ -17,7 +18,7 @@ module SolidusAdmin
|
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def copy_initializer
|
|
20
|
-
|
|
21
|
+
template 'config/initializers/solidus_admin.rb.tt', 'config/initializers/solidus_admin.rb'
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def ignore_tailwind_build_files
|
|
@@ -25,7 +26,7 @@ module SolidusAdmin
|
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def build_tailwind
|
|
28
|
-
rake "solidus_admin:tailwindcss:
|
|
29
|
+
rake "solidus_admin:tailwindcss:install" if options[:tailwind]
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def install_lookbook
|
|
@@ -37,7 +38,15 @@ module SolidusAdmin
|
|
|
37
38
|
gem "actioncable"
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
route "mount Lookbook::Engine, at: '
|
|
41
|
+
route "mount Lookbook::Engine, at: '#{solidus_mount_point}lookbook' if Rails.env.development?"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def solidus_mount_point
|
|
47
|
+
mount_point = Spree::Core::Engine.routes.find_script_name({})
|
|
48
|
+
mount_point += "/" unless mount_point.end_with?("/")
|
|
49
|
+
mount_point
|
|
41
50
|
end
|
|
42
51
|
end
|
|
43
52
|
end
|
|
@@ -6,28 +6,24 @@ SolidusAdmin::Config.configure do |config|
|
|
|
6
6
|
# It needs to be a path to an image file accessible by Sprockets.
|
|
7
7
|
# config.logo_path = "my_own_logo.svg"
|
|
8
8
|
|
|
9
|
-
# Add custom paths for TailwindCSS to scan for styles. By default, it already
|
|
10
|
-
# includes the following paths:
|
|
11
|
-
# - public/solidus_admin/*.html
|
|
12
|
-
# - app/helpers/solidus_admin/**/*.rb
|
|
13
|
-
# - app/assets/javascripts/solidus_admin/**/*.js
|
|
14
|
-
# - app/views/solidus_admin/**/*.{erb,haml,html,slim}
|
|
15
|
-
# - app/components/solidus_admin/**/*.{rb,erb,haml,html,slim,js}
|
|
16
|
-
#
|
|
17
|
-
# config.tailwind_content << Rails.root.join("app/my/custom/path/**.rb")
|
|
18
|
-
|
|
19
|
-
# Append custom stylesheets to be compiled by TailwindCSS.
|
|
20
|
-
# config.tailwind_stylesheets << Rails.root.join("app/my/custom/path/style.css")
|
|
21
|
-
|
|
22
9
|
# Add custom folder paths to watch for changes to trigger a cache sweep forcing a
|
|
23
10
|
# regeneration of the importmap.
|
|
24
11
|
# config.importmap_cache_sweepers << Rails.root.join("app/javascript/my_admin_components")
|
|
25
12
|
|
|
13
|
+
# If you want to avoid defining menu_item customizations twice while migrating to SolidusAdmin
|
|
14
|
+
# you can import menu_items from the backend by uncommenting the following line,
|
|
15
|
+
# but you will need to
|
|
16
|
+
<%- if defined? Spree::Backend -%>
|
|
17
|
+
config.import_menu_items_from_backend!
|
|
18
|
+
<%- else -%>
|
|
19
|
+
# config.import_menu_items_from_backend!
|
|
20
|
+
<%- end -%>
|
|
21
|
+
|
|
26
22
|
# Add custom paths to importmap files to be loaded.
|
|
27
23
|
# config.importmap_paths << Rails.root.join("config/solidus_admin_importmap.rb")
|
|
28
24
|
#
|
|
29
25
|
# Configure the main navigation.
|
|
30
|
-
# See SolidusAdmin::
|
|
26
|
+
# See SolidusAdmin::MenuItem for more details.
|
|
31
27
|
# config.menu_items << {
|
|
32
28
|
# key: :my_custom_link,
|
|
33
29
|
# route: :my_custom_link_path,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin::AdminResources
|
|
4
|
+
def admin_resources(resource, **options)
|
|
5
|
+
batch_actions = %i[destroy]
|
|
6
|
+
batch_actions &= options[:only] if options[:only]
|
|
7
|
+
batch_actions -= options[:except] if options[:except]
|
|
8
|
+
|
|
9
|
+
resources(resource, options) do
|
|
10
|
+
yield if block_given?
|
|
11
|
+
|
|
12
|
+
collection do
|
|
13
|
+
delete :destroy if batch_actions.include?(:destroy)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
member do
|
|
17
|
+
patch :move if options[:sortable]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
yield if block_given?
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -17,38 +17,6 @@ module SolidusAdmin
|
|
|
17
17
|
# The default value is the Solidus logo that lives in the solidus_core gem.
|
|
18
18
|
preference :logo_path, :string, default: "logo/solidus.svg"
|
|
19
19
|
|
|
20
|
-
# The list of paths were Tailwind CSS classes are used.
|
|
21
|
-
#
|
|
22
|
-
# You can modify this list to include your own paths:
|
|
23
|
-
#
|
|
24
|
-
# SolidusAdmin::Config.tailwind_content << Rails.root.join("app/my/custom/path")
|
|
25
|
-
#
|
|
26
|
-
# Recompile with `bin/rails solidus_admin:tailwindcss:build` after changing this list.
|
|
27
|
-
#
|
|
28
|
-
# @see https://tailwindcss.com/docs/configuration#content
|
|
29
|
-
preference :tailwind_content, :array, default: [
|
|
30
|
-
"#{ENGINE_ROOT}/app/helpers/**/*.rb",
|
|
31
|
-
"#{ENGINE_ROOT}/app/assets/javascripts/**/*.js",
|
|
32
|
-
"#{ENGINE_ROOT}/app/views/**/*.erb",
|
|
33
|
-
"#{ENGINE_ROOT}/app/components/**/*.{rb,erb,js}",
|
|
34
|
-
"#{ENGINE_ROOT}/spec/components/previews/**/*.{erb,rb}",
|
|
35
|
-
|
|
36
|
-
Rails.root&.join("public/solidus_admin/*.html"),
|
|
37
|
-
Rails.root&.join("app/helpers/solidus_admin/**/*.rb"),
|
|
38
|
-
Rails.root&.join("app/assets/javascripts/solidus_admin/**/*.js"),
|
|
39
|
-
Rails.root&.join("app/views/solidus_admin/**/*.{erb,haml,html,slim}"),
|
|
40
|
-
Rails.root&.join("app/components/solidus_admin/**/*.{rb,erb,haml,html,slim,js}")
|
|
41
|
-
].compact
|
|
42
|
-
|
|
43
|
-
# List of Tailwind CSS files to be combined into the final stylesheet.
|
|
44
|
-
#
|
|
45
|
-
# You can modify this list to include your own files:
|
|
46
|
-
#
|
|
47
|
-
# SolidusAdmin::Config.tailwind_stylesheets << Rails.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css")
|
|
48
|
-
#
|
|
49
|
-
# Recompile with `bin/rails solidus_admin:tailwindcss:build` after changing this list.
|
|
50
|
-
preference :tailwind_stylesheets, :array, default: []
|
|
51
|
-
|
|
52
20
|
# List of paths to watch for changes to trigger a cache sweep forcing a regeneration of the importmap.
|
|
53
21
|
#
|
|
54
22
|
# @see https://github.com/rails/importmap-rails#sweeping-the-cache-in-development-and-test
|
|
@@ -65,33 +33,20 @@ module SolidusAdmin
|
|
|
65
33
|
"#{ENGINE_ROOT}/config/importmap.rb",
|
|
66
34
|
]
|
|
67
35
|
|
|
68
|
-
# @!attribute [rw]
|
|
69
|
-
# @return [Integer] The
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
preference :
|
|
73
|
-
|
|
74
|
-
# @!attribute [rw]
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
# @!attribute [rw] products_per_page
|
|
84
|
-
# @return [Integer] The number of products to display per page in the admin interface.
|
|
85
|
-
# This preference determines the pagination limit for the product listing.
|
|
86
|
-
# The default value is fetched from the Spree core configuration and currently set to 10.
|
|
87
|
-
preference :products_per_page, :integer, default: Spree::Config[:admin_products_per_page]
|
|
88
|
-
|
|
89
|
-
# @!attribute [rw] product_search_key
|
|
90
|
-
# @return [String] The key to use when searching for products in the admin interface.
|
|
91
|
-
# This preference determines the product attribute to use for search.
|
|
92
|
-
# By default, it is set to 'name_or_variants_including_master_sku_cont',
|
|
93
|
-
# meaning it will search by product name or product variants sku.
|
|
94
|
-
preference :product_search_key, :string, default: :name_or_variants_including_master_sku_cont
|
|
36
|
+
# @!attribute [rw] low_stock_value
|
|
37
|
+
# @return [Integer] The low stock value determines the threshold at which products are considered low in stock.
|
|
38
|
+
# Products with a count_on_hand less than or equal to this value will be considered low in stock.
|
|
39
|
+
# Default: 10
|
|
40
|
+
preference :low_stock_value, :integer, default: 10
|
|
41
|
+
|
|
42
|
+
# @!attribute [rw] enable_alpha_features?
|
|
43
|
+
# @return [Boolean] Determines whether alpha features are enabled or disabled in the application.
|
|
44
|
+
# Setting this to `true` enables access to alpha stage features that might still be in testing or development.
|
|
45
|
+
# Use with caution, as these features may not be fully stable or complete.
|
|
46
|
+
# Default: false
|
|
47
|
+
preference :enable_alpha_features, :boolean, default: false
|
|
48
|
+
|
|
49
|
+
alias enable_alpha_features? enable_alpha_features
|
|
95
50
|
|
|
96
51
|
preference :storefront_product_path_proc, :proc, default: ->(_version) {
|
|
97
52
|
->(product) { "/products/#{product.slug}" }
|
|
@@ -186,16 +141,69 @@ module SolidusAdmin
|
|
|
186
141
|
]
|
|
187
142
|
end
|
|
188
143
|
|
|
144
|
+
def import_menu_items_from_backend!
|
|
145
|
+
menu_item_to_hash = ->(item, index) do
|
|
146
|
+
route =
|
|
147
|
+
if item.url.is_a?(Symbol)
|
|
148
|
+
-> { solidus_admin.public_send(item.url) }
|
|
149
|
+
elsif item.url.is_a?(String)
|
|
150
|
+
-> { item.url }
|
|
151
|
+
elsif item.url.is_a?(Proc)
|
|
152
|
+
item.url
|
|
153
|
+
elsif item.url.nil?
|
|
154
|
+
-> { spree.public_send(:"admin_#{item.label}_path") }
|
|
155
|
+
else
|
|
156
|
+
raise ArgumentError, "Unknown url type #{item.url.class}"
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
match_path =
|
|
160
|
+
case item.match_path
|
|
161
|
+
when Regexp then -> { _1 =~ item.match_path }
|
|
162
|
+
when Proc then item.match_path
|
|
163
|
+
when String then -> { _1.start_with?("/admin#{item.match_path}") }
|
|
164
|
+
when nil then -> { _1.start_with?(route.call) }
|
|
165
|
+
else raise ArgumentError, "Unknown match_path type #{item.match_path.class}"
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
icon =
|
|
169
|
+
case item.icon
|
|
170
|
+
when /^ri-/
|
|
171
|
+
item.icon.delete_prefix("ri-")
|
|
172
|
+
when String
|
|
173
|
+
'record-circle-line' # fallback on a generic icon
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
{
|
|
177
|
+
position: index,
|
|
178
|
+
key: item.label,
|
|
179
|
+
icon: icon,
|
|
180
|
+
route: route,
|
|
181
|
+
children: item.children.map.with_index(&menu_item_to_hash),
|
|
182
|
+
match_path: match_path,
|
|
183
|
+
}
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
@menu_items = Spree::Backend::Config.menu_items.map.with_index(&menu_item_to_hash)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
189
|
def components
|
|
190
190
|
@components ||= Hash.new do |_h, k|
|
|
191
|
-
"solidus_admin/#{k}/component".classify
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
const_name = "solidus_admin/#{k}/component".classify
|
|
192
|
+
|
|
193
|
+
unless Object.const_defined?(const_name)
|
|
194
|
+
prefix = "#{ENGINE_ROOT}/app/components/solidus_admin/"
|
|
195
|
+
suffix = "/component.rb"
|
|
196
|
+
dictionary = Dir["#{prefix}**#{suffix}"].map { _1.delete_prefix(prefix).delete_suffix(suffix) }
|
|
197
|
+
corrections = DidYouMean::SpellChecker.new(dictionary: dictionary).correct(k.to_s)
|
|
198
|
+
|
|
199
|
+
raise ComponentNotFoundError.new(
|
|
200
|
+
"Unknown component #{k}#{DidYouMean.formatter.message_for(corrections)}",
|
|
201
|
+
k.classify,
|
|
202
|
+
receiver: ::SolidusAdmin
|
|
203
|
+
)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
const_name.constantize
|
|
199
207
|
end
|
|
200
208
|
end
|
|
201
209
|
|
|
@@ -211,6 +219,26 @@ module SolidusAdmin
|
|
|
211
219
|
|
|
212
220
|
# The HTTP method used to logout the user in the admin interface.
|
|
213
221
|
preference :logout_link_method, :string, default: :delete
|
|
222
|
+
|
|
223
|
+
# @!attribute [rw] themes
|
|
224
|
+
# @return [Hash] A hash containing the themes that are available for the admin panel
|
|
225
|
+
preference :themes, :hash, default: {
|
|
226
|
+
solidus: 'solidus_admin/application',
|
|
227
|
+
solidus_dark: 'solidus_admin/dark',
|
|
228
|
+
solidus_dimmed: 'solidus_admin/dimmed',
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# @!attribute [rw] theme
|
|
232
|
+
# @return [String] Default admin theme name
|
|
233
|
+
preference :theme, :string, default: 'solidus'
|
|
234
|
+
|
|
235
|
+
# @!attribute [rw] dark_theme
|
|
236
|
+
# @return [String] Default admin theme name
|
|
237
|
+
preference :dark_theme, :string, default: 'solidus_dark'
|
|
238
|
+
|
|
239
|
+
def theme_path(user_theme)
|
|
240
|
+
themes.fetch(user_theme&.to_sym, themes[theme.to_sym])
|
|
241
|
+
end
|
|
214
242
|
end
|
|
215
243
|
end
|
|
216
244
|
|