Skip to content

Conversation

@dermatz
Copy link
Collaborator

@dermatz dermatz commented Feb 10, 2026

This pull request adds feature-request #130 for theme support (dark, light, auto) to the MageForge Inspector component, making the inspector's appearance configurable from the Magento admin and ensuring the theme is consistently applied across the frontend UI. The changes include new configuration options, backend logic, frontend template updates, and extensive CSS and JS improvements for theming.

Configuration and Backend Integration

  • Added a new system configuration option in the Magento admin panel to select the Inspector theme (dark, light, or auto), including a source model for the theme options and ACL resource for permission control. [1] [2] [3]
  • Set the default theme to "dark" in config.xml and exposed a getTheme() method in the Inspector block to retrieve the configured theme for frontend use. [1] [2]
image

Theme support (dark, light, auto)

  • Refactored CSS to use custom properties (CSS variables) for overlay/glass effects, and introduced theme overrides for light and auto modes, including color and background adjustments for better appearance in all themes. [1] [2] [3] [4] [5]
image image

Frontend Template and Data Flow

  • Updated the frontend template (inspector.phtml) to pass the configured theme as a data-theme attribute to the root inspector element, enabling dynamic theming on the frontend.

JavaScript Theme Propagation

  • Modified the Inspector's JavaScript to propagate the data-theme attribute to all dynamically injected UI elements (highlight box, info badge, floating button), ensuring consistent theming even for elements rendered outside the root component. [1] [2] [3]

UI/UX Improvements

  • Updated the floating button's icon to a more streamlined SVG and ensured color consistency in different themes.
image

@dermatz dermatz requested a review from Copilot February 10, 2026 11:54
@dermatz dermatz enabled auto-merge (squash) February 10, 2026 11:54
@dermatz dermatz disabled auto-merge February 10, 2026 11:54
@dermatz dermatz merged commit 0a95280 into main Feb 10, 2026
16 checks passed
@dermatz dermatz deleted the feature/dark-light-mode branch February 10, 2026 11:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable dark/light/auto theming for the MageForge frontend Inspector, with an admin configuration section and frontend propagation so injected UI elements render consistently across themes.

Changes:

  • Introduces a new admin configuration section (with ACL) to select the Inspector theme (dark/light/auto) and sets a default theme in module config.
  • Exposes the configured theme via the Inspector block and passes it to the template as data-theme.
  • Updates Inspector CSS/JS to use theme-aware CSS variables and propagate theme to dynamically injected UI elements.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/view/frontend/web/js/inspector.js Propagates data-theme to injected DOM elements; updates floating button icon.
src/view/frontend/web/css/inspector.css Refactors overlay styling to CSS variables and adds light/auto theme overrides.
src/view/frontend/templates/inspector.phtml Adds data-theme attribute sourced from the block config.
src/etc/config.xml Adds default config value for mageforge/inspector/theme.
src/etc/adminhtml/system.xml Adds admin config UI for enabling Inspector and selecting theme.
src/etc/acl.xml Adds ACL resource to control access to the new config section.
src/Model/Config/Source/InspectorTheme.php Provides select options for theme (dark/light/auto).
src/Block/Inspector.php Adds getTheme() method to read configured theme for frontend rendering.
Comments suppressed due to low confidence (2)

src/view/frontend/web/js/inspector.js:321

  • Unused variable gradientId.
            const gradientId = 'mageforge-gradient-' + Math.random().toString(36).substr(2, 9);

src/view/frontend/web/js/inspector.js:942

  • Unused variable lazyIcon.
                const { lazyIcon, lazyColor } = this.getLazyLoadingStyle(a11yData.lazyLoading);

--mageforge-border-glass: rgba(255, 255, 255, 0.1);
--mageforge-shadow-glow: rgba(255, 255, 255, 0.05);
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new CSS custom property --mageforge-shadow-glow is defined (and overridden for themes) but never used anywhere in this stylesheet. Consider removing it until it’s needed, or apply it where appropriate to avoid accumulating unused variables.

Suggested change
.mageforge-inspector--glow {
box-shadow: 0 0 0 1px var(--mageforge-shadow-glow);
}

Copilot uses AI. Check for mistakes.
Comment on lines +691 to +696
--mageforge-color-slate-100: #0f172a; /* Slate 900 */
--mageforge-color-slate-200: #1e293b; /* Slate 800 */
--mageforge-color-slate-300: #334155; /* Slate 700 */
--mageforge-color-slate-400: #64748b; /* Slate 500 */
--mageforge-color-slate-500: #94a3b8; /* Slate 400 */

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the light theme override, --mageforge-color-slate-400 is assigned a darker value than --mageforge-color-slate-500 (effectively swapping the 400/500 shades vs the :root definitions). This makes the variable naming inconsistent and can lead to unexpected colors where these variables are used; consider keeping shade ordering consistent and adjusting specific usages instead.

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +23
<field id="theme" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Theme</label>
<source_model>OpenForgeProject\MageForge\Model\Config\Source\InspectorTheme</source_model>
<config_path>mageforge/inspector/theme</config_path>
<comment>Choose between Dark, Light, or Auto (System Preference) theme.</comment>
</field>
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field includes a <comment> string, but the translate attribute is only set to label. In Magento system.xml, comments won’t be picked up for translation unless you include comment in the translate list (e.g., translate="label comment").

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +92
public function getTheme(): string
{
return (string) $this->scopeConfig->getValue('mageforge/inspector/theme') ?: 'dark';
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTheme() reads mageforge/inspector/theme from the default scope only; this means website/store-view overrides configured in system.xml won’t be reflected on the storefront. Read this value using store scope (e.g., pass ScopeInterface::SCOPE_STORE to getValue()) so the frontend honors per-store configuration.

Copilot uses AI. Check for mistakes.
Comment on lines 320 to 323
// Generate unique ID for SVG gradient to avoid collisions
const gradientId = 'mageforge-gradient-' + Math.random().toString(36).substr(2, 9);

// Icon + Text with unique gradient ID
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gradientId is still generated but no longer used by the updated SVG markup. This leaves dead code and an unnecessary Math.random() call on every button creation; remove the unused variable or reintroduce a use for it.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant