Skip to content

Commit

Permalink
Improve WooCommerce blocks styling (#70)
Browse files Browse the repository at this point in the history
* Improve WooCommerce blocks styling

* Remove forms mixin
  • Loading branch information
madalingorbanescu authored Jan 21, 2020
1 parent 102e4b1 commit 99c4d54
Show file tree
Hide file tree
Showing 20 changed files with 2,340 additions and 181 deletions.
26 changes: 15 additions & 11 deletions assets/scss/blocks/_helpers.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
$wp-colors: (
sm-color-primary: var(--current-color-primary),
sm-color-secondary: var(--current-color-secondary),
sm-color-tertiary: var(--current-color-tertiary),
sm-dark-primary: var(--current-dark-primary),
sm-dark-secondary: var(--current-dark-secondary),
sm-dark-tertiary: var(--current-dark-tertiary),
sm-light-primary: var(--current-light-primary),
sm-light-secondary: var(--current-light-secondary),
sm-light-tertiary: var(--current-light-tertiary),
sm_color_primary: var(--current-color-primary),
sm_color_secondary: var(--current-color-secondary),
sm_color_tertiary: var(--current-color-tertiary),
sm_dark_primary: var(--current-dark-primary),
sm_dark_secondary: var(--current-dark-secondary),
sm_dark_tertiary: var(--current-dark-tertiary),
sm_light_primary: var(--current-light-primary),
sm_light_secondary: var(--current-light-secondary),
sm_light_tertiary: var(--current-light-tertiary),
);

/* Color Helper Classes */
Expand All @@ -17,7 +17,10 @@ $wp-colors: (

@each $name, $color in $wp-colors {

.has-#{$name}-background-color {
$kebabName: str-replace($name, '_', '-');

.has-#{$name}-background-color,
.has-#{$kebabName}-background-color {
background-color: $color;

@include specific(3) {
Expand All @@ -39,7 +42,8 @@ $wp-colors: (
}
}

.has-#{$name}-color {
.has-#{$name}-color,
.has-#{$kebabName}-color {
color: $color;

@include specific(3) {
Expand Down
3 changes: 2 additions & 1 deletion assets/scss/components/site-header/_menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ ul.menu,
}
}

.menu-item {
.menu-item,
.page_item {
position: relative;
}
9 changes: 9 additions & 0 deletions assets/scss/editor-woocommerce.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import "setup";
@import "woocommerce/product";
@import "woocommerce/blocks/style";

// Force add-to-cart button to be displayed without hover
.wp-block-button.wc-block-grid__product-add-to-cart {
opacity: 1;
transform: translateY(0);
}
149 changes: 0 additions & 149 deletions assets/scss/elements/_forms.scss
Original file line number Diff line number Diff line change
@@ -1,152 +1,3 @@
// Forms General Options

// @todo more semantic for these variables
$color-dark: var(--current-dark-secondary) !default;
$color-white: var(--current-light-primary) !default;

$input-color: var(--current-dark-secondary) !default;
$input-border-color: var(--current-light-tertiary) !default;
$input-border-width: .0625em !default;
$input-background-color: var(--current-light-tertiary) !default;
$input-padding: .8em 1.18em .93em !default;
$input-focus-border-color: var(--current-dark-primary) !default;
$input-focus-background-color: var(--current-light-primary) !default;
$input-border-radius: 0 !default;
$input-disabled-color: var(--current-dark-secondary) !default;
$input-disabled-background-color: var(--current-dark-secondary) !default;
$input-disabled-border-color: var(--current-dark-secondary) !default;

$placeholder-color: var(--current-dark-secondary) !default;

$label-color: var(--current-dark-secondary) !default;

$legend-color: var(--current-dark-secondary) !default;

$button-color: var(--current-light-primary) !default;
$button-background-color: var(--current-dark-secondary) !default;

$checkbox-color: var(--current-dark-secondary) !default;
$checkbox-background-color: var(--current-light-primary) !default;
$checkbox-width: 1.5rem !default;
$checkbox-height: 1.5rem !default;

// Spacing
$input-vertical-spacing: var(--theme-spacing-tiny) !default;
$input-horizontal-spacing: var(--theme-spacing-tiny) !default; // Checkboxes and Radios

@mixin field {
width: 100%;
height: auto;
max-width: 100%;
padding: $input-padding;
border: $input-border-width solid $input-border-color;

color: $input-color;
border-radius: $input-border-radius;
background-color: $input-background-color;

font: inherit;
line-height: 1.5;
-webkit-font-smoothing: initial;
-webkit-appearance: none;

&:focus,
&:active {
outline: 0;
box-shadow: none;
border-color: $input-focus-border-color;
}

&[disabled] {
border-color: $input-disabled-border-color;
background-color: $input-disabled-background-color;
}
}


@mixin input {
@include field;
}

@mixin textarea {
@include field;

min-height: 7.5em;
resize: vertical;
}

@mixin select {
@include field;

padding-right: 3.125em;

background-color: var(--current-light-tertiary);
background-image: url("assets/images/arrow-caret.svg");
background-position: calc(100% - 17px) center;
background-repeat: no-repeat;
background-size: .56em .312em;

-webkit-appearance: none;
}

@mixin label {
color: $label-color;
font: inherit;
margin: 0;

&:not(:first-child) {
margin-top: $input-vertical-spacing;
}

&:not(:last-child) {
margin-bottom: $input-vertical-spacing;
}

cursor: pointer;
}

@mixin checkbox-base {
position: relative;
left: 0;

float: left;
clear: left;

border: $input-border-width solid $input-border-color;
border-radius: $input-border-radius;

width: $checkbox-width !important;
height: $checkbox-height !important;
margin-right: $input-horizontal-spacing;
margin-bottom: $input-vertical-spacing;

background-color: $color-white;
cursor: pointer;

-webkit-appearance: none;
}

@mixin checkbox {
@include checkbox-base;

&:checked {
border-color: $checkbox-color;
background: $checkbox-background-color url('assets/images/checkbox.svg') center center no-repeat;
background-size: 100% 100%;
outline: 0;
}
}

@mixin radio {
@include checkbox-base;
border-radius: 50%;

&:checked {
border: .43em solid $checkbox-color;
outline: 0;
}
}

@include placeholder() {
color: $placeholder-color;
opacity: .6;
Expand Down
17 changes: 17 additions & 0 deletions assets/scss/setup/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@

@return $number;
}

/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
/// Source: https://css-tricks.com/snippets/sass/str-replace-function/
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);

@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}

@return $string;
}
1 change: 1 addition & 0 deletions assets/scss/setup/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@import "mixins/fluid";
@import "mixins/font";
@import "mixins/grid";
@import "mixins/forms";
@import "mixins/image-cover";
@import "mixins/media-queries";
@import "mixins/nav-links";
Expand Down
148 changes: 148 additions & 0 deletions assets/scss/setup/mixins/_forms.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Forms General Options

// @todo more semantic for these variables
$color-dark: var(--current-dark-secondary) !default;
$color-white: var(--current-light-primary) !default;

$input-color: var(--current-dark-secondary) !default;
$input-border-color: var(--current-light-tertiary) !default;
$input-border-width: .0625em !default;
$input-background-color: var(--current-light-tertiary) !default;
$input-padding: .8em 1.18em .93em !default;
$input-focus-border-color: var(--current-dark-primary) !default;
$input-focus-background-color: var(--current-light-primary) !default;
$input-border-radius: 0 !default;
$input-disabled-color: var(--current-dark-secondary) !default;
$input-disabled-background-color: var(--current-dark-secondary) !default;
$input-disabled-border-color: var(--current-dark-secondary) !default;

$placeholder-color: var(--current-dark-secondary) !default;

$label-color: var(--current-dark-secondary) !default;

$legend-color: var(--current-dark-secondary) !default;

$button-color: var(--current-light-primary) !default;
$button-background-color: var(--current-dark-secondary) !default;

$checkbox-color: var(--current-dark-secondary) !default;
$checkbox-background-color: var(--current-light-primary) !default;
$checkbox-width: 1.5rem !default;
$checkbox-height: 1.5rem !default;

// Spacing
$input-vertical-spacing: var(--theme-spacing-tiny) !default;
$input-horizontal-spacing: var(--theme-spacing-tiny) !default; // Checkboxes and Radios

@mixin field {
width: 100%;
height: auto;
max-width: 100%;
padding: $input-padding;
border: $input-border-width solid $input-border-color;

color: $input-color;
border-radius: $input-border-radius;
background-color: $input-background-color;

font: inherit;
line-height: 1.5;
-webkit-font-smoothing: initial;
-webkit-appearance: none;

&:focus,
&:active {
outline: 0;
box-shadow: none;
border-color: $input-focus-border-color;
}

&[disabled] {
border-color: $input-disabled-border-color;
background-color: $input-disabled-background-color;
}
}


@mixin input {
@include field;
}

@mixin textarea {
@include field;

min-height: 7.5em;
resize: vertical;
}

@mixin select {
@include field;

padding-right: 3.125em;

background-color: var(--current-light-tertiary);
background-image: url("assets/images/arrow-caret.svg");
background-position: calc(100% - 17px) center;
background-repeat: no-repeat;
background-size: .56em .312em;

-webkit-appearance: none;
}

@mixin label {
color: $label-color;
font: inherit;
margin: 0;

&:not(:first-child) {
margin-top: $input-vertical-spacing;
}

&:not(:last-child) {
margin-bottom: $input-vertical-spacing;
}

cursor: pointer;
}

@mixin checkbox-base {
position: relative;
left: 0;

float: left;
clear: left;

border: $input-border-width solid $input-border-color;
border-radius: $input-border-radius;

width: $checkbox-width !important;
height: $checkbox-height !important;
margin-right: $input-horizontal-spacing;
margin-bottom: $input-vertical-spacing;

background-color: $color-white;
cursor: pointer;

-webkit-appearance: none;
}

@mixin checkbox {
@include checkbox-base;

&:checked {
border-color: $checkbox-color;
background: $checkbox-background-color url('assets/images/checkbox.svg') center center no-repeat;
background-size: 100% 100%;
outline: 0;
}
}

@mixin radio {
@include checkbox-base;
border-radius: 50%;

&:checked {
border: .43em solid $checkbox-color;
outline: 0;
}
}
Loading

0 comments on commit 99c4d54

Please sign in to comment.