new donate form :) new colors and new amount chooser

This commit is contained in:
Matt Dunn-Rankin 2017-01-05 15:47:12 -08:00
parent f5fb8711fc
commit 6b81da82b1
4 changed files with 167 additions and 44 deletions

View file

@ -22,26 +22,45 @@
if (!field('stripe_token').value) { if (!field('stripe_token').value) {
e.preventDefault(); e.preventDefault();
var amount = Math.floor(parseFloat(field('amount').value) * 100); var amountChoice =
donationForm.querySelector('input[name=amount]:checked');
if (amountChoice.value === "custom") {
amountChoice = document.getElementById('amount-custom-value');
}
// Start parsing at the first digit in the string, to trim leading dollar
// signs and what have you.
var amountNumberString = (amountChoice.value.match(/[0-9].+/) || [""])[0];
var amount = Math.floor(parseFloat(amountNumberString) * 100);
if (!isNaN(amount)) { if (!isNaN(amount)) {
field('amount').value = amountNumberString;
checkout.open({ checkout.open({
name: 'Dress to Impress', name: 'Dress to Impress',
description: 'Donation (thank you!)', description: 'Donation (thank you!)',
amount: amount amount: amount,
panelLabel: "Donate"
}); });
} }
} }
}); });
var toggle = document.getElementById('success-thanks-toggle-description'); var toggle = document.getElementById('success-thanks-toggle-description');
toggle.addEventListener('click', function() { if (toggle) {
var desc = document.getElementById('description'); toggle.addEventListener('click', function() {
var attr = 'data-show'; var desc = document.getElementById('description');
if (desc.hasAttribute(attr)) { var attr = 'data-show';
desc.removeAttribute(attr); if (desc.hasAttribute(attr)) {
} else { desc.removeAttribute(attr);
desc.setAttribute(attr, true); } else {
desc.setAttribute(attr, true);
}
});
}
document.getElementById('amount-custom').addEventListener('change', function(e) {
if (e.target.checked) {
document.getElementById('amount-custom-value').focus();
} }
}); });
})(); })();

View file

@ -15,7 +15,10 @@ body.campaigns-show, body.campaigns-current
color: $campaign-text-color color: $campaign-text-color
a a
color: $campaign-text-color + #222 color: $campaign-text-color + #222 !important
#home-link:hover
background-color: $campaign-background-color
#userbar, #footer #userbar, #footer
color: $text-color color: $text-color
@ -32,52 +35,120 @@ body.campaigns-show, body.campaigns-current
+module +module
background: $campaign-background-color background: $campaign-background-color
border-color: $campaign-border-color border-color: $campaign-border-color
display: flex
flex-direction: row
margin-top: 1em margin-top: 1em
margin-bottom: 1.5em margin-bottom: 1.5em
padding-bottom: 32px padding-bottom: 32px
padding-left: 24px padding-left: 24px
padding-right: 24px
padding-top: 32px padding-top: 32px
position: relative
&[data-campaign-theme="hug"] // We only use bird theme now. Whatever.
background: &::after
image: url(image_path("campaigns/hug.gif"))
position: ($container-width - 150px - 8px) -4px
repeat: no-repeat
&[data-campaign-theme="bird"]
background: background:
image: url(image_path("campaigns/bird.gif")) image: url(image_path("campaigns/bird.gif"))
position: ($container-width - 150px - 8px) -4px
repeat: no-repeat repeat: no-repeat
bottom: 0
content: " "
height: 125px
position: absolute
right: 0
width: 150px
header, div header, #donation-fields
+inline-block flex: 1
p
font-family: $main-font
margin: 0
div
font-size: 115%
margin-left: 20px
#donation-form-title #donation-form-title
font-size: 125% font-size: 125%
font-weight: bold font-weight: bold
margin-bottom: .25em margin-bottom: .25em
margin-top: 0
p p
font-family: $main-font
font-size: 85% font-size: 85%
margin-bottom: 0 margin-bottom: 0
margin-top: .5em margin-top: .5em
#donation-fields
margin-left: 20px
padding-top: 7px
#amount-header
font-size: 85%
font-weight: bold
#amount-choices
$amount-choices-border-color: desaturate(lighten($campaign-border-color, 30%), 30%)
display: flex
flex-direction: row
margin-bottom: 1em
li
border: 1px solid $amount-choices-border-color
border-radius: 5px
display: block
flex: 1
list-style: none
overflow: hidden
text-align: center
&:not(:last-of-type)
margin-right: .75em
input[type=radio]
height: 0
margin: 0
padding: 0
opacity: 0
position: absolute
width: 0
label
border: 1px solid transparent
box-sizing: border-box
display: block
padding: .5em .5em
width: 100%
input[type=radio]:checked ~ label
background: $amount-choices-border-color
font-weight: bold
input[type=radio]:focus ~ label
border-color: white
border-radius: 5px
#amount-custom-fields
display: none
input[type=text]
font-family: inherit
font-size: inherit
line-height: 1
padding: 0
text-align: center
#amount-custom:checked ~ #amount-custom-fields
display: block
#amount-custom:checked ~ label[for=amount-custom]
display: none
input[type=text] input[type=text]
border-color: #cce border-color: #cce
color: $campaign-text-color color: $campaign-text-color
width: 3em width: 3em
button #donation-controls
+loud-awesome-button-color text-align: center
button
+awesome-button-color(#004)
font-size: 120%
#campaign-text[data-campaign-complete] #campaign-text[data-campaign-complete]
#description #description

View file

@ -1,6 +1,12 @@
$campaign-border-color: #006 // 2015 campaign blue
$campaign-background-color: #eef // $campaign-border-color: #006
$campaign-text-color: #004 // $campaign-background-color: #eef
// $campaign-text-color: #004
// $campaign-link-color: $campaign-text-color + #222
$campaign-border-color: hsl(33, 100%, 40%)
$campaign-background-color: hsl(33, 100%, 97%)
$campaign-text-color: hsl(33, 100%, 20%)
$campaign-link-color: $campaign-text-color + #222 $campaign-link-color: $campaign-text-color + #222
=campaign-progress =campaign-progress
@ -17,7 +23,7 @@ $campaign-link-color: $campaign-text-color + #222
.button .button
+awesome-button +awesome-button
+loud-awesome-button-color +awesome-button-color(#004)
font-size: 75% font-size: 75%
margin-left: 1em margin-left: 1em
padding: .25em .75em padding: .25em .75em
@ -31,7 +37,7 @@ $campaign-link-color: $campaign-text-color + #222
height: 2.5em height: 2.5em
.campaign-progress-label .campaign-progress-label
+text-shadow(#777, -1px, -1px, 0) text-shadow: 1px 1px 0 #888
color: white color: white
font-size: 150% font-size: 150%
left: 0 left: 0

View file

@ -13,18 +13,45 @@
= hidden_field_tag 'donation[stripe_token]' = hidden_field_tag 'donation[stripe_token]'
= hidden_field_tag 'donation[stripe_token_type]' = hidden_field_tag 'donation[stripe_token_type]'
= hidden_field_tag 'donation[donor_email]' = hidden_field_tag 'donation[donor_email]'
= hidden_field_tag 'donation[amount]'
%header %header
-# I'm hardcoding the messaging this year, because I'm abandoning the UI
-# of giant paragraphs, and I don't feel like figuring out how this new
-# design generalizes just yet :P Whatever.
%p#donation-form-title %p#donation-form-title
Thanks for supporting Dress to Impress! Thanks for supporting Dress to Impress!
%p#donation-form-subtitle %p
Securely powered by #{link_to 'Stripe', 'https://stripe.com/'}. From modeling to servers, Dress to Impress is a community effort.
We never, ever see your payment info. This year, we need to raise $720 to cover our 2016 hosting costs.
%br %p
All donations go directly to our hosting costs. Thanks for your help! As a thank-you gift, for every $5 you give, we'll feature one of your
%div outfits here and on the homepage. Last year's outfits were pretty great—will this year's be even better? :o
= precede '$' do %p
= text_field_tag 'donation[amount]', '10.00' All donations are securely powered by
%button{:type => 'submit'} Donate now! #{link_to 'Stripe', 'https://stripe.com/'}, and go directly toward our
hosting costs. Thank you for your help!
#donation-fields
#amount-header Amount
#amount-choices
%li
%input#amount-5{type: 'radio', name: 'amount', value: '5.00'}
%label{for: 'amount-5'} $5
%li
%input#amount-10{type: 'radio', name: 'amount', value: '10.00'}
%label{for: 'amount-10'} $10
%li
%input#amount-30{type: 'radio', name: 'amount', value: '20.00', checked: true}
%label{for: 'amount-30'} $20
%li
%input#amount-50{type: 'radio', name: 'amount', value: '50.00'}
%label{for: 'amount-50'} $50
%li
%input#amount-custom{type: 'radio', name: 'amount', value: 'custom'}
%label{for: 'amount-custom'} Other
%label#amount-custom-fields{for: 'amount-custom-value'}
%input#amount-custom-value{type: 'text'}
#donation-controls
%button{type: 'submit'} Donate now!
#campaign-text{'data-campaign-complete' => @campaign.complete?} #campaign-text{'data-campaign-complete' => @campaign.complete?}
- if @campaign.complete? && @campaign.thanks? - if @campaign.complete? && @campaign.thanks?