FEATURE: Add fireworks + gradient animation to campaign success banner (#77)

FEATURE: Add fireworks + gradient animation to campaign success banner (#77)

diff --git a/assets/javascripts/discourse/components/campaign-banner.js.es6 b/assets/javascripts/discourse/components/campaign-banner.js.es6
index 536f83e..61c0ab1 100644
--- a/assets/javascripts/discourse/components/campaign-banner.js.es6
+++ b/assets/javascripts/discourse/components/campaign-banner.js.es6
@@ -4,6 +4,7 @@ import { equal } from "@ember/object/computed";
 import { setting } from "discourse/lib/computed";
 import Component from "@ember/component";
 import discourseComputed, { observes } from "discourse-common/utils/decorators";
+import { later } from "@ember/runloop";
 import { inject as service } from "@ember/service";
 
 export default Component.extend({
@@ -31,6 +32,7 @@ export default Component.extend({
   showContributors: setting(
     "discourse_subscriptions_campaign_show_contributors"
   ),
+  classNameBindings: ["isGoalMet:goal-met"],
 
   init() {
     this._super(...arguments);
@@ -69,6 +71,25 @@ export default Component.extend({
     } else {
       document.body.classList.remove("subscription-campaign-sidebar");
     }
+
+    // makes sure to only play animation once, & not repeat on reload
+    if (this.isGoalMet) {
+      const successAnimationKey = this.keyValueStore.get(
+        "campaign_success_animation"
+      );
+
+      if (!successAnimationKey) {
+        later(() => {
+          this.keyValueStore.set({
+            key: "campaign_success_animation",
+            value: Date.now(),
+          });
+          document.body.classList.add("success-animation-off");
+        }, 7000);
+      } else {
+        document.body.classList.add("success-animation-off");
+      }
+    }
   },
 
   @discourseComputed(
@@ -130,7 +151,6 @@ export default Component.extend({
     const currentVolume = this.subscriberGoal
       ? this.subscribers
       : this.amountRaised;
-
     return currentVolume >= this.goalTarget;
   },
 
diff --git a/assets/javascripts/discourse/templates/components/campaign-banner.hbs b/assets/javascripts/discourse/templates/components/campaign-banner.hbs
index 99de413..d2b3ce4 100644
--- a/assets/javascripts/discourse/templates/components/campaign-banner.hbs
+++ b/assets/javascripts/discourse/templates/components/campaign-banner.hbs
@@ -12,21 +12,31 @@
         var(--campaign-background-image);
       background-size: cover;
       background-repeat: no-repeat;' ''}}">
-      <h2 class="campaign-banner-info-header">{{i18n 'discourse_subscriptions.campaign.title'}}</h2>
+      {{#if isGoalMet}}
+         <h2 class="campaign-banner-info-header">{{i18n 'discourse_subscriptions.campaign.success_title'}}</h2>
+        <p class="campaign-banner-info-description">{{i18n 'discourse_subscriptions.campaign.success_body'}}</p>
+      {{else}}
+        <h2 class="campaign-banner-info-header">{{i18n 'discourse_subscriptions.campaign.title'}}</h2>
         <p class="campaign-banner-info-description">{{i18n 'discourse_subscriptions.campaign.body'}}</p>
-        {{#if product}}
-          {{#link-to "s.show" product disabled=product.subscribed class="btn btn-primary campaign-banner-info-button"}}
-            {{d-icon "far-heart"}} {{d-icon "heart" class="hover-heart"}} {{i18n 'discourse_subscriptions.campaign.button'}}
-          {{/link-to}}
-        {{else}}
-          {{#link-to "s" class="btn btn-primary campaign-banner-info-button"}}
-            {{d-icon "far-heart"}} {{d-icon "heart" class="hover-heart"}} {{i18n 'discourse_subscriptions.campaign.button'}}
-          {{/link-to}}
-        {{/if}}
+      {{/if}}
+      {{#if product}}
+        {{#link-to "s.show" product disabled=product.subscribed class="btn btn-primary campaign-banner-info-button"}}
+          {{d-icon "far-heart"}} {{d-icon "heart" class="hover-heart"}} {{i18n 'discourse_subscriptions.campaign.button'}}
+        {{/link-to}}
+      {{else}}
+        {{#link-to "s" class="btn btn-primary campaign-banner-info-button"}}
+          {{d-icon "far-heart"}} {{d-icon "heart" class="hover-heart"}} {{i18n 'discourse_subscriptions.campaign.button'}}
+        {{/link-to}}
+      {{/if}}
+      
     </div>
     <div class="campaign-banner-progress">
       {{#if isGoalMet}}
-        <p class="campaign-banner-progress-success">{{i18n 'discourse_subscriptions.campaign.goal'}}!</p>
+        <div class="fireworks">
+          <div class="before"></div>
+          <div class="after"></div>
+        </div>
+        <div class="campaign-banner-progress-success"></div>
         {{#if subscriberGoal}}
           <p class="campaign-banner-progress-description">
             {{i18n 'discourse_subscriptions.campaign.goal_comparison' current=subscribers goal=goalTarget}}
diff --git a/assets/stylesheets/common/campaign.scss b/assets/stylesheets/common/campaign.scss
index 59877ae..287b334 100644
--- a/assets/stylesheets/common/campaign.scss
+++ b/assets/stylesheets/common/campaign.scss
@@ -97,6 +97,10 @@ body.archetype-regular {
   border: 1px solid var(--primary-low);
   position: relative;
   align-items: stretch;
+  @media screen and (max-width: 400px) {
+    width: 98%;
+    flex-direction: column;
+  }
   .btn.close {
     position: absolute;
     top: 1em;
@@ -122,11 +126,11 @@ body.archetype-regular {
       align-items: center;
     }
     @media screen and (max-width: 400px) {
-      width: 100%;
-      display: grid;
-      grid-template-columns: 60% auto;
-      grid-template-areas: "left right" "left right";
+      width: calc(100% - 4em);
+      display: flex;
+      flex-direction: column;
       align-items: center;
+      padding-bottom: 1em;
     }
     &-header {
       font-size: $font-up-6;
@@ -145,6 +149,9 @@ body.archetype-regular {
       @media screen and (max-width: 750px) {
         font-size: $font-down-1;
       }
+      @media screen and (max-width: 400px) {
+        text-align: center;
+      }
     }
     &-button {
       grid-area: right;
@@ -170,16 +177,21 @@ body.archetype-regular {
     width: 60%;
     padding: 1.5em 2em 1.5em;
     @media screen and (max-width: 400px) {
-      display: none;
+      width: calc(100% - 4em);
     }
     &-success {
-      font-size: $font-up-1;
-      text-align: center;
-      background-color: var(--tertiary);
-      color: var(--secondary);
-      padding: 0.25em;
+      height: 32px;
+      background: linear-gradient(
+        -45deg,
+        var(--tertiary-hover),
+        var(--tertiary-medium),
+        var(--tertiary-hover),
+        var(--tertiary-medium)
+      );
       border-radius: 2em;
       margin: 0;
+      background-size: 400% 100%;
+      animation: gradient 15s ease infinite;
     }
     &-description {
       margin: 0.5em 0 0;
@@ -236,7 +248,7 @@ body.archetype-regular {
 html:not(.mobile-view) .subscriptions-campaign-topic-footer .campaign-banner {
   margin-top: 2em;
   height: min-content;
-  width: calc(100% + 5em);
+  width: calc(100% + 14em);
   .btn.close {
     top: 1em;
     right: 1em;
@@ -264,3 +276,234 @@ html:not(.mobile-view) .subscriptions-campaign-topic-footer .campaign-banner {
     }
   }
 }
+
+// CSS Animations for campaign Success
+@keyframes gradient {
+  0% {
+    background-position: 0% 50%;
+  }
+  50% {
+    background-position: 100% 50%;
+  }
+  100% {
+    background-position: 0% 50%;
+  }
+}
+
+/* Fireworks
+  Copyright (c) 2020 by Eddie Lin (https://codepen.io/yshlin/pen/ylDEk)
+  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

[... diff too long, it was truncated ...]

GitHub sha: beb73b58f3be2c7fb651bc8f613d2a8c0311912e

This commit appears in #77 which was approved by justindirose. It was merged by justindirose.