feat(components): wire up the framework ComponentLoader#706
Merged
Conversation
this is added to the component loade and not to the asset because it is alongside the component so needs to be added there
…ary into refactor/component-based-php-rendering
- Created concrete `ThemeComponentLoader` that extends `AbstractComponentLoader` and implements `Shareable`. - Added `ThemeComponentLoader` to `Main` container classes to enforce a single shared instance. - Removed redundant `elementary_theme_get_components_instance()` function. - Updated `elementary_theme_component()` and `elementary_theme_get_component()` global wrappers to directly retrieve the shared loader instance from the container. - Added tests in `MainTest` to ensure the component loader is correctly shared.
Convert the asset-loading mixin into a concrete, injectable class so it has an instance identity that can be passed around and shared.
Add a context-scoped Core\Components loader (extends the framework ComponentLoader, resolves the shared Assets instance) and register it in Main. Expose Util::component()/Util::get_component() helpers backed by the shared loader, and mark Assets as Shareable so the loader resolves from the container
There was a problem hiding this comment.
Pull request overview
This PR wires the theme into the framework’s ComponentLoader so PHP components and their JS/CSS assets can be resolved and rendered consistently via a shared loader, and adds build/test support for component entry points.
Changes:
- Add a theme
Componentsloader extending the frameworkComponentLoader, sharing the themeAssetsinstance for component asset registration. - Introduce
Util::component()/Util::get_component()wrappers and bootstrap updates (namespacedfunctions.php, registerComponentsinMain). - Extend webpack to build per-component JS/SCSS from
src/components/*and emit.asset.phpmetadata for component CSS, with a Jest test for entry discovery.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
webpack.config.js |
Adds component entry discovery/build configs and emits CSS .asset.php metadata for component styles. |
tests/php/inc/MainTest.php |
Adds coverage for “component loader is shared” (currently references the wrong class). |
tests/js/webpack-config.test.js |
Adds a unit test for getComponentEntries (mock currently incomplete and will throw on require). |
tests/js/jest.config.js |
Removes unused setupFiles entry. |
src/components/card/card.scss |
Adds Card component SCSS. |
src/components/card/card.php |
Adds render-only Card component PHP partial (demonstrates nested component usage). |
src/components/card/card.js |
Adds Card component JS stub entry point. |
src/components/button/button.scss |
Adds Button component SCSS. |
src/components/button/button.php |
Adds render-only Button component PHP partial. |
src/components/button/button.js |
Adds Button component JS stub entry point. |
phpcs.xml.dist |
Excludes component partials from specific PHPCS rules due to runtime scope under the loader. |
inc/Main.php |
Registers the new Core\Components class in the bootstrap class list. |
inc/Helpers/Util.php |
Adds component wrapper helpers delegating to the shared loader instance. |
inc/Core/Components.php |
Introduces the theme’s ComponentLoader subclass and connects it to the shared Assets. |
inc/Core/Assets.php |
Marks Assets as Shareable so the component loader can reuse it. |
functions.php |
Namespaces bootstrap, centralizes constant definitions, and instantiates Main. |
.stylelintrc.json |
Ignores *.php files in stylelint runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Base automatically changed from
refactor/assets-extend-assetloader
to
theme-elementary-v2
June 4, 2026 12:37
bhavz-10
approved these changes
Jun 4, 2026
…e/component-php-render # Conflicts: # inc/Core/Assets.php
- MainTest referenced the removed Components\ThemeComponentLoader; point it at the registered Core\Components. - webpack-config jest mock lacked module/output, so requiring webpack.config threw on spread before any test ran; add them.
Refresh composer.lock: rtcamp/wp-framework dev-main b947582 → f4c2511, the main tip now carrying ComponentLoader.
pratik-londhe4
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Technical Details
Component loader (
inc/Core/Components.php)Components extends ComponentLoader implements Shareable.get_context()returnselementary(namespaces the component asset handles).get_asset_loader()resolves the sharedCore\Assetsinstance from the container.framework loader — no theme-side path configuration, no priority option.
Global wrappers →
Util(inc/Helpers/Util.php)Util::component()→ delegates toComponentLoader::render()Util::get_component()→ delegates toComponentLoader::get()component_loader();Core\Assetsis nowShareableso the loader can resolve it.
Bootstrap (
functions.php)constants()function (mirrors theplugin);
defined( 'ABSPATH' ) || exit.inc/helpers/custom-functions.phpand itsrequire— the wrappers nowlive in
Util.Components (
src/components/)card/card.phpdemonstrates composability by renderingButtoninternally viaUtil::component.Checklist
Componentsloader ininc/Core/Components.php, extends frameworkComponentLoaderUtil::component()/Util::get_component()wrappers replacecustom-functions.phpCore\AssetsmarkedShareable; loader resolves it from the containerButton+Cardrender through the loader (Card nests Button)To-do
Fixes/Covers issue
Fixes #637 (supersedes #673)