This PR branches off the work completed in #50 so that PR should be reviewed and merged before reviewing this PR.
Description
Completes BBT-123 - This PR adds the ability for an editor to manage multiple styles at once, and to select which one of those styles is 'active'. The UI is very basic here and will change in the future, but this PR just focuses on adding the basic functionality.
I've reused the endpoint from BBT-122, but changed it up slightly so it handles both GET & POST requests - a GET request allows us to retrieve all the style variations for the current theme, and a POST request sets the active style variation for the current theme.
Rather than grabbing the globalStylesId using the core __experimentalGetCurrentGlobalStylesId() function, I'm now making a request to our endpoint and finding the post that is published as there should only ever be 1 for the current theme.
Change Log
Renamed endpoint now it has more functionality
Added GET/POST request handling on the endpoint, with the GET containing the existing functionality and the POST handling setting the active style variation
Added a <select> control in the top bar which allows us to switch between variations
Added a new Activate button which sets the variation that's currently being edited as the active variation
Steps to test
You still need to seed a 2nd variation manually using the method outlined in the PR for BBT-122 - #50
Ensure you can switch between the 2 variations
Ensure you can make changes to one variation and the other remains unaffected
Switch to the inactive variation and check you can activate it successfully.
Description
Completes BBT-123 - This PR adds the ability for an editor to manage multiple styles at once, and to select which one of those styles is 'active'. The UI is very basic here and will change in the future, but this PR just focuses on adding the basic functionality.
I've reused the endpoint from BBT-122, but changed it up slightly so it handles both GET & POST requests - a GET request allows us to retrieve all the style variations for the current theme, and a POST request sets the active style variation for the current theme.
Rather than grabbing the
globalStylesId
using the core__experimentalGetCurrentGlobalStylesId()
function, I'm now making a request to our endpoint and finding the post that is published as there should only ever be 1 for the current theme.Change Log
<select>
control in the top bar which allows us to switch between variationsActivate
button which sets the variation that's currently being edited as the active variationSteps to test
Screenshots/Videos
https://github.com/bigbite/themer/assets/45216035/7dfe7792-113c-4453-af8f-2240b2d96437
Checklist: