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

Call To Action

Jonathan Tsang edited this page Sep 1, 2017 · 1 revision

Description

Used On

  • Bundle
  • Course Landing
  • Site Landing

Template Markup

<section class="call-to-action {% if section.settings.background_image != blank %}full-width-background{% endif %} {% if section.settings.background_color_preset != 'none' %}{{ section.settings.background_color_preset | append: '-section-color-preset' }}{% endif %}" data-preview-item="call-to-action">
  <div class="container">

    <div class="section__content">

      {% if section.settings.heading != blank %}
        <h3 class="section__heading">{{ section.settings.heading }}</h3>
        {% if section.settings.subheading != blank %}
          <h4 class="section__subheading">{{ section.settings.subheading }}</h4>
        {% endif %}
      {% endif %}

      {% if section.settings.body != blank %}
        <p class="section__body">{{ section.settings.body }}</p>
      {% endif %}

      {% if section.settings.price != blank || section.blocks != nil %}
        <div class="section__button-group">
        {% if section.settings.price != blank %}
          <a class="button button-primary" href="{{ section.settings.price.links.add_to_cart }}">{{ block.settings.button_text }}</a>
        {% else %}
          {% for block in section.blocks %}
            <a class="button button-primary" href="{{ block.settings.button_url }}">{{ block.settings.button_text }}</a>
          {% endfor %}
        {% endif %}
        </div>
      {% endif %}

    </div>

  </div>
</section>

{% style %}
...
{% endstyle %}

{% schema %}
...
{% schema %}

Style

Alignment, Layout & Style modifiers will be encapsulated with {% style %} & {% endstyle %} tags.

section.call-to-action {

  .section__heading,
  .section__subheading {
    text-align: {{ section.settings.heading_alignment }};
  }

  {% if section.settings.background_image != blank %}
    $background-image: '{{ section.settings.background_image }}';
  {% else %}
    $background-image: null;
  {% endif %}

  $background-overlay-color: {{ section.settings.overlay_color }};
  $background-overlay-opacity: {{ section.settings.overlay_opacity }} * 0.01;

  @if $background-overlay-opacity {
    $color: rgba($background-overlay-color, $background-overlay-opacity);
    $overlay: linear-gradient(
      $color,
      $color
    );
  } @else {
    $overlay: null;
  }
  $img: if($background-image, url('#{$background-image}'), null);

  @if $img {
    $background: ($overlay, $img);
  } @else {
    $background: (rgba($background-overlay-color, $background-overlay-opacity));
  }

  &.full-width-background {
    @include background-image($background...);
  }
}

Schema

Schema will be encapsulated with {% schema %} & {% endschema %} tags.

{
  "label": "Call To Action",
  "settings": [
    {
      "label": "Heading",
      "settings": [
        {
          "type": "text",
          "id": "heading",
          "label": "Heading",
          "default": "Ready to elevate your career?"
        },
        {
          "type": "text",
          "id": "subheading",
          "label": "Subheading",
          "default": "Get started now!"
        },
        {
          "type": "radio",
          "id": "heading_alignment",
          "label": "Alignment",
          "description": "Headings will inherit the same alignment",
          "default": "left",
          "options": [
            {
              "value": "left",
              "label": "Left"
            },
            {
              "value": "center",
              "label": "Center"
            },
            {
              "value": "right",
              "label": "Right"
            }
          ]
        }
      ]
    },
    {
      "label": "Text",
      "settings": [
        {
          "type": "richtext",
          "id": "body",
          "label": "",
          "default": ""
        }
      ]
    },
    {
      "label": "Background",
      "settings": [
        {
          "type": "select",
          "id": "background_color_preset",
          "label": "Color Preset",
          "description": "Presets can be configured in the Colors configuration menu",
          "default": "primary",
          "options": [
            { "value": "none", "label": "None" },
            { "value": "primary", "label": "Primary" },
            { "value": "secondary", "label": "Secondary" },
            { "value": "tertiary", "label": "Tertiary" }
          ]
        },
        {
          "type": "image",
          "id": "background_image",
          "default": "",
          "label": "Image"
        },
        {
          "type": "color",
          "id": "overlay_color",
          "label": "Overlay Color",
          "default": "#D9DEE2"
        },
        {
          "type": "number",
          "id": "overlay_opacity",
          "label": "Overlay Opacity",
          "default": 0,
          "min": 0,
          "max": 100
        }
      ]
    }
  ],
  "blocks": {
    "label": "Add Button",
    "limit": 2,
    "types": [
      {
        "type": "button",
        "label": "Button",
        "settings": [
          {
            "type": "text",
            "id": "button_text",
            "label": "Text"
          },
          {
            "type": "price_picker",
            "id": "price",
            "label": "Attach a course"
          },
          {
            "type": "page_picker",
            "id": "button_url",
            "label": "Custom URL"
          }
        ]
      }
    ],
    "defaults": [
      {
        "type": "button",
        "values": {
          "button_text": "View Courses",
          "button_url": "/collections/courses"
        }
      }
    ]
  }
}
Clone this wiki locally