Skip to content

feat(components): wire up the framework ComponentLoader#706

Merged
aryanjasala merged 32 commits into
theme-elementary-v2from
feature/component-php-render
Jun 4, 2026
Merged

feat(components): wire up the framework ComponentLoader#706
aryanjasala merged 32 commits into
theme-elementary-v2from
feature/component-php-render

Conversation

@aryanjasala
Copy link
Copy Markdown
Member

Technical Details

Component loader (inc/Core/Components.php)

  • Components extends ComponentLoader implements Shareable.
  • get_context() returns elementary (namespaces the component asset handles).
  • get_asset_loader() resolves the shared Core\Assets instance from the container.
  • Override hierarchy (child theme → parent theme → plugin) falls out of the
    framework loader — no theme-side path configuration, no priority option.

Global wrappers → Util (inc/Helpers/Util.php)

  • Util::component() → delegates to ComponentLoader::render()
  • Util::get_component() → delegates to ComponentLoader::get()
  • Both backed by a shared component_loader(); Core\Assets is now Shareable
    so the loader can resolve it.

Bootstrap (functions.php)

  • Namespaced; theme constants defined via a constants() function (mirrors the
    plugin); defined( 'ABSPATH' ) || exit.
  • Removes inc/helpers/custom-functions.php and its require — the wrappers now
    live in Util.

Components (src/components/)

  • card/card.php demonstrates composability by rendering Button internally via
    Util::component.

Checklist

  • Components loader in inc/Core/Components.php, extends framework ComponentLoader
  • Resolution + override via the framework hierarchy (child > parent > plugin); no theme path config
  • Util::component() / Util::get_component() wrappers replace custom-functions.php
  • Core\Assets marked Shareable; loader resolves it from the container
  • Components are render-only — no business logic, no data fetching
  • Button + Card render through the loader (Card nests Button)
  • No regressions in existing templates

To-do

  • Component library build-out (TASK-007)
  • Scaffold CLI for generating new components (TASK-009)

Fixes/Covers issue

Fixes #637 (supersedes #673)

abhishekxix and others added 29 commits April 29, 2026 13:00
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
@aryanjasala aryanjasala requested a review from Copilot June 4, 2026 02:46
Copy link
Copy Markdown

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

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 Components loader extending the framework ComponentLoader, sharing the theme Assets instance for component asset registration.
  • Introduce Util::component() / Util::get_component() wrappers and bootstrap updates (namespaced functions.php, register Components in Main).
  • Extend webpack to build per-component JS/SCSS from src/components/* and emit .asset.php metadata 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.

Comment thread tests/js/webpack-config.test.js
Comment thread tests/php/inc/MainTest.php Outdated
Comment thread tests/php/inc/MainTest.php
Comment thread functions.php
Base automatically changed from refactor/assets-extend-assetloader to theme-elementary-v2 June 4, 2026 12:37
…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.
@aryanjasala aryanjasala merged commit 65634b9 into theme-elementary-v2 Jun 4, 2026
8 checks passed
@aryanjasala aryanjasala deleted the feature/component-php-render branch June 4, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants