From 7de36dbb6e1bf48fd93b95db9ee243fe826b958f Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Thu, 26 Mar 2020 14:43:59 -0400
Subject: [PATCH] ISTWCMS-3661: updating styling and templating for facebook

---
 .../04-components/facebook/facebook.js        | 23 ----------------
 .../04-components/facebook/facebook.twig      | 26 ++++++++++++++-----
 .../04-components/facebook/facebook.yml       |  5 ++++
 3 files changed, 25 insertions(+), 29 deletions(-)
 delete mode 100644 source/_patterns/04-components/facebook/facebook.js

diff --git a/source/_patterns/04-components/facebook/facebook.js b/source/_patterns/04-components/facebook/facebook.js
deleted file mode 100644
index 4f717afe..00000000
--- a/source/_patterns/04-components/facebook/facebook.js
+++ /dev/null
@@ -1,23 +0,0 @@
-(function ($, Drupal) {
-  'use strict';
-
-  // The styling for this mobile menu is located in source/_patterns/04-components/menus/menu--main/.
-
-  Drupal.behaviors.facebook = {
-    attach(context, settings) {
-      $('.uw-facebook__data').each(function () {
-
-        var fbwidth = $(this).parent().width();
-
-        if (fbwidth == 0) {
-          fbwidth = 239;
-        }
-
-        var fburl = encodeURIComponent('/' + $(this).data('username'));
-
-        $(this).before('<iframe src="https://www.facebook.com/plugins/likebox.php?href=' + fburl + '&amp;width=' + fbwidth + '&amp;height=350&amp;colorscheme=light&amp;show_faces=false&amp;border_color&amp;stream=true&amp;header=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; max-width: 500px;width:' + fbwidth + 'px; height:350px;" allowTransparency="true"></iframe>');
-        $(this).remove();
-      });
-    },
-  };
-})(jQuery, Drupal);
diff --git a/source/_patterns/04-components/facebook/facebook.twig b/source/_patterns/04-components/facebook/facebook.twig
index 74c2957c..20adc650 100644
--- a/source/_patterns/04-components/facebook/facebook.twig
+++ b/source/_patterns/04-components/facebook/facebook.twig
@@ -1,6 +1,20 @@
-<div class="uw-facebook">
-  <div class="uw-facebook__wrapper">
-    <div class="uw-facebook__data" data-username="{{ username }}">
-    </div>
-  </div>
-</div>
+<div class="uw-facebook">
+  <div class="uw-facebook__wrapper">
+    <script async defer src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script>
+    {% if feed_type == 'timeline' %}
+      <div class="fb-page"
+           data-href="https://www.facebook.com/{{ username }}"
+           data-tabs="timeline"
+           data-width="500"
+           data-hide-cover="false"
+           data-show-facepile="false"
+           adapt_container_width="true">
+      </div>
+    {% else %}
+      <div class="fb-post"
+         data-href="{{ url }}"
+         data-width="500">
+      </div>
+    {% endif %}
+  </div>
+</div>
diff --git a/source/_patterns/04-components/facebook/facebook.yml b/source/_patterns/04-components/facebook/facebook.yml
index e69de29b..91a1f104 100644
--- a/source/_patterns/04-components/facebook/facebook.yml
+++ b/source/_patterns/04-components/facebook/facebook.yml
@@ -0,0 +1,5 @@
+feed_type: 'singlepost'
+url: 'https://www.facebook.com/university.waterloo/photos/a.413434815757/10158092685535758/?type=3&__xts__%5B0%5D=68.ARBMF_TWIqmabPEvgm2lDS_9tdueCSGzKC0hHLKDklHAINNO6G3UjO8uhvXt-UW3biG9j5pQwbI0CW7LbTCj2gixcH7f_uKe3-AlkAarFGkYYFfMfHNHUFs4UX_oCgir9oyKSBvyA7E8M3r1sf-wW8XyMVZ0ch9EYbfuChTQgXP0GfvcAs-jYZgmZu-2ohe5CpzrHCwHLxGun-_sa4uBm0SZ7aoPqmAqI8PmhEReeeDWD6Qm46wOFj0Bah0UFIxwQeKjhQ_rk_i4ijgfV3FiarIHb-Ns8jdkYdJ0eTUuF1Qr36iBUPkd6PIOVX03d_YCbNbkycOKY41Qkho&__tn__=-R'
+include_text_video: 'true'
+username: 'university.waterloo'
+display_name: 'UW'
-- 
GitLab