-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple payments styling #7500
Merged
Merged
Simple payments styling #7500
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e6509da
simple-payments: implement styles to the block
artpi 7e8d9ab
some change
artpi 10d8026
simple-payments: small coding improvements in output_shortcode()
retrofox 4f4be62
simple-payments: do not use underscore in css class
retrofox c2e0186
simple-payments: minor improvements defining endpoints
retrofox 4c2dae9
simple-payments: use `<p>` tag for description and price
retrofox 43d30be
simple-payments: minor improvements
retrofox 912a9cb
simple-payments: add purchase-box container. improve paypal button st…
retrofox 1102a9b
simple-pyaments: wrap all text into `<p>` elems
retrofox da337bb
simple-payments: move globals as PaypalExpressCheckout properties
retrofox 40c4a34
simple-payments: coding improvementes.
retrofox 67a6324
simple-payments: minor code improvements
retrofox 276a855
rebase: squash -> "simple-payments: move globals as PaypalExpressChec…
retrofox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,57 @@ | ||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message { | ||
|
||
.jetpack-simple-payments-wrapper { | ||
margin: 0.5em 0; | ||
} | ||
|
||
.jetpack-simple-payments-title { | ||
font-weight: bold; | ||
display: block; | ||
margin-bottom: 0.3em; | ||
} | ||
|
||
.jetpack-simple-payments-payment-row { | ||
margin-top: 0.3em; | ||
} | ||
|
||
.jetpack-simple-payments-price { | ||
font-weight: bold; | ||
display: inline-block; | ||
float: left; | ||
margin-right: 15px; | ||
} | ||
|
||
.jetpack-simple-payments-items { | ||
display:inline-block; | ||
margin-right: 15px; | ||
} | ||
|
||
.jetpack-simple-payments-items input { | ||
width: 30px; | ||
} | ||
|
||
.jetpack-simple-payments-button { | ||
display: inline-block; | ||
float: left; | ||
} | ||
|
||
.jetpack-simple-payments-purchase-message { | ||
display: none; | ||
padding: 1em; | ||
} | ||
|
||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message, | ||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message a { | ||
/* stronger rule in order to set the text color */ | ||
body .jetpack-simple-payments-wrapper p.jetpack-simple-payments-purchase-message { | ||
color: #fff; | ||
padding: 1em; | ||
} | ||
|
||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message.show { | ||
.jetpack-simple-payments-purchase-message.show { | ||
display: block; | ||
} | ||
|
||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message.success { | ||
.jetpack-simple-payments-purchase-message.success { | ||
background-color: #4ab866; | ||
} | ||
|
||
body .jetpack-simple-payments__wrapper div.jetpack-simple-payments__purchase-message.error { | ||
.jetpack-simple-payments-purchase-message.error { | ||
background-color: #d94f4f; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ class Jetpack_Simple_Payments { | |
|
||
static $shortcode = 'simple-payment'; | ||
|
||
static $css_classname_prefix = 'jetpack-simple-payments'; | ||
|
||
// Classic singleton pattern: | ||
private static $instance; | ||
private function __construct() {} | ||
|
@@ -61,13 +63,13 @@ function parse_shortcode( $attrs, $content = false ) { | |
|
||
// We allow for overriding the presentation labels | ||
$data = shortcode_atts( array( | ||
'blog_id' => Jetpack_Options::get_option( 'id' ), | ||
'dom_id' => uniqid( 'jetpack-simple-payments-' . $product->ID . '_', true ), | ||
'class' => 'jetpack-simple-payments-' . $product->ID, | ||
'title' => get_the_title( $product ), | ||
'blog_id' => Jetpack_Options::get_option( 'id' ), | ||
'dom_id' => uniqid( self::$css_classname_prefix . '-' . $product->ID . '_', true ), | ||
'class' => self::$css_classname_prefix . '-' . $product->ID, | ||
'title' => get_the_title( $product ), | ||
'description' => $product->post_content, | ||
'cta' => get_post_meta( $product->ID, 'spay_cta', true ), | ||
'multiple' => get_post_meta( $product->ID, 'spay_multiple', true ) || '0' | ||
'cta' => get_post_meta( $product->ID, 'spay_cta', true ), | ||
'multiple' => get_post_meta( $product->ID, 'spay_multiple', true ) || '0' | ||
), $attrs ); | ||
$data['price'] = $this->format_price( | ||
get_post_meta( $product->ID, 'spay_price', true ), | ||
|
@@ -86,23 +88,26 @@ function parse_shortcode( $attrs, $content = false ) { | |
|
||
function output_shortcode( $data ) { | ||
$items = ''; | ||
$cssPrefix = self::$css_classname_prefix; | ||
|
||
if ( $data['multiple'] ) { | ||
$items="<div class='jetpack-simple-payments-items'> | ||
<input class='jetpack-simple-payments-items-number' type='number' min='1' value='1' id='{$data['dom_id']}_number'> | ||
</div>"; | ||
$items="<div class='${cssPrefix}-items'> | ||
<input class='${cssPrefix}-items-number' type='number' value='1' id='{$data['dom_id']}_number' /> | ||
</div>"; | ||
} | ||
$output = " | ||
<div class='{$data[ 'class' ]} jetpack-simple-payments__wrapper'> | ||
<p class='jetpack-simple-payments__purchase-message'> | ||
</p> | ||
<div class='jetpack-simple-payments__title'>{$data['title']}</div> | ||
<div class='jetpack-simple-payments__description'>{$data['description']}</div> | ||
<div class='jetpack-simple-payments__price'>{$data['price']}</div> | ||
{$items} | ||
<div class='jetpack-simple-payments__button' id='{$data['dom_id']}_button'></div> | ||
|
||
return " | ||
<div class='{$data['class']} ${cssPrefix}-wrapper'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think adding the class name prefix as a variable is not very helpful. It's harder to read the styling then and I've never seen class naming in a variable. :) We are also not going to change the class name prefix I think -- why would we? |
||
<p class='${cssPrefix}-purchase-message'></p> | ||
<div class='${cssPrefix}-title'><p>{$data['title']}</p></div> | ||
<div class='${cssPrefix}-description'><p>{$data['description']}</p></div> | ||
<div class='${cssPrefix}-purchase-box'> | ||
<div class='${cssPrefix}-price'><p>{$data['price']}</p></div> | ||
{$items} | ||
<div class='${cssPrefix}-button' id='{$data['dom_id']}_button'></div> | ||
</div> | ||
</div> | ||
"; | ||
return $output; | ||
"; | ||
} | ||
|
||
function format_price( $price, $currency, $all_data ) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use flexbox (like we do in Calypso Editor previews) or at least clear the floats in the parent
div
.