-
Notifications
You must be signed in to change notification settings - Fork 219
Product Stock indicator: Add support for background color, margin, padding & various typography controls #8954
Conversation
This commit introduces a new file `supports.ts` for the Product SKU block in the WooCommerce Blocks plugin, which adds color, typography, and spacing support. The following configuration has been added: 1. In `assets/js/atomic/blocks/product-elements/sku/supports.ts`, a new `supports` object is created, which extends the shared configuration and adds support for the following properties: - `text` and `background` color - `fontSize`, `lineHeight`, `__experimentalFontWeight`, `__experimentalFontFamily`, `__experimentalFontStyle`, `__experimentalTextTransform`, `__experimentalTextDecoration`, and `__experimentalLetterSpacing` for typography - `margin` and `padding` for spacing
…ll Products block This commit extends the support for color, typography, and spacing to the Product SKU block when used within the All Products block. The following changes have been made: 1. In `assets/js/atomic/blocks/product-elements/sku/block.tsx`, the `useColorProps`, `useSpacingProps`, and `useTypographyProps` hooks are imported and used to add the appropriate className and style properties to the rendered SKU element. 2. In `assets/js/atomic/blocks/product-elements/sku/edit.tsx`, the `style` property is separated from `useBlockProps()` and used directly on the `div` element for the SKU block.
This commit adds the ".wp-block-woocommerce-product-sku" class to the Product SKU Gutenberg block for server-side rendering purposes. The inclusion of this class ensures consistent styling between the editor and the front-end view of the block, providing a seamless experience for users. The class name is generated based on the Gutenberg block prefix "wp-block", the namespace "woocommerce", and the block name "product-sku", creating a unique and identifiable class for the block. This class enables developers to target the block specifically in both the editor and front-end styles, maintaining the integrity of the block's appearance and functionality across different environments. By adding this class to the server-side rendered version of the block, we ensure a unified and coherent styling experience throughout the block's usage.
This commit refactors the Product SKU block supports to enable color, typography, and spacing features for all builds, while keeping experimental features specific to the feature plugin build. It also adds necessary lint and TypeScript error handling for the experimental spacing API.
This commit adds the overflow-wrap property to the Product SKU block styles to handle long SKU values gracefully. It also updates the comment for the experimental spacing API to better reflect the usage check.
This commit refactors the Product SKU block classname and style handling. It combines classnames for better readability and removes the hardcoded textTransform style in favor of default styles. This also fix the issue where textTransform style was not working as expected.
This commit updates the stock-indicator block support in the woocommerce-blocks repository. It includes the following changes: - Added support for background color, line height, and various experimental typography features. - Conditionally included support for margin and padding based on the availability of the __experimentalGetSpacingClassesAndStyles function from the @wordpress/block-editor package. These updates provide more customization options for the stock-indicator block, allowing users to better match the appearance of this element to their site's design.
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +453 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
This commit introduces a new function, `getTextBasedOnStock`, which handles the generation of stock text based on the stock information provided. It replaces the previous `lowStockText` and `stockText` functions, making the code more readable and maintainable. In addition, minor adjustments to the class name handling have been made to simplify the code and ensure consistent styling when used inside the All Products block. In the `edit.tsx` file, the `useBlockProps` function call has been updated to include the default `wc-block-components-product-stock-indicator` class name, ensuring it is always applied.
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.
Great work!
Since that we removed the __experimentalSelector
key, I think that we can remove those lines: https://github.com/woocommerce/woocommerce-blocks/pull/8954/files#diff-fdc398df407d5b8f5953192c6f08df749bebd4b2e771ee9bf1cccdb0b7a9966dR31-R45
This commit removes the redundant get_block_type_supports() method from the ProductStockIndicator.php file, as it is no longer needed. The block type supports are now handled in the frontend.
Hi @gigitux, thanks for the suggestion. I've removed the Could you please take a quick look before I merge this PR? 🙂 |
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.
Nice work! 🚢
This Pull Request enhances the styling capabilities of the Product Stock Indicator block by introducing additional support for background color, typography & spacing. This improvement provides users with more flexibility when customizing the appearance of the Product Stock Indicator block.
Here is what Product Stock Indicator block supports now:
Color:
Typography:
Spacing:
Part of #7954 & #8695
Testing
Test using blocks sidebar
Test using Global Styles
Screen.Recording.2023-03-30.at.2.17.57.PM.mov
WooCommerce Visibility
Changelog