Skip to content

Commit

Permalink
Refactor to use proper spacing utilities (godaddy-wordpress#1253)
Browse files Browse the repository at this point in the history
* Initial organization of utitlies

* Clean accordion styles

* Clean alert styles

* Clean author

* Move stacked shadow control to the bottom

* Clean and organize common vars

* Clean and remove excess classes from background component

* Use break-small() instead of hardcoding media query

* Remove unused utilities

* Add organized utilities

* Clean up editor-only utilities

* Clean and organize block gallery styles

* Update services block with revised columns and gutter utilities

* Update features block with revised columns and gutter utilities

* Update features block test

* Update collage block with proper utilities (plus deprecation)

* Update _datepicker.scss

* Clean up row block styles

* Clean up post carousel

* Clean up posts block

* Rename "columns" utility to "has-columns"

* Rename scss files

* Remove unneeded utilities on Offset Gallery

* Move format utility into the proper directory

* Update Posts block with cleaned up styling and utilities

* Clean up post carousel

* Update offset gallery style

* Clean utilities again

* Clean excess comments

* Clean more utilities

* Update edit.js

* Remove editor utility padding

* Use utilities in Offset gallery

* Move utilities into post carousel style

* Move utilities into posts block styles

* Move unused utilities

* Organizing more

* Add deprecations

* Update block.json

* test_coblocks_render_posts_block

* Update save.spec.js.snap

* Fix test_coblocks_render_posts_block unit test

* Tweak offset deprecation

* Remove unused component from Offset deprecation

* Try migrate for offset (not working)

* Try again, not working

* Fix offset components-placeholder spacing

* Change Larger to Huge (to match existing size patterns)

* Try new migration

* Update deprecated.js

* Update deprecated.js

* Update deprecated.js

* Update deprecated.js

* Fix gutter

* Features

* Fix responsive class

* Fix columns class on Features

* Update deprecated.js

* Finish Features deprecation

* Finish Features deprecation

* Fix offset

* Migrate Collage to utilities

* Tweaks

* Finish collage dep

* Responsive collage styles

* Remove last unused utils

* Tweaks for offset image size class

* Minor typo in deprecation

* Add legacy margin/padding

* Add support for legacy collage block

* Legacy styles for Features

* Legacy styles for Services

* Tweaking services legacy styling

* Finish services legacy styling

* Tweak for Row

* Fix gutter-none option for legacy collage block

* Fix no-gutter collage

Co-authored-by: Evan Herman <[email protected]>
Co-authored-by: JR Tashjian <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2020
1 parent 524bd86 commit 8ad59ea
Show file tree
Hide file tree
Showing 129 changed files with 2,628 additions and 2,578 deletions.
10 changes: 5 additions & 5 deletions .dev/tests/phpunit/src/blocks/posts/test-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public function test_file_actions() {
*/
public function test_coblocks_render_posts_block() {
$attributes = [
'className' => 'test-class-name',
'postsToShow' => 4,
'order' => 'date',
'orderBy' => 'desc',
'className' => 'test-class-name',
'postsToShow' => 4,
'order' => 'date',
'orderBy' => 'desc',
'postFeedType' => 'internal',
];

Expand All @@ -63,7 +63,7 @@ public function test_coblocks_render_posts_block() {
global $post;
$post = get_post( $post_id );

$this->assertEquals( '<div class="wp-block-coblocks-posts test-class-name"><div class="list-none ml-0 pl-0 pt-3"></div></div>', coblocks_render_posts_block( $attributes ) );
$this->assertEquals( '<div class="test-class-name"><div class="wp-block-coblocks-posts__inner"></div></div>', coblocks_render_posts_block( $attributes ) );
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/blocks/accordion/accordion-item/styles/editor.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.wp-block-coblocks-accordion-item {

p {
margin-top: 0;
}

// Remove hover and focus, as the title is now a text field.
// Remove hover and focus, as the title is a text field.
&__title {
&::after {
display: none;
Expand All @@ -15,7 +16,7 @@
}

&--open &__title {
border-radius: $accordion-border-radius $accordion-border-radius 0 0;
border-radius: 4px 4px 0 0;
}

// Set proper margin for the first and last item within the accordion item for < Gutenberg 6.3.
Expand Down
10 changes: 5 additions & 5 deletions src/blocks/accordion/accordion-item/styles/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.wp-block-coblocks-accordion-item {
border-radius: $accordion-border-radius;
border-radius: 4px;
margin: 0 0 1em;

p:first-of-type {
Expand All @@ -12,12 +12,12 @@

&__title {
background: hsla(240, 5%, 57%, 0.1);
border-radius: $accordion-border-radius;
border-radius: 4px;
padding: 10px 15px;
position: relative;

&::after {
border-radius: $accordion-border-radius;
border-radius: 4px;
bottom: 0;
content: "";
left: 0;
Expand All @@ -38,13 +38,13 @@
}

details[open] summary {
border-radius: $accordion-border-radius $accordion-border-radius 0 0;
border-radius: 4px 4px 0 0;
}

&__content {
border: 1px solid hsla(240, 5%, 57%, 0.1);
border-radius: 0 0 4px 4px;
border-top: 0;
border-radius: 0 0 $accordion-border-radius $accordion-border-radius;
padding: 15px 20px;

> div {
Expand Down
16 changes: 8 additions & 8 deletions src/blocks/alert/styles/editor.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.block-editor-block-styles .wp-block-coblocks-alert {
background-color: $alert-default-background-color !important;
color: $alert-default-color !important;
background-color: $color-alert-default-bg !important;
color: $color-alert-default-color !important;

&.is-style-warning {
background-color: $alert-warning-background-color !important;
color: $alert-warning-color !important;
background-color: $color-alert-warning-bg !important;
color: $color-alert-warning-color !important;
}

&.is-style-error {
background-color: $alert-error-background-color !important;
color: $alert-error-color !important;
background-color: $color-alert-error-bg !important;
color: $color-alert-error-color !important;
}

&.is-style-success {
background-color: $alert-success-background-color !important;
color: $alert-success-color !important;
background-color: $color-alert-success-bg !important;
color: $color-alert-success-color !important;
}
}
18 changes: 9 additions & 9 deletions src/blocks/alert/styles/style.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
.wp-block-coblocks-alert {
background-color: $alert-default-background-color;
border-radius: 3px;
color: $alert-default-color;
background-color: $color-alert-default-bg;
border-radius: 4px;
color: $color-alert-default-color;
padding: 2em;

&:not(.has-background) {
&.is-style-warning {
background-color: $alert-warning-background-color;
background-color: $color-alert-warning-bg;
}

&.is-style-error {
background-color: $alert-error-background-color;
background-color: $color-alert-error-bg;
}

&.is-style-success {
background-color: $alert-success-background-color;
background-color: $color-alert-success-bg;
}
}

&:not(.has-text-color) {
&.is-style-warning {
color: $alert-warning-color;
color: $color-alert-warning-color;
}

&.is-style-error {
color: $alert-error-color;
color: $color-alert-error-color;
}

&.is-style-success {
color: $alert-success-color;
color: $color-alert-success-color;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/blocks/author/styles/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
}

.wp-block-coblocks-author {

&__avatar {
background: $white;
position: relative;
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/author/styles/style.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.wp-block-coblocks-author {
align-items: flex-start;
background: $accordion-background;
background: $dark-opacity-light-200;
display: flex;
padding: 30px 25px;
position: relative;

@media (min-width: 600px) {
@include break-small() {
padding: 40px 35px;
}

Expand All @@ -17,7 +17,7 @@
position: relative;
width: 70px;

@media (min-width: 600px) {
@include break-small() {
height: 150px;
margin-right: 35px;
width: 150px;
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/click-to-tweet/styles/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.wp-block-coblocks-click-to-tweet {
border-radius: $accordion-border-radius;
border-radius: 4px;
margin-bottom: 1.9em;
position: relative;
border: 1px solid transparent;
Expand Down Expand Up @@ -30,12 +30,12 @@
}

&__twitter-btn:not(.has-button-color) {
background: $twitter;
background: $color-twitter;
}

&__twitter-btn {
appearance: none;
border-radius: $accordion-border-radius;
border-radius: 4px;
border: none;
box-shadow: none !important;
color: $white !important;
Expand Down
42 changes: 2 additions & 40 deletions src/blocks/dynamic-separator/styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,5 @@
}
}

.is-twentytwenty {
.entry-content hr.wp-block-coblocks-dynamic-separator {
&::before {
background: none;
content: "...";
left: 0;
top: calc(50% - 18px);
transform: none;
width: auto;
}

&::after {
display: none;
}

&.is-style-line::before,
&.is-style-fullwidth::before {
background: currentColor;
content: "";
display: block;
height: 1px;
margin-left: auto;
max-width: 120px;
top: 50%;
width: 15vw;
}

&.is-style-fullwidth::before {
max-width: 100%;
width: 100%;
}
}

.wp-block-coblocks-dynamic-separator.is-style-line:not(.has-background),
.wp-block-coblocks-dynamic-separator.is-style-fullwidth:not(.has-background) {
&::before {
background: #6d6d6d; // Color from TwentyTwenty
}
}
}
// Import style tweaks for core WordPress themes
@import "theme";
40 changes: 40 additions & 0 deletions src/blocks/dynamic-separator/styles/theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.is-twentytwenty {
.entry-content hr.wp-block-coblocks-dynamic-separator {
&::before {
background: none;
content: "...";
left: 0;
top: calc(50% - 18px);
transform: none;
width: auto;
}

&::after {
display: none;
}

&.is-style-line::before,
&.is-style-fullwidth::before {
background: currentColor;
content: "";
display: block;
height: 1px;
margin-left: auto;
max-width: 120px;
top: 50%;
width: 15vw;
}

&.is-style-fullwidth::before {
max-width: 100%;
width: 100%;
}
}

.wp-block-coblocks-dynamic-separator.is-style-line:not(.has-background),
.wp-block-coblocks-dynamic-separator.is-style-fullwidth:not(.has-background) {
&::before {
background: #6d6d6d; // Color from TwentyTwenty
}
}
}
2 changes: 1 addition & 1 deletion src/blocks/features/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"attributes": {
"gutter": {
"type": "string",
"default": "large"
"default": "medium"
},
"columns": {
"type": "number",
Expand Down
79 changes: 79 additions & 0 deletions src/blocks/features/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* Internal dependencies
*/
import metadata from './block.json';
import { BackgroundStyles, BackgroundClasses, BackgroundVideo, BackgroundAttributes } from '../../components/background';
import DimensionsAttributes from '../../components/dimensions-control/attributes';

/**
* WordPress dependencies
*/
import { InnerBlocks, getColorClassName } from '@wordpress/block-editor';

const deprecated =
[ {
attributes: {
...DimensionsAttributes,
...BackgroundAttributes,
...metadata.attributes,
gutter: {
type: 'string',
default: 'large',
},
},
save( { attributes, className } ) {
const {
coblocks,
columns,
contentAlign,
customTextColor,
textColor,
gutter,
marginSize,
paddingSize,
} = attributes;

// Body color class and styles.
const textClass = getColorClassName( 'color', textColor );

let classes = className;

if ( coblocks && ( typeof coblocks.id !== 'undefined' ) ) {
classes = classnames( classes, `coblocks-features-${ coblocks.id }` );
}

const innerClasses = classnames(
'wp-block-coblocks-features__inner',
...BackgroundClasses( attributes ), {
'has-text-color': textColor || customTextColor,
[ textClass ]: textClass,
'has-padding': paddingSize && paddingSize !== 'no',
[ `has-${ paddingSize }-padding` ]: paddingSize && ( paddingSize !== 'advanced' ),
'has-margin': marginSize && marginSize !== 'no',
[ `has-${ marginSize }-margin` ]: marginSize && ( marginSize !== 'advanced' ),
[ `has-${ gutter }-gutter` ]: gutter,
[ `has-${ contentAlign }-content` ]: contentAlign,
} );

const innerStyles = {
...BackgroundStyles( attributes ),
color: textClass ? undefined : customTextColor,
};

return (
<div className={ classes } data-columns={ columns }>
<div className={ innerClasses } style={ innerStyles }>
{ BackgroundVideo( attributes ) }
<InnerBlocks.Content />
</div>
</div>
);
},
} ];

export default deprecated;
Loading

0 comments on commit 8ad59ea

Please sign in to comment.