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
Featured Category block: add support for global style #5542
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e9d7c30
Product title: add support global style #4965
gigitux 517f80a
add specific type
gigitux 48709c7
add custom save function
gigitux 6d79824
move hooks in a specific folder
gigitux 4bcdc58
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux a17ca36
fix crash on WP 5.8
gigitux 8e2f0dc
Featured Category block: Add support for global style #4965
gigitux 1d9cf47
fix border color
gigitux c2cab62
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux 614737f
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux 8a92711
fix opacity
gigitux 3effda7
fix border radius
gigitux 755d7cc
fix order rules css
gigitux 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Block from './block'; | ||
|
||
export const Edit = ( props: unknown ): JSX.Element => { | ||
const blockProps = useBlockProps(); | ||
|
||
// The useBlockProps function returns the style with the `color`. | ||
// We need to remove it to avoid the block to be styled with the color. | ||
const { color, ...styles } = blockProps.style; | ||
|
||
return ( | ||
<div { ...blockProps } style={ styles }> | ||
<Block { ...props } /> | ||
</div> | ||
); | ||
}; |
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,19 +6,21 @@ import { InnerBlocks } from '@wordpress/block-editor'; | |||||||||||
import { registerBlockType } from '@wordpress/blocks'; | ||||||||||||
import { getSetting } from '@woocommerce/settings'; | ||||||||||||
import { Icon, folderStarred } from '@woocommerce/icons'; | ||||||||||||
import { isFeaturePluginBuild } from '@woocommerce/block-settings'; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Internal dependencies | ||||||||||||
*/ | ||||||||||||
import './style.scss'; | ||||||||||||
import './editor.scss'; | ||||||||||||
import Block from './block'; | ||||||||||||
import { example } from './example'; | ||||||||||||
import { Edit } from './edit'; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Register and run the "Featured Category" block. | ||||||||||||
*/ | ||||||||||||
registerBlockType( 'woocommerce/featured-category', { | ||||||||||||
apiVersion: 2, | ||||||||||||
title: __( 'Featured Category', 'woo-gutenberg-products-block' ), | ||||||||||||
icon: { | ||||||||||||
src: ( | ||||||||||||
|
@@ -37,6 +39,21 @@ registerBlockType( 'woocommerce/featured-category', { | |||||||||||
supports: { | ||||||||||||
align: [ 'wide', 'full' ], | ||||||||||||
html: false, | ||||||||||||
color: { | ||||||||||||
text: true, | ||||||||||||
background: true, | ||||||||||||
}, | ||||||||||||
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. Background and text color are enabled by default so this can be shortened like this:
Suggested change
|
||||||||||||
typography: { | ||||||||||||
fontSize: true, | ||||||||||||
}, | ||||||||||||
...( isFeaturePluginBuild() && { | ||||||||||||
__experimentalBorder: { | ||||||||||||
color: true, | ||||||||||||
radius: true, | ||||||||||||
width: true, | ||||||||||||
__experimentalSkipSerialization: false, | ||||||||||||
}, | ||||||||||||
} ), | ||||||||||||
}, | ||||||||||||
example, | ||||||||||||
attributes: { | ||||||||||||
|
@@ -146,14 +163,12 @@ registerBlockType( 'woocommerce/featured-category', { | |||||||||||
* | ||||||||||||
* @param {Object} props Props to pass to block. | ||||||||||||
*/ | ||||||||||||
edit( props ) { | ||||||||||||
return <Block { ...props } />; | ||||||||||||
}, | ||||||||||||
edit: Edit, | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Block content is rendered in PHP, not via save function. | ||||||||||||
*/ | ||||||||||||
save() { | ||||||||||||
save: () => { | ||||||||||||
return <InnerBlocks.Content />; | ||||||||||||
}, | ||||||||||||
} ); |
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,10 +1,16 @@ | ||
.wp-block-woocommerce-featured-category { | ||
border-color: transparent; | ||
overflow: hidden; | ||
color: #fff; | ||
background-color: #000; | ||
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. Can we order CSS properties alphabetically? It's easier to maintain. |
||
} | ||
|
||
.wc-block-featured-category { | ||
position: relative; | ||
background-color: $gray-900; | ||
background-size: cover; | ||
background-position: center center; | ||
width: 100%; | ||
margin: 0 0 1.5em 0; | ||
margin: 0 0 0 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
@@ -63,6 +69,8 @@ | |
.wc-block-featured-category__description, | ||
.wc-block-featured-category__price, | ||
.wc-block-featured-category__link { | ||
color: inherit; | ||
font-size: inherit; | ||
width: 100%; | ||
padding: 0 48px 16px 48px; | ||
z-index: 1; | ||
|
@@ -71,12 +79,19 @@ | |
.wc-block-featured-category__title { | ||
margin-top: 0; | ||
|
||
div { | ||
color: inherit; | ||
font-size: inherit; | ||
} | ||
|
||
&::before { | ||
display: none; | ||
} | ||
} | ||
|
||
.wc-block-featured-category__description { | ||
color: inherit; | ||
font-size: inherit; | ||
p { | ||
margin: 0; | ||
} | ||
|
@@ -94,6 +109,7 @@ | |
bottom: 0; | ||
right: 0; | ||
background-color: inherit; | ||
border-radius: inherit; | ||
opacity: 0.5; | ||
z-index: 1; | ||
} | ||
|
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
Oops, something went wrong.
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.
I think that we should not limit the height in the editor.
Now the user can change the
font-size
. If thefont-size
is high, the block should become bigger otherwise the user can't see the entire text.