Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor layouts #20

Merged
merged 25 commits into from
Jan 13, 2024
Merged

Refactor layouts #20

merged 25 commits into from
Jan 13, 2024

Conversation

simonhamp
Copy link
Owner

@simonhamp simonhamp commented Jan 13, 2024

This PR allows for really flexible layouts, allowing you to display whatever text or pictures you want in your image and laying them out relative to each other in more complex ways.

Added

  • New PictureBox feature: You can now load other pictures into your designs 🖼️
  • A new TwoUp layout, with a picture to the left and the text content to the right

Sneaker photo by Matthew Hamilton on Unsplash

Changed

  • Layouts have been refactored, to move away from a fixed set of features defined in the base Layout class, to a fully dynamic set, defined in the child Layout class.
    This means you can now define as many features as you like within your Layout class and aren't limited to what this library supports by default
  • More reliance on interfaces, moving many references to the Box class to a new Box interface
  • Some theme colours have been improved

Fixed

  • Box rendering logic has been massively improved. You can now make points other than just the top-left (the default $anchor) of a box relative to the $anchor of any other feature.
  • Improved some tests

This will allow us to get more flexible layouts
As all of the config needs to be in the main layout class anyway, we're better off just moving all of that logic there to keep it together
If we do it too early, we may not have the other feature available that we're basing it on

By resolving this later, we allow the layout class to define all features first before trying to calculate their relative positions
This can be used a pure playground rather than a demo of a given layout setup
This allows us to position the anchor point of text-boxes according to their rendered size without getting caught in an infinite loop
There are a load of breaks in here, but basically needed in order to get closer to that perfect API.

It's now possible to define complex relativeTo closure logic and have it respected

$pivot was renamed to $anchor
As it's optional, we need to handle that better
No features

Updates snapshots because of minor layout improvements
@simonhamp simonhamp added the breaking-change This PR contains breaking changes, so a new major version will be required label Jan 13, 2024
# Conflicts:
#	src/Traits/RendersFeatures.php
#	tests/Integration/ImageTest.php
#	tests/Integration/__snapshots__/ImageTest__test_basic_image with data set basic with background url__1.png
#	tests/Integration/__snapshots__/ImageTest__test_basic_image with data set different theme with background url__1.png
@simonhamp simonhamp merged commit 8812b17 into main Jan 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This PR contains breaking changes, so a new major version will be required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant