Add form template interface and initial form template

[MAILPOET-2985]
This commit is contained in:
Rostislav Wolny
2020-06-30 14:01:41 +02:00
committed by Veljko V
parent 10e1a673c6
commit 42e807e2ce
2 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
<?php
namespace MailPoet\Form\Templates;
class InitialForm implements Template {
public function getName(): string {
return '';
}
public function getBody(): array {
return [
[
'id' => 'email',
'name' => __('Email', 'mailpoet'),
'type' => 'text',
'params' => [
'label' => __('Email', 'mailpoet'),
'required' => true,
'label_within' => true,
],
'styles' => [
'full_width' => true,
],
],
[
'id' => 'submit',
'name' => __('Submit', 'mailpoet'),
'type' => 'submit',
'params' => [
'label' => __('Subscribe!', 'mailpoet'),
],
'styles' => [
'full_width' => true,
],
],
];
}
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;
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace MailPoet\Form\Templates;
interface Template {
public function getName(): string;
public function getBody(): array;
public function getSettings(): array;
public function getStyles(): string;
}