This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
223 changed files
with
81,930 additions
and
31,909 deletions.
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
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,9 +1,10 @@ | ||
@import "node_modules/@wordpress/base-styles/variables"; | ||
|
||
$gap-largest: $grid-unit-50; | ||
$gap-larger: 4.5 * $grid-unit; | ||
$gap-large: $grid-unit-30; | ||
$gap: $grid-unit-20; | ||
$gap-small: $grid-unit-15; | ||
$gap-smaller: $grid-unit-10; | ||
$gap-smallest: $grid-unit-05; | ||
// grid-unit from base-styles is 8px. | ||
$gap-largest: 6 * $grid-unit; // 48px | ||
$gap-larger: 4.5 * $grid-unit; // 36px | ||
$gap-large: 3 * $grid-unit; // 24px | ||
$gap: 2 * $grid-unit; // 16px | ||
$gap-small: 1.5 * $grid-unit; // 12px | ||
$gap-smaller: 1 * $grid-unit; // 8px | ||
$gap-smallest: 0.5 * $grid-unit; // 4px |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { createBlock, type BlockInstance } from '@wordpress/blocks'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { OnClickCallbackParameter, InheritedAttributes } from './types'; | ||
|
||
const isConversionPossible = () => { | ||
return true; | ||
}; | ||
|
||
const getButtonLabel = () => | ||
__( 'Transform into blocks', 'woo-gutenberg-products-block' ); | ||
|
||
const getBlockifiedTemplate = ( inheritedAttributes: InheritedAttributes ) => | ||
[ | ||
createBlock( 'woocommerce/cart', { | ||
...inheritedAttributes, | ||
className: 'wc-block-cart', | ||
} ), | ||
].filter( Boolean ) as BlockInstance[]; | ||
|
||
const onClickCallback = ( { | ||
clientId, | ||
attributes, | ||
getBlocks, | ||
replaceBlock, | ||
selectBlock, | ||
}: OnClickCallbackParameter ) => { | ||
replaceBlock( clientId, getBlockifiedTemplate( attributes ) ); | ||
|
||
const blocks = getBlocks(); | ||
|
||
const groupBlock = blocks.find( | ||
( block ) => | ||
block.name === 'core/group' && | ||
block.innerBlocks.some( | ||
( innerBlock ) => | ||
innerBlock.name === 'woocommerce/store-notices' | ||
) | ||
); | ||
|
||
if ( groupBlock ) { | ||
selectBlock( groupBlock.clientId ); | ||
} | ||
}; | ||
|
||
/** | ||
* Title shown within the block itself. | ||
*/ | ||
const getTitle = () => { | ||
return __( 'Cart Shortcode', 'woo-gutenberg-products-block' ); | ||
}; | ||
|
||
/** | ||
* Description shown within the block itself. | ||
*/ | ||
const getDescription = () => { | ||
return __( | ||
'This block will render the classic cart shortcode. You can optionally transform it into blocks for more control over the cart experience.', | ||
'woo-gutenberg-products-block' | ||
); | ||
}; | ||
|
||
const blockifyConfig = { | ||
getButtonLabel, | ||
onClickCallback, | ||
getBlockifiedTemplate, | ||
}; | ||
|
||
export { blockifyConfig, isConversionPossible, getDescription, getTitle }; |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { createBlock, type BlockInstance } from '@wordpress/blocks'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { OnClickCallbackParameter, InheritedAttributes } from './types'; | ||
|
||
const isConversionPossible = () => { | ||
return true; | ||
}; | ||
|
||
const getButtonLabel = () => | ||
__( 'Transform into blocks', 'woo-gutenberg-products-block' ); | ||
|
||
const getBlockifiedTemplate = ( inheritedAttributes: InheritedAttributes ) => | ||
[ | ||
createBlock( 'woocommerce/checkout', { | ||
...inheritedAttributes, | ||
className: 'wc-block-checkout', | ||
} ), | ||
].filter( Boolean ) as BlockInstance[]; | ||
|
||
const onClickCallback = ( { | ||
clientId, | ||
attributes, | ||
getBlocks, | ||
replaceBlock, | ||
selectBlock, | ||
}: OnClickCallbackParameter ) => { | ||
replaceBlock( clientId, getBlockifiedTemplate( attributes ) ); | ||
|
||
const blocks = getBlocks(); | ||
|
||
const groupBlock = blocks.find( | ||
( block ) => | ||
block.name === 'core/group' && | ||
block.innerBlocks.some( | ||
( innerBlock ) => | ||
innerBlock.name === 'woocommerce/store-notices' | ||
) | ||
); | ||
|
||
if ( groupBlock ) { | ||
selectBlock( groupBlock.clientId ); | ||
} | ||
}; | ||
|
||
const getTitle = () => { | ||
return __( 'Checkout Shortcode', 'woo-gutenberg-products-block' ); | ||
}; | ||
|
||
const getDescription = () => { | ||
return __( | ||
'This block will render the classic checkout shortcode. You can optionally transform it into blocks for more control over the checkout experience.', | ||
'woo-gutenberg-products-block' | ||
); | ||
}; | ||
|
||
const blockifyConfig = { | ||
getButtonLabel, | ||
onClickCallback, | ||
getBlockifiedTemplate, | ||
}; | ||
|
||
export { blockifyConfig, isConversionPossible, getDescription, getTitle }; |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { TemplateDetails } from './types'; | ||
|
||
export const TYPES = { | ||
cart: 'cart', | ||
checkout: 'checkout', | ||
}; | ||
export const PLACEHOLDERS = { | ||
cart: 'cart', | ||
checkout: 'checkout', | ||
}; | ||
|
||
export const TEMPLATES: TemplateDetails = { | ||
cart: { | ||
type: TYPES.cart, | ||
// Title shows up in the list view in the site editor. | ||
title: __( 'Cart Shortcode', 'woo-gutenberg-products-block' ), | ||
// Description in the site editor. | ||
description: __( | ||
'Renders the classic cart shortcode.', | ||
'woo-gutenberg-products-block' | ||
), | ||
placeholder: PLACEHOLDERS.cart, | ||
}, | ||
checkout: { | ||
type: TYPES.checkout, | ||
title: __( 'Checkout Shortcode', 'woo-gutenberg-products-block' ), | ||
description: __( | ||
'Renders the classic checkout shortcode.', | ||
'woo-gutenberg-products-block' | ||
), | ||
placeholder: PLACEHOLDERS.checkout, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
:where(.wp-block-woocommerce-classic-shortcode) { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
.wp-block-woocommerce-classic-shortcode__placeholder-warning { | ||
border-left: 5px solid #2181d2; | ||
padding-left: em(40px); | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder .components-placeholder__fieldset { | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder-wireframe, | ||
.wp-block-woocommerce-classic-shortcode__placeholder-copy { | ||
grid-row-start: 1; | ||
grid-column-start: 1; | ||
transition: 0.3s all ease; | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder-copy { | ||
border: 1px solid $gray-900; | ||
background-color: #fff; | ||
padding: $gap-large $gap-larger; | ||
border-radius: 3px; | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 900px; | ||
width: 400px; | ||
margin: auto; | ||
opacity: 0; | ||
z-index: 10; | ||
|
||
.wp-block-woocommerce-classic-shortcode__placeholder-copy__icon-container { | ||
margin: 0 0 $gap; | ||
|
||
span { | ||
@include font-size(larger); | ||
display: block; | ||
} | ||
.woo-icon { | ||
color: #{$studio-woocommerce-purple}; | ||
@include font-size(large); | ||
|
||
svg { | ||
vertical-align: middle; | ||
} | ||
} | ||
} | ||
p { | ||
margin: 0 0 $gap; | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder-migration-button-container { | ||
justify-content: center; | ||
margin: $gap 0; | ||
} | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder-wireframe { | ||
pointer-events: none; | ||
|
||
// Image based placeholders should fill horizontal width. | ||
> img { | ||
width: 100%; | ||
} | ||
} | ||
|
||
.wp-block-woocommerce-classic-shortcode { | ||
.components-placeholder { | ||
box-shadow: none; | ||
padding: 0; | ||
} | ||
} | ||
|
||
.is-selected .wp-block-woocommerce-classic-shortcode, | ||
.is-hovered .wp-block-woocommerce-classic-shortcode, | ||
.wp-block-woocommerce-classic-shortcode.is-selected, | ||
.wp-block-woocommerce-classic-shortcode.is-hovered { | ||
.wp-block-woocommerce-classic-shortcode__placeholder-wireframe { | ||
filter: blur(3px); | ||
opacity: 0.5; | ||
|
||
* { | ||
color: $gray-200 !important; | ||
border-color: $gray-200 !important; | ||
} | ||
} | ||
.wp-block-woocommerce-classic-shortcode__placeholder-copy { | ||
opacity: 1; | ||
} | ||
.components-placeholder { | ||
box-shadow: inherit; | ||
} | ||
} |
Oops, something went wrong.