Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Feature: Form template registration #33

Merged
merged 17 commits into from
Jul 16, 2022
Merged

Conversation

jonwaldstein
Copy link
Contributor

@jonwaldstein jonwaldstein commented Jul 12, 2022

Description

We recently introduced the initial template api as it relates to customizing the front-end. This PR accompanies that by adding a template registration system so new Templates can get registered and pull in their front-end assets.

One of the goals for Templates, is keeping it as simple as possible. If someone wants to create a template that just pulls in some CSS we want them to get up and running easily. Here is a birds eye view of a template simplicity using the (work-in-progress) classic template as an example:

class ClassicFormTemplate extends FormTemplate {

    public static function id(): string
    {
        return 'classic';
    }

    public static function name(): string
    {
        return __('Classic Template', 'give');
    }

    public function css(): string
    {
        return GIVE_NEXT_GEN_URL . 'src/NextGen/DonationForm/FormTemplates/ClassicFormTemplate/template.css';
    }

    public function js(): string
    {
        return GIVE_NEXT_GEN_URL . 'src/NextGen/DonationForm/FormTemplates/ClassicFormTemplate/template.js';
    }
}

add_action('givewp_register_form_template', function (FormTemplateRegistrar $formTemplateRegistrar) {
    $formTemplateRegistrar->registerTemplate(ClassicFormTemplate::class);
});

Affects

The new "classic form" was created as the new default for next gen forms. Viewing the form should reflect some basic CSS to show the template is active. Note - this PR is not intended to have a complete version of the Classic Template - just using it for a tangible example until we're ready to build it out.

Also added phpunit here out of necessity.

Visuals

Screen Shot 2022-07-13 at 5 37 43 PM

Testing Instructions

View a NextGen form and see some basic css applied. This is the start of what will soon be the Classic Template.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

@github-actions
Copy link

A build of this branch is available at https://impress-org.github.io/givewp-next-gen/feature/template-registration

@jonwaldstein jonwaldstein marked this pull request as ready for review July 15, 2022 15:01
@jonwaldstein jonwaldstein requested a review from kjohnson July 15, 2022 15:03
@jonwaldstein
Copy link
Contributor Author

@kjohnson this is ready for review.

Copy link
Contributor

@kjohnson kjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonwaldstein added my review - mostly questions and additional commentary. Otherwise, not opposed to this getting merged soon, so I submitted the review as a "Comment" as opposed to "Request Changes".

@kjohnson kjohnson merged commit a29ee08 into develop Jul 16, 2022
@github-actions
Copy link

A build of this branch is available at https://impress-org.github.io/givewp-next-gen/develop

@jonwaldstein jonwaldstein deleted the feature/template-registration branch July 19, 2022 15:29
@jonwaldstein jonwaldstein self-assigned this Jul 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants