Skip to content

Commit

Permalink
stylesheets examples improved
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmaguitar committed Nov 7, 2023
1 parent cafb7ec commit cf80013
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
8 changes: 8 additions & 0 deletions plugins/stylesheets-79a4c3/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
### Block Development Examples - Stylesheets 79a4c3

This example shows how to apply styles to blocks using different sources:
- inline styles
- default classes (`wp-block-block-development-examples-stylesheets-79a4c3`)
- custom classes (`hasPerspective`)
- styles only for the editor (`editor.scss`)
- styles shared by the editor and the frontend (`style.scss`)


<!-- Please, do not remove these @TABLE EXAMPLES BEGIN and @TABLE EXAMPLES END comments or modify the table inside. This table is automatically generated from the data at data/examples.json and data/tags.json -->
<!-- @TABLE EXAMPLES BEGIN -->
| Folder | <span style="display: inline-block; width:250px">Short description</span> | Tags | ID ([❓](https://github.com/wptrainingteam/block-development-examples/wiki/04-Why-an-ID-for-every-example%3F "Why an ID for every example?")) | Download .zip | Live Demo |
Expand Down
2 changes: 1 addition & 1 deletion plugins/stylesheets-79a4c3/build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => '1aabc5acf8be95b43685');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => 'e9497778f99f65a5f848');
2 changes: 1 addition & 1 deletion plugins/stylesheets-79a4c3/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/stylesheets-79a4c3/build/style-index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion plugins/stylesheets-79a4c3/src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ import './editor.scss';
* @return {WPElement} Element to render.
*/
export default function Edit() {
const customStyleUnderline = {
textDecoration:'green wavy underline'
};

const blockProps = useBlockProps( { style: customStyleUnderline, className: 'hasPerspective', } );

return (
<p { ...useBlockProps() }>
<p { ...blockProps }>
{ __(
'Hello World, step 2 (from the editor, in green).',
'block-development-examples'
Expand Down
13 changes: 12 additions & 1 deletion plugins/stylesheets-79a4c3/src/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ import { __ } from '@wordpress/i18n';
* @return {WPElement} Element to render.
*/
export default function save() {

const customStyleUnderline = {
textDecoration:'red underline',
textDecorationThickness: '3px'
};

const blockProps = useBlockProps.save( {
style: customStyleUnderline,
className: 'hasPerspective'
} );

return (
<p { ...useBlockProps.save() }>
<p { ...blockProps }>
{ __(
'Hello World, step 2 (from the frontend, in red).',
'block-development-examples'
Expand Down
9 changes: 8 additions & 1 deletion plugins/stylesheets-79a4c3/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@
background: #fcc;
border: 2px solid #c99;
padding: 20px;
}

&.hasPerspective {
transform: perspective(400px) rotate3d(1, -1, 0, 8deg);
}
&.hasPerspective:hover {
transform: perspective(400px) rotate3d(1, -1, 0, -8deg);
}
}

0 comments on commit cf80013

Please sign in to comment.