Browse Source

added and designed home footer simplenews subscription

Bachir Soussi Chiadmi 3 years ago
parent
commit
3cebce26e6

+ 36 - 0
config/sync/block.block.materiosimplenewssubscription.yml

@@ -0,0 +1,36 @@
+uuid: 9707958e-dc3d-43f9-a449-84993d135dae
+langcode: en
+status: true
+dependencies:
+  module:
+    - context
+    - materio_simplenews
+  theme:
+    - materiotheme
+id: materiosimplenewssubscription
+theme: materiotheme
+region: footer_left
+weight: 0
+provider: null
+plugin: materio_simplenews_subscription_block
+settings:
+  id: materio_simplenews_subscription_block
+  label: 'Materio Simplenews subscription'
+  provider: materio_simplenews
+  label_display: '0'
+  newsletters:
+    materio_newsletter: materio_newsletter
+    ze_daily_materio_: ze_daily_materio_
+  message: 'Stay informed - subscribe to our newsletter.'
+  unique_id: d0c7bdf4-c218-4ded-840a-9c4c731ec469
+visibility:
+  view_inclusion:
+    id: view_inclusion
+    negate: null
+    view_inclusion: {  }
+    context_mapping: {  }
+  request_path_exclusion:
+    id: request_path_exclusion
+    pages: ''
+    negate: null
+    context_mapping: {  }

+ 12 - 0
config/sync/core.entity_form_mode.simplenews_subscriber.materio_block.yml

@@ -0,0 +1,12 @@
+uuid: a97d0282-01c9-4b2e-8f91-24b0e3e6443c
+langcode: en
+status: true
+dependencies:
+  module:
+    - simplenews
+_core:
+  default_config_hash: leCpWOylvfK6ArYQp2n7dcGoAFC_A-X7qQm5FdYToWg
+id: simplenews_subscriber.materio_block
+label: Block
+targetEntityType: simplenews_subscriber
+cache: true

+ 1 - 0
config/sync/core.extension.yml

@@ -116,6 +116,7 @@ module:
   materio_migrate: 0
   materio_samples: 0
   materio_sapi: 0
+  materio_simplenews: 0
   materio_user: 0
   matomo: 0
   maxlength: 0

+ 1 - 0
config/sync/language/fr/core.entity_form_mode.simplenews_subscriber.materio_block.yml

@@ -0,0 +1 @@
+label: Bloc

+ 9 - 0
web/modules/custom/materio_simplenews/config/install/core.entity_form_mode.simplenews_subscriber.materio_block.yml

@@ -0,0 +1,9 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - simplenews
+id: simplenews_subscriber.materio_block
+label: Materio Block
+targetEntityType: simplenews_subscriber
+cache: true

+ 7 - 0
web/modules/custom/materio_simplenews/materio_simplenews.info.yml

@@ -0,0 +1,7 @@
+name: Materio Simple News
+type: module
+description: 'Simple News extensions Materio module'
+core: 8.x
+package: 'Materio'
+dependencies:
+  - simplenews

+ 5 - 0
web/modules/custom/materio_simplenews/materio_simplenews.module

@@ -0,0 +1,5 @@
+<?php
+
+function materio_simplenews_entity_type_alter(array &$entity_types) {
+  $entity_types['simplenews_subscriber']->setFormClass('materio_block', '\Drupal\materio_simplenews\Form\MaterioSubscriptionsBlockForm');
+}

+ 103 - 0
web/modules/custom/materio_simplenews/src/Form/MaterioSubscriptionsBlockForm.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace Drupal\materio_simplenews\Form;
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\simplenews\Form\SubscriptionsFormBase;
+
+/**
+ * Configure simplenews subscriptions of the logged user.
+ */
+class MaterioSubscriptionsBlockForm extends SubscriptionsFormBase {
+
+  protected $uniqueId;
+
+  /**
+   * A message to use as description for the block.
+   *
+   * @var string
+   */
+  public $message;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    if (empty($this->uniqueId)) {
+      throw new \Exception('Unique ID must be set with setUniqueId.');
+    }
+    return 'materio_simplenews_subscriptions_block_' . $this->uniqueId;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUniqueId($id) {
+    $this->uniqueId = $id;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function form(array $form, FormStateInterface $form_state) {
+    // Hide subscription widget if only one newsletter available.
+    if (count($this->getNewsletters()) == 1) {
+      $this->getSubscriptionWidget($form_state)->setHidden();
+    }
+
+    $form = parent::form($form, $form_state);
+
+    // $form['message'] = array(
+    //   '#type' => 'item',
+    //   '#markup' => $this->message,
+    // );
+
+    unset($form['subscriptions']['widget']['#title']);
+    unset($form['subscriptions']['widget']['#description']);
+    unset($form['mail']['widget']['#title']);
+    unset($form['mail']['widget']['#description']);
+    unset($form['mail']['widget'][0]['#title']);
+    unset($form['mail']['widget'][0]['#title_display']);
+    unset($form['mail']['widget'][0]['#description']);
+    $form['mail']['widget'][0]['value']['#placeholder'] = t('email');
+    unset($form['mail']['widget'][0]['value']['#title']);
+    unset($form['mail']['widget'][0]['value']['#description']);
+
+    $mailvalue = $form['mail']['widget'][0];
+    $test='test';
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function actions(array $form, FormStateInterface $form_state) {
+    $actions = parent::actions($form, $form_state);
+    $actions[static::SUBMIT_UPDATE]['#value'] = $this->t('Update');
+    return $actions;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getSubmitMessage(FormStateInterface $form_state, $op, $confirm) {
+    switch ($op) {
+      case static::SUBMIT_UPDATE:
+        return $this->t('The newsletter subscriptions for %mail have been updated.', array('%mail' => $form_state->getValue('mail')[0]['value']));
+
+      case static::SUBMIT_SUBSCRIBE:
+        if ($confirm) {
+          return $this->t('You will receive a confirmation e-mail shortly containing further instructions on how to complete your subscription.');
+        }
+        return $this->t('You have been subscribed.');
+
+      case static::SUBMIT_UNSUBSCRIBE:
+        if ($confirm) {
+          return $this->t('You will receive a confirmation e-mail shortly containing further instructions on how to cancel your subscription.');
+        }
+        return $this->t('You have been unsubscribed.');
+    }
+  }
+
+}

+ 184 - 0
web/modules/custom/materio_simplenews/src/Plugin/Block/MaterioSimplenewsSubscriptionBlock.php

@@ -0,0 +1,184 @@
+<?php
+
+namespace Drupal\materio_simplenews\Plugin\Block;
+
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Form\FormBuilderInterface;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\simplenews\Entity\Subscriber;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Provides an 'Simplenews subscription' block with all available newsletters and an email field.
+ *
+ * @Block(
+ *   id = "materio_simplenews_subscription_block",
+ *   admin_label = @Translation("Materio Simplenews subscription"),
+ *   category = @Translation("Simplenews")
+ * )
+ */
+class MaterioSimplenewsSubscriptionBlock extends BlockBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * The form builder.
+   *
+   * @var \Drupal\Core\Form\FormBuilderInterface
+   */
+  protected $formBuilder;
+
+  /**
+   * Constructs an SimplenewsSubscriptionBlock object.
+   *
+   * @param array $configuration
+   *   A configuration array containing information about the plugin instance.
+   * @param string $plugin_id
+   *   The plugin_id for the plugin instance.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   * @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
+   *   The form builder object.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, FormBuilderInterface $formBuilder) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->entityTypeManager = $entity_type_manager;
+    $this->formBuilder = $formBuilder;
+  }
+
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('entity_type.manager'),
+      $container->get('form_builder')
+    );
+  }
+
+
+  /**
+   * {@inheritdoc}
+   */
+  public function defaultConfiguration() {
+    // By default, the block will contain 1 newsletter.
+    return array(
+      'newsletters' => array(),
+      'message' => t('Stay informed - subscribe to our newsletter.'),
+      'unique_id' => '',
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function blockAccess(AccountInterface $account) {
+    // Only grant access to users with the 'subscribe to newsletters' permission.
+    return AccessResult::allowedIfHasPermission($account, 'subscribe to newsletters');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function blockForm($form, FormStateInterface $form_state) {
+    $newsletters = simplenews_newsletter_get_visible();
+    foreach ($newsletters as $newsletter) {
+      $options[$newsletter->id()] = $newsletter->name;
+    }
+
+    $form['newsletters'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Newsletters'),
+      '#options' => $options,
+      '#required' => TRUE,
+      '#default_value' => $this->configuration['newsletters'],
+    );
+    $form['message'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Block message'),
+      '#size' => 60,
+      '#maxlength' => 255,
+      '#default_value' => $this->configuration['message'],
+    );
+    $form['unique_id'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Unique ID'),
+      '#size' => 60,
+      '#maxlength' => 255,
+      '#description' => t('Each subscription block must have a unique form ID. If no value is provided, a random ID will be generated. Use this to have a predictable, short ID, e.g. to configure this form use a CAPTCHA.'),
+      '#default_value' => $this->configuration['unique_id'],
+    );
+    /*if (\Drupal::moduleHandler()->moduleExists('views')) {
+        $form['link_previous'] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Display link to previous issues'),
+          '#return_value' => 1,
+          '#default_value' => variable_get('simplenews_block_l_' . $delta, 1),
+          '#description' => t('Link points to newsletter/newsletter_id, which is provided by the newsletter issue list default view.'),
+        );
+      }*/
+    /*if (\Drupal::moduleHandler()->moduleExists('views')) {
+      $form['rss_feed'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Display RSS-feed icon'),
+        '#return_value' => 1,
+        '#default_value' => variable_get('simplenews_block_r_' . $delta, 1),
+        '#description' => t('Link points to newsletter/feed/newsletter_id, which is provided by the newsletter issue list default view.'),
+      );
+    }*/
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function blockSubmit($form, FormStateInterface $form_state) {
+    $this->configuration['newsletters'] = array_filter($form_state->getValue('newsletters'));
+    $this->configuration['message'] = $form_state->getValue('message');
+    //$this->configuration['link_previous'] = $form_state->getValue('link_previous');
+    //$this->configuration['rss_feed'] = $form_state->getValue('rss_feed');
+    $this->configuration['unique_id'] = empty($form_state->getValue('unique_id')) ? \Drupal::service('uuid')->generate() : $form_state->getValue('unique_id');
+}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build() {
+    /** @var \Drupal\materio_simplenews\Form\MaterioSubscriptionsBlockForm $form_object */
+    $form_object = $this->entityTypeManager->getFormObject('simplenews_subscriber', 'materio_block');
+    $form_object->setUniqueId($this->configuration['unique_id']);
+    $form_object->setNewsletterIds($this->configuration['newsletters']);
+    $form_object->message = $this->configuration['message'];
+
+    // Set the entity on the form.
+    if ($user = \Drupal::currentUser()) {
+      if ($subscriber = simplenews_subscriber_load_by_uid($user->id())) {
+        $form_object->setEntity($subscriber);
+      }
+      else {
+        $form_object->setEntity(Subscriber::create()->fillFromAccount($user));
+      }
+    }
+    else {
+      $form_object->setEntity(Subscriber::create());
+    }
+
+    return $this->formBuilder->getForm($form_object);
+  }
+
+}

+ 45 - 19
web/themes/custom/materiotheme/assets/dist/main.css

@@ -1096,58 +1096,58 @@ div.dialog-off-canvas-main-canvas {
 body.toolbar-horizontal.toolbar-themes.toolbar-no-tabs {
   padding-top: 24px !important; }
 
-header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
   margin: 0 auto; }
   @media only screen and (max-width: 436px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 436px; } }
   @media only screen and (min-width: 655px) and (max-width: 872px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 654px; } }
   @media only screen and (min-width: 873px) and (max-width: 1090px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 872px; } }
   @media only screen and (min-width: 1091px) and (max-width: 1308px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 1090px; } }
   @media only screen and (min-width: 1309px) and (max-width: 1526px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 1308px; } }
   @media only screen and (min-width: 1527px) and (max-width: 1744px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 1526px; } }
   @media only screen and (min-width: 1745px) and (max-width: 1962px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 1744px; } }
   @media only screen and (min-width: 1963px) and (max-width: 2180px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 1962px; } }
   @media only screen and (min-width: 2181px) and (max-width: 2398px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 2180px; } }
   @media only screen and (min-width: 2399px) and (max-width: 2616px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 2398px; } }
   @media only screen and (min-width: 2617px) and (max-width: 2834px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 2616px; } }
   @media only screen and (min-width: 2835px) and (max-width: 3052px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 2834px; } }
   @media only screen and (min-width: 3053px) and (max-width: 3270px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 3052px; } }
   @media only screen and (min-width: 3271px) and (max-width: 3488px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 3270px; } }
   @media only screen and (min-width: 3489px) and (max-width: 3706px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 3488px; } }
   @media only screen and (min-width: 3707px) and (max-width: 3924px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 3706px; } }
   @media only screen and (min-width: 3925px) and (max-width: 4142px) {
-    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper {
+    header[role="banner"] .wrapper, main[role="main"] > .scroller > .wrapper, footer[role="contentinfo"] > .wrapper {
       width: 3924px; } }
 
 header[role="banner"] {
@@ -1607,7 +1607,7 @@ article.node--type-frontpage .node__content > section.home-showrooms {
     article.node--type-frontpage .node__content > section.home-showrooms .field--name-computed-showrooms-reference > .field__item {
       grid-row: 1;
       opacity: 0;
-      transition: all 0.7s ease-out; }
+      transition: all 2s ease-out; }
       article.node--type-frontpage .node__content > section.home-showrooms .field--name-computed-showrooms-reference > .field__item.active {
         opacity: 1; }
       article.node--type-frontpage .node__content > section.home-showrooms .field--name-computed-showrooms-reference > .field__item .taxonomy-term {
@@ -2029,3 +2029,29 @@ article.card {
       #showrooms article.showroom figure img {
         max-width: 100%; }
 
+footer[role="contentinfo"] #block-materiosimplenewssubscription form {
+  display: flex;
+  flex-flow: row nowrap;
+  align-items: center;
+  font-size: 0.756em; }
+  footer[role="contentinfo"] #block-materiosimplenewssubscription form > * {
+    margin-right: 0.5em; }
+  footer[role="contentinfo"] #block-materiosimplenewssubscription form #edit-subscriptions {
+    display: flex;
+    flex-flow: row nowrap; }
+    footer[role="contentinfo"] #block-materiosimplenewssubscription form #edit-subscriptions > * {
+      margin-right: 0.5em;
+      display: flex;
+      flex-flow: row nowrap;
+      align-items: center; }
+  footer[role="contentinfo"] #block-materiosimplenewssubscription form #edit-mail-wrapper input[type="email"] {
+    width: 10em; }
+  footer[role="contentinfo"] #block-materiosimplenewssubscription form #edit-actions--2 input[type="submit"] {
+    border: none;
+    background: none;
+    background-color: #69cdcf;
+    border-radius: 5px;
+    color: #fff;
+    padding: 0.7em 1em;
+    font-weight: 700; }
+

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/materiotheme/assets/dist/main.js


+ 11 - 0
web/themes/custom/materiotheme/assets/styles/base/_layout.scss

@@ -172,3 +172,14 @@ main[role="main"]{
     }
   }
 }
+
+
+//  ___         _
+// | __|__  ___| |_ ___ _ _
+// | _/ _ \/ _ \  _/ -_) '_|
+// |_|\___/\___/\__\___|_|
+footer[role="contentinfo"]{
+  >.wrapper{
+    @extend %grided-width;
+  }
+}

+ 48 - 3
web/themes/custom/materiotheme/assets/styles/main.scss

@@ -674,11 +674,9 @@ article.node--type-frontpage{
             // top:0; left:0;
             // width:100%; height:100%;
             // overflow: hidden;
-
             opacity: 0;
             // transform: translateX(100%);
-            transition: all 0.7s ease-out;
-
+            transition: all 2s ease-out;
             &.active{
               opacity: 1;
               // transform: translateX(0);
@@ -1319,3 +1317,50 @@ article.card{
   }
 
 }
+
+
+//  ___         _
+// | __|__  ___| |_ ___ _ _
+// | _/ _ \/ _ \  _/ -_) '_|
+// |_|\___/\___/\__\___|_|
+footer[role="contentinfo"]{
+  #block-materiosimplenewssubscription{
+    form{
+      display: flex;
+      flex-flow: row nowrap;
+      align-items: center;
+      font-size: 0.756em;
+      >*{
+        margin-right: 0.5em;
+      }
+      #edit-subscriptions{
+        display: flex;
+        flex-flow: row nowrap;
+        >*{
+          margin-right: 0.5em;
+          display: flex;
+          flex-flow: row nowrap;
+          align-items: center;
+        }
+      }
+      #edit-mail-wrapper{
+        input[type="email"]{
+          width:10em;
+        }
+      }
+      #edit-actions--2{
+        input[type="submit"]{
+          border: none;
+          background: none;
+          background-color: $color-base;
+          border-radius: 5px;
+          color: #fff;
+          padding: 0.7em 1em;
+          font-weight: 700;
+        }
+      }
+    }
+
+
+  }
+}

+ 1 - 1
web/themes/custom/materiotheme/vuejs/components/Pages/Home.vue

@@ -91,7 +91,7 @@ export default {
         this.showroomJ = 0
       }
       // in any case (re)launch the animation
-      this.showroomInterval = setInterval(this.switchShowroomCarroussel.bind(this), 5000);
+      this.showroomInterval = setInterval(this.switchShowroomCarroussel.bind(this), 15000);
       console.log('this.showroomInterval', this.showroomInterval);
       this.switchShowroomCarroussel()
     },

Some files were not shown because too many files changed in this diff