Skip to content

Refactor gallery builder for flexible thumbnail position#59

Open
younes-dro wants to merge 32 commits into
devfrom
feature/gallery-layouts-default
Open

Refactor gallery builder for flexible thumbnail position#59
younes-dro wants to merge 32 commits into
devfrom
feature/gallery-layouts-default

Conversation

@younes-dro

@younes-dro younes-dro commented Jul 11, 2025

Copy link
Copy Markdown
Owner
  1. Renamed interface alias for clarity and updated the gallery builder to support dynamic thumbnail positioning.
  2. Simplified layout rendering logic to use the thumb_position config value directly, enabling easier support for multiple positions.
  3. Added a TODO for dependency injection consideration.

Renamed interface alias for clarity and updated the gallery builder to support dynamic thumbnail positioning. Simplified layout rendering logic to use the thumb_position config value directly, enabling easier support for multiple positions. Added a TODO for dependency injection consideration.
Replaced hardcoded asset version strings with `DRO_PVVP_VERSION` constant, which is now dynamically set from the plugin file metadata. This ensures asset versioning matches the plugin version automatically.
Refactored gallery factory to accept an array for configuration instead of a string, and set the layout from the config array. Changed default thumbnail position in product image template from 'bottom' to 'left'.
The Default_Gallery class now accepts an optional configuration array in its constructor, allowing dynamic setup of builder properties such as layout, thumbnail position and size, main image size, slider and lightbox options, lazy loading, CSS classes, and data attributes.
The factory has been updated to pass the config when instantiating Default_Gallery.
Replaced var_dump with error_log for better debugging in Default Builder. Updated gallery layout creation to pass full config array instead of just layout key. Added a TODO for future dependency injection in Default Gallery constructor.
The gallery now renders images for each available product variation using DRO_PVVP_Variation_Data_Provider. This change enables displaying main images and thumbnails per variation, improving the gallery's flexibility and user experience.
Updated the try-catch block to catch Throwable instead of Exception when rendering the product image gallery. This ensures that both exceptions and errors are handled, improving error logging and fallback behavior.
Renamed the Variation_Data_Provider property in DRO_PVVP_Default_Builder for clarity and removed the unused DRO_PVVP_Gallery_Builder class. Also cleaned up error logging and simplified the build method's image checks.
1- Renamed `DRO_PVVP_Default_Gallery` to `DRO_PVVP_Default_Layout` .
2- Updated all references in the factory and layout files to reflect the new class and file name.
Corrects the misspelling of the 'builder' property (previously 'buidler') and updates all references in the DRO_PVVP_Default_Layout class to use the correct property name.
Added a unit test for `DRO_PVVP_Default_Layout` to verify configuration values are correctly passed to the builder.
Updated set_layout method in `DRO_PVVP_Default_Builder` to assign the provided layout value instead of hardcoding 'default'.
Updated the unit tests for DRO_PVVP_Gallery_Factory to use the new create_gallery_layout method and updated namespace imports.
Removed tests for deprecated methods and added tests for layout instantiation and error handling with unknown layouts.
Introduces a unit test to verify that create_gallery_layout falls back to the 'default' layout when provided with an empty layout value.
Replaces direct usage of DRO_PVVP_Variation_Data_Provider with an alias (Provider) throughout the test file for clarity.
Adds a new unit test for the set_product method to verify it stores the WC_Product instance and returns the provider object.
1- Introduces DRO_PVVP_Invalid_Product_Exception to handle cases where a product is not set or not a variable product.
2- Updates the variation data provider and related interfaces to throw this exception, and adds error handling in the default gallery layout.
3-iIncludes minor code cleanup and formatting improvements across several files.
Updated the import of DRO_PVVP_Variation_Data_Provider to use an alias 'Provider' and updated its usage in the render method for improved code clarity.
…e product

- Created a variable product with attribute 'pa_color'
- Added two variations with different prices and attributes
- Verified get_available_variations() returns expected array structure
- Ensured returned array contains required variation data (e.g., attributes, display_price)

Related to: DRO_PVVP_Variation_Data_Provider::get_available_variations
…p into setUp()

- Registered the 'pa_color' taxonomy and ensured the 'red' term exists in setUp() to avoid duplication across tests.
- Created the variable product and its variations within setUp() for reusable test fixture setup.
- Improved test isolation and clarity by centralizing environment preparation.
- Ensured tests run reliably with consistent test data setup.
Cleaned up the DRO_PVVP_Variation_Data_Provider_Test class by removing extra blank lines in the setUp method for improved code readability.
Added 'declare(strict_types=1);' and appropriate namespace declarations to multiple PHP files for improved type safety and code consistency. Also fixed a minor function call in class-dro-pvvp.php and added a placeholder test method in the unit test file.
…lery layout exception

- Added temporary filter 'disable_variation_image_collections' to bypass override during fallback
- Ensured filter is removed after loading default WooCommerce template to restore normal behavior
Replaces the switch statement with dynamic class name construction for gallery layouts.
Comment thread includes/gallery/factories/class-dro-pvvp-gallery-factory.php
Introduced new SCSS and compiled CSS files for the default frontend layout. Updated gulpfile.js to add tasks for compiling and watching layout SCSS files. Refactored asset registration in PHP: renamed enqueue_assets() to register_assets(), updated asset paths, and ensured styles/scripts are registered and enqueued properly for the default layout.
-Introduces a new frontend layout entry (default-layout) with corresponding TypeScript, JS, and CSS/SCSS files.
-Updates asset registration in PHP to use the new file names and paths. Enhances webpack config to support frontend layout builds and adds related npm scripts for development and production.
-Renames files for consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant