Checkout style
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 11 May 2023 14:49:27 +0000 (16:49 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 11 May 2023 14:49:27 +0000 (16:49 +0200)
src/club/models.py
src/club/templates/club/2022/donation_step1_form.html
src/wolnelektury/static/2022/styles/layout/_checkout.scss

index 8338b55..98b4ee0 100644 (file)
@@ -44,21 +44,27 @@ class Club(models.Model):
         for tag, amounts in ('single', single), ('monthly', monthly):
             wide_spot = narrow_spot = 0
             for i, p in enumerate(amounts):
         for tag, amounts in ('single', single), ('monthly', monthly):
             wide_spot = narrow_spot = 0
             for i, p in enumerate(amounts):
-                if p.description or p.wide:
-                    if not p.description:
-                        p.narrow_wide = True
-                    if narrow_spot == 1:
-                        amounts[i-1].narrow_wide = True
-                        narrow_spot = 0
                 if p.wide:
                 if p.wide:
-                    if wide_spot == 2:
-                        p.wide_not_wide = True
-                        wide_spot += 1
-                    else:
+                    # Do we have space for xl?
+                    if wide_spot < 2:
+                        p.box_variant = 'xl'
                         wide_spot += 2
                         wide_spot += 2
+                    else:
+                        p.box_variant = 'card'
+                        wide_spot += 1
+                    narrow_spot = 0
+                elif p.description:
+                    p.box_variant = 'card'
+                    if narrow_spot:
+                        amounts[i-1].box_variant = 'bar'
+                    wide_spot += 1
+                    narrow_spot = 0
                 else:
                 else:
+                    p.box_variant = 'half'
                     wide_spot += 1
                     wide_spot += 1
+                    narrow_spot += 1
                 wide_spot %= 3
                 wide_spot %= 3
+                narrow_spot %= 2
             c[tag] = amounts
             c[f'{tag}_wide_spot'] = wide_spot
         return c
             c[tag] = amounts
             c[f'{tag}_wide_spot'] = wide_spot
         return c
index 2f98869..cfdd5d3 100644 (file)
   {% with amounts=club.get_amounts %}
   <div class="l-checkout__payments payments-once">
     {% for amount in amounts.single %}
   {% with amounts=club.get_amounts %}
   <div class="l-checkout__payments payments-once">
     {% for amount in amounts.single %}
-      <div class="l-checkout__payments__box once{% if not schedule.monthly and schedule.amount == amount.amount or not schedule and club.default_single_amount == amount.amount %} is-active{% endif %}{% if amount.narrow_wide %} narrow-wide{% endif %}{% if amount.wide %} l-checkout__payments__box--special{% if not amount.wide_not_wide %} l-checkout__payments__box--xl{% endif %}{% endif %}">
-        <div>
-          <h3>{{ amount.amount }} zł</h3>
-          <div class="l-checkout__payments__box__btn-wrp">
-            <button name="single_amount" value="{{ amount.amount }}">Wybierz</button>
-          </div>
-        </div>
-        {% if amount.description %}
-          <div>
+      <div class="l-checkout__payments__box once{% if not schedule.monthly and schedule.amount == amount.amount or not schedule and club.default_single_amount == amount.amount %} is-active{% endif %}{% if amount.wide %} l-checkout__payments__box--special{% endif %} l-checkout__payments__box--{{ amount.box_variant }}">
+
+        <h3>{{ amount.amount }} zł</h3>
+        <div class="l-checkout__payments__box__btn-wrp">
+          {% if amount.description %}
             <p>{{ amount.description|safe }}</p>
             <p>{{ amount.description|safe }}</p>
-          </div>
-        {% endif %}
+          {% endif %}
+          <button name="single_amount" value="{{ amount.amount }}">Wybierz</button>
+        </div>
       </div>
     {% endfor %}
     <input type="hidden"
       </div>
     {% endfor %}
     <input type="hidden"
 
   <div class="l-checkout__payments payments-recurring">
     {% for amount in amounts.monthly %}
 
   <div class="l-checkout__payments payments-recurring">
     {% for amount in amounts.monthly %}
-      <div class="l-checkout__payments__box{% if schedule.monthly and schedule.amount == amount.amount or not schedule and amount.amount == club.default_monthly_amount %} is-active{% endif %}{% if amount.narrow_wide %} narrow-wide{% endif %}{% if amount.wide and not amount.wide_not_wide %} l-checkout__payments__box--xl{% endif %}">
+      <div class="l-checkout__payments__box{% if schedule.monthly and schedule.amount == amount.amount or not schedule and amount.amount == club.default_monthly_amount %} is-active{% endif %}{% if amount.wide %} l-checkout__payments__box--special{% endif %} l-checkout__payments__box--{{ amount.box_variant }}">
         <h3>{{ amount.amount }} zł <span>/mies.</span></h3>
         <div class="l-checkout__payments__box__btn-wrp">
         <h3>{{ amount.amount }} zł <span>/mies.</span></h3>
         <div class="l-checkout__payments__box__btn-wrp">
-          <p>{{ amount.description|safe }}</p>
+          {% if amount.description %}
+            <p>{{ amount.description|safe }}</p>
+          {% endif %}
           <button name="monthly_amount" value="{{ amount.amount }}">Wybierz</button>
         </div>
       </div>
           <button name="monthly_amount" value="{{ amount.amount }}">Wybierz</button>
         </div>
       </div>
index b4423dd..779324a 100644 (file)
   transition: box-shadow $ease-out 250ms;
   box-shadow: 0px 0px 0px rgba(55, 170, 156, 0);
   margin-bottom: 30px;
   transition: box-shadow $ease-out 250ms;
   box-shadow: 0px 0px 0px rgba(55, 170, 156, 0);
   margin-bottom: 30px;
-  width: calc(50% - 8px);
+  width: 100%;
 
 
-  &.narrow-wide {
-      flex-direction: row;
-      width: 100%;
-  }
-  
   @include rwd($break-flow) {
       width: calc(33.333% - 20px);
   }
   @include rwd($break-flow) {
       width: calc(33.333% - 20px);
   }
 
   &.is-active {
       box-shadow: 0px 0px 20px rgba(55, 170, 156, 0.35);
 
   &.is-active {
       box-shadow: 0px 0px 20px rgba(55, 170, 156, 0.35);
-      background: #083F4D;
-      color: white;
+      background: white;
+      color: black;
 
 
-      @include rwd($break-flow) {
-          background: white;
-          color: black;
-      }
     h3 {
       color: white;
       background: #083F4D;
     h3 {
       color: white;
       background: #083F4D;
     }
   }
 
     }
   }
 
+  &.l-checkout__payments__box--half {
+      width: calc(50% - 8px);
+      @include rwd($break-flow) {
+          width: calc(33.333% - 20px);
+      }
+
+      &.is-active {
+          background: #083F4D;
+          color: white;
+
+          @include rwd($break-flow) {
+              background: white;
+              color: black;
+          }
+      }
+  }
+  &.l-checkout__payments__box--bar {
+      flex-direction: row;
+      
+      @include rwd($break-flow) {
+          flex-direction: column;
+      }
+
+      &.is-active {
+          background: #083F4D;
+          color: white;
+
+          @include rwd($break-flow) {
+              background: white;
+              color: black;
+          }
+      }
+
+      h3, .l-checkout__payments__box__btn-wrp {
+          flex-grow: 1;
+      }
+  }
+  &.l-checkout__payments__box--card {
+  }
+  
   &.l-checkout__payments__box--xl {
       width: 100%;
   &.l-checkout__payments__box--xl {
       width: 100%;
+      justify-content: center;
+      min-height: 160px;
+
       @include rwd($break-flow) {
           width: calc(67.4% - 20px);
       @include rwd($break-flow) {
           width: calc(67.4% - 20px);
-          width: calc(67.4% - 20px);
-          flex-direction: row;
-          & > div {
-              display: flex;
-              &:first-child {
-                  width: 50%;
+          padding-left: calc(33.7% - 10px);
+          position: relative;
+
+          h3 {
+              position: absolute;
+              left: 0;
+              top: 0;
+              padding-right: 50%;
+          }
+          
+          .l-checkout__payments__box__btn-wrp {
+              margin: 0;
+
+              p {
                   flex-wrap: wrap;
                   max-width: 340px;
                   margin-right: 20px;
               }
 
                   flex-wrap: wrap;
                   max-width: 340px;
                   margin-right: 20px;
               }
 
-              &:last-child {
-                  width: 49%;
+              button {
+                  position: absolute;
+                  bottom: 20px;
+                  left: 20px;
+                  width: calc(50% - 50px);
                   align-items: center;
                   justify-content: center;
               }
                   align-items: center;
                   justify-content: center;
               }
         }
     }
 }
         }
     }
 }
-
-
-.payments-recurring {
-    .l-checkout__payments__box {
-        width: 100%;
-        &.is-active {
-            background: white;
-            color: black;
-        }
-        @include rwd($break-flow) {
-            width: calc(33.333% - 20px);
-            //margin-right: 30px;
-        }
-    }
-}