Refactor form templates to use inheritance
[MAILPOET-2810]
This commit is contained in:
committed by
Veljko V
parent
21367ef05d
commit
defc83e0c4
@@ -2,12 +2,93 @@
|
|||||||
|
|
||||||
namespace MailPoet\Form\Templates;
|
namespace MailPoet\Form\Templates;
|
||||||
|
|
||||||
interface Template {
|
abstract class Template {
|
||||||
public function getName(): string;
|
abstract public function getName(): string;
|
||||||
|
|
||||||
public function getBody(): array;
|
abstract public function getBody(): array;
|
||||||
|
|
||||||
public function getSettings(): array;
|
public function getSettings(): array {
|
||||||
|
return [
|
||||||
|
'on_success' => 'message',
|
||||||
|
'success_message' => '',
|
||||||
|
'segments' => null,
|
||||||
|
'segments_selected_by' => 'admin',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function getStyles(): string;
|
public function getStyles(): string {
|
||||||
|
return <<<EOL
|
||||||
|
/* form */
|
||||||
|
.mailpoet_form {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* columns */
|
||||||
|
.mailpoet_column_with_background {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
/* space between columns */
|
||||||
|
.mailpoet_form_column:not(:first-child) {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* input wrapper (label + input) */
|
||||||
|
.mailpoet_paragraph {
|
||||||
|
line-height:20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* labels */
|
||||||
|
.mailpoet_segment_label,
|
||||||
|
.mailpoet_text_label,
|
||||||
|
.mailpoet_textarea_label,
|
||||||
|
.mailpoet_select_label,
|
||||||
|
.mailpoet_radio_label,
|
||||||
|
.mailpoet_checkbox_label,
|
||||||
|
.mailpoet_list_label,
|
||||||
|
.mailpoet_date_label {
|
||||||
|
display:block;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inputs */
|
||||||
|
.mailpoet_text,
|
||||||
|
.mailpoet_textarea,
|
||||||
|
.mailpoet_select,
|
||||||
|
.mailpoet_date_month,
|
||||||
|
.mailpoet_date_day,
|
||||||
|
.mailpoet_date_year,
|
||||||
|
.mailpoet_date {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_text,
|
||||||
|
.mailpoet_textarea {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_checkbox {
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_submit {
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_divider {
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_message {
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_form_loading {
|
||||||
|
width: 30px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailpoet_form_loading > span {
|
||||||
|
width: 5px;
|
||||||
|
height: 5px;
|
||||||
|
background-color: #5b5b5b;
|
||||||
|
}
|
||||||
|
EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ use MailPoet\Form\Templates\Template;
|
|||||||
/**
|
/**
|
||||||
* Template for default form created on plugin activation
|
* Template for default form created on plugin activation
|
||||||
*/
|
*/
|
||||||
class DefaultForm extends InitialForm implements Template {
|
class DefaultForm extends Template {
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return _x('My First Form', 'default name of form (GDPR friendly) to capture emails', 'mailpoet');
|
return _x('My First Form', 'default name of form (GDPR friendly) to capture emails', 'mailpoet');
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ use MailPoet\Form\Templates\Template;
|
|||||||
/**
|
/**
|
||||||
* Temporary form template. Remove after we get real data from designer
|
* Temporary form template. Remove after we get real data from designer
|
||||||
*/
|
*/
|
||||||
class DemoForm implements Template {
|
class DemoForm extends Template {
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return 'My Fancy Form';
|
return 'My Fancy Form';
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@ namespace MailPoet\Form\Templates\Templates;
|
|||||||
|
|
||||||
use MailPoet\Form\Templates\Template;
|
use MailPoet\Form\Templates\Template;
|
||||||
|
|
||||||
class InitialForm implements Template {
|
class InitialForm extends Template {
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -37,89 +37,4 @@ class InitialForm implements Template {
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSettings(): array {
|
|
||||||
return [
|
|
||||||
'on_success' => 'message',
|
|
||||||
'success_message' => '',
|
|
||||||
'segments' => null,
|
|
||||||
'segments_selected_by' => 'admin',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStyles(): string {
|
|
||||||
return <<<EOL
|
|
||||||
/* form */
|
|
||||||
.mailpoet_form {
|
|
||||||
}
|
|
||||||
|
|
||||||
/* columns */
|
|
||||||
.mailpoet_column_with_background {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
/* space between columns */
|
|
||||||
.mailpoet_form_column:not(:first-child) {
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* input wrapper (label + input) */
|
|
||||||
.mailpoet_paragraph {
|
|
||||||
line-height:20px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* labels */
|
|
||||||
.mailpoet_segment_label,
|
|
||||||
.mailpoet_text_label,
|
|
||||||
.mailpoet_textarea_label,
|
|
||||||
.mailpoet_select_label,
|
|
||||||
.mailpoet_radio_label,
|
|
||||||
.mailpoet_checkbox_label,
|
|
||||||
.mailpoet_list_label,
|
|
||||||
.mailpoet_date_label {
|
|
||||||
display:block;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* inputs */
|
|
||||||
.mailpoet_text,
|
|
||||||
.mailpoet_textarea,
|
|
||||||
.mailpoet_select,
|
|
||||||
.mailpoet_date_month,
|
|
||||||
.mailpoet_date_day,
|
|
||||||
.mailpoet_date_year,
|
|
||||||
.mailpoet_date {
|
|
||||||
display:block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_text,
|
|
||||||
.mailpoet_textarea {
|
|
||||||
width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_checkbox {
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_submit {
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_divider {
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_message {
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_form_loading {
|
|
||||||
width: 30px;
|
|
||||||
text-align: center;
|
|
||||||
line-height: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mailpoet_form_loading > span {
|
|
||||||
width: 5px;
|
|
||||||
height: 5px;
|
|
||||||
background-color: #5b5b5b;
|
|
||||||
}
|
|
||||||
EOL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user