Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual improvements for 3.0 #2981

Merged
merged 12 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/scss/components/elements/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ pre {
ul, ol {
padding-left: $spacing-lg;
}

li {
margin-top: $spacing-xs;
}
}

// === Content Floating Alignments === //
Expand Down
11 changes: 11 additions & 0 deletions assets/scss/components/elements/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@
font-weight: 700;
font-size: var(--h4FontSize);
}

@extend %nv-reset-field-spacing;
}

.wp-block-search .wp-block-search__button {
@extend %nv-button-primary;
}

.wp-block-search.wp-block-search__button-inside .wp-block-search__inside-wrapper {
@extend %nv-form-fields;
}


.post-date {
display: block;
font-size: $text-sm;
Expand Down
4 changes: 0 additions & 4 deletions assets/scss/components/elements/blog/_blogpost-covers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ $overlay: rgba(0, 0, 0, 0.75);
color: var(--color, #fff);
}
}

.entry-title {
margin-bottom: 20px;
}
}
25 changes: 16 additions & 9 deletions assets/scss/components/elements/blog/_blogpost-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}

.blog-entry-title {
margin-bottom: $spacing-xs;
word-wrap: break-word;
}

Expand Down Expand Up @@ -65,15 +66,17 @@
margin-bottom: 0;
}

.layout-grid .content > * {
margin: $spacing-xs 0;

&:last-child {
margin-bottom: 0;
.layout-grid .content {
> .blog-entry-title {
margin-bottom: $spacing-xs;
}

&:first-child {
margin-top: 0;
> * {
margin-bottom: $spacing-md;

&:last-child {
margin-bottom: 0;
}
}
}

Expand All @@ -85,8 +88,12 @@
flex-direction: column;
flex-grow: 1;

> .blog-entry-title {
margin-bottom: $spacing-xs;
}

> * {
margin: 0 0 $spacing-md;
margin-bottom: $spacing-md;

&:last-child {
margin-bottom: 0;
Expand All @@ -106,7 +113,7 @@ body:not(.nv-blog-default) {
margin-right: calc(-1 * var(--gridSpacing, 30px) / 2);

article {
margin-bottom: calc(var(--gridSpacing, 30px) );
margin-bottom: calc(var(--gridSpacing, 30px));
padding: 0 calc(var(--gridSpacing, 30px) / 2);
}
}
Expand Down
4 changes: 2 additions & 2 deletions assets/scss/components/elements/blog/_single.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
margin-top: $spacing-aired;
}

.entry-header .title, .page .title, .nv-page-title {
margin-bottom: $spacing-xl;
.entry-header .title {
margin-bottom: $spacing-xs;
}

.attachment-neve-blog {
Expand Down
2 changes: 2 additions & 0 deletions assets/scss/components/main/_extends.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
color: var(--primaryBtnColor);
border-style: solid;
border-color: currentColor;
fill: currentColor;
border-width: var(--primaryBtnBorderWidth, 0);
border-radius: var(--primaryBtnBorderRadius, 3px);
padding: var(--primaryBtnPadding, 13px 15px);
Expand Down Expand Up @@ -69,6 +70,7 @@
color: var(--secondaryBtnColor);
border-style: solid;
border-color: currentColor;
fill: currentColor;
border-width: var(--secondaryBtnBorderWidth, 0);
border-radius: var(--secondaryBtnBorderRadius, 3px);
padding: var(--secondaryBtnPadding, 7px 12px);
Expand Down
8 changes: 6 additions & 2 deletions e2e-tests/cypress/integration/editor/classic/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ describe('Page meta box settings', function () {
});
});
cy.setCustomizeSettings({
neve_migrated_hfg_colors: true,
nav_menu_locations: [],
custom_css_post_id: -1,
nav_menu_locations: [],
neve_migrated_hfg_colors: true,
neve_new_skin: 'new',
neve_ran_migrations: true,
neve_blog_archive_content_width: 50,
neve_other_pages_content_width: 30,
neve_single_post_content_width: 40,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ describe('Single page sidebar', function () {
});

cy.setCustomizeSettings({
neve_migrated_hfg_colors: true,
nav_menu_locations: [],
custom_css_post_id: -1,
nav_menu_locations: [],
neve_migrated_hfg_colors: true,
neve_new_skin: 'new',
neve_ran_migrations: true,
neve_blog_archive_content_width: 50,
neve_other_pages_content_width: 30,
neve_single_post_content_width: 40,
});
cy.saveLocalStorage();
});
Expand Down
9 changes: 9 additions & 0 deletions globals/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1492,3 +1492,12 @@ function neve_can_use_conditional_header() {
function neve_had_old_hfb() {
return ( get_theme_mod( 'hfg_header_layout' ) !== false || get_theme_mod( 'hfg_footer_layout' ) ) !== false;
}

/**
* Check if we have pro support.
*
* @param string $feature feature to check support for.
*/
function neve_pro_has_support( $feature ) {
return ( defined( 'NEVE_PRO_COMPATIBILITY_FEATURES' ) && isset( NEVE_PRO_COMPATIBILITY_FEATURES[ $feature ] ) );
}
2 changes: 1 addition & 1 deletion header-footer-grid/Core/Components/PaletteSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function toggle_script() {
$default_state = 'window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"';
}

return '"use strict";const e="data-neve-theme",t="neve_user_theme";function r(){let n=' . $default_state . ',r=localStorage.getItem(t);"dark"===r&&(n="dark"),"light"===r&&(n="light"),document.documentElement.setAttribute(e,n)}r();const a=document.getElementById("neve_body");function n(n){if(n.srcElement&&(n.srcElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.parentElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.parentElement.parentElement.matches("a.palette-icon-wrapper"))){if(n.preventDefault(),"dark"===document.documentElement.getAttribute(e))return localStorage.setItem(t,"light"),void document.documentElement.setAttribute(e,"light");localStorage.setItem(t,"dark"),document.documentElement.setAttribute(e,"dark")}}a&&a.addEventListener("click",n,!1);';
return '!function(){"use strict";const e="data-neve-theme",t="neve_user_theme";function r(){let n=' . $default_state . ',r=localStorage.getItem(t);"dark"===r&&(n="dark"),"light"===r&&(n="light"),document.documentElement.setAttribute(e,n)}r();const a=document.getElementById("neve_body");function n(n){if(n.srcElement&&(n.srcElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.parentElement.matches("a.palette-icon-wrapper")||n.srcElement.parentElement&&n.srcElement.parentElement.parentElement.parentElement.matches("a.palette-icon-wrapper"))){if(n.preventDefault(),"dark"===document.documentElement.getAttribute(e))return localStorage.setItem(t,"light"),void document.documentElement.setAttribute(e,"light");localStorage.setItem(t,"dark"),document.documentElement.setAttribute(e,"dark")}}a&&a.addEventListener("click",n,!1);}();';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/admin/metabox/controls/control_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ final public function save( $post_id ) {
if ( isset( $_POST[ $this->id ] ) ) {
$value = $this->sanitize_value( wp_unslash( $_POST[ $this->id ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
// Remove post meta on default.
if ( $value === $this->settings['default'] ) {
if ( $value === $this->settings['default'] && $this->id !== 'neve_meta_content_width' ) {
delete_post_meta( $post_id, $this->id );

return;
Expand Down
58 changes: 55 additions & 3 deletions inc/admin/metabox/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
* @package Neve\Admin\Metabox
*/
class Main extends Controls_Base {

/**
* Is new skin.
*
* @var bool
*/
private $new_skin;

/**
* Main constructor.
*/
public function __construct() {
$this->new_skin = neve_is_new_skin();
}

/**
* Add controls.
*/
Expand Down Expand Up @@ -42,11 +57,18 @@ private function add_layout_controls() {
)
)
);

$position_default = ( self::is_new_page() || self::is_checkout() ) ? 'full-width' : 'default';

if ( $this->new_skin ) {
$position_default = 'default';
}

$this->add_control(
new Controls\Radio(
'neve_meta_sidebar',
array(
'default' => ( self::is_new_page() || self::is_checkout() ) ? 'full-width' : 'default',
'default' => $position_default,
'choices' => array(
'default' => __( 'Customizer Setting', 'neve' ),
'left' => __( 'Left Sidebar', 'neve' ),
Expand Down Expand Up @@ -120,11 +142,19 @@ private function add_content_toggles() {
* Add content width control.
*/
private function add_content_width() {

$enabled_default = ( self::is_new_page() || self::is_checkout() ) ? 'on' : 'off';
$width_default = ( self::is_new_page() || self::is_checkout() ) ? 100 : 70;
if ( $this->new_skin ) {
$enabled_default = 'off';
$width_default = self::is_post() ? 70 : 100;
}

$this->add_control(
new Controls\Checkbox(
'neve_meta_enable_content_width',
array(
'default' => ( self::is_new_page() || self::is_checkout() ) ? 'on' : 'off',
'default' => $enabled_default,
'label' => __( 'Content Width', 'neve' ) . ' (%)',
'input_label' => __( 'Enable Individual Content Width', 'neve' ),
'priority' => 50,
Expand All @@ -135,7 +165,7 @@ private function add_content_width() {
new Controls\Range(
'neve_meta_content_width',
array(
'default' => ( self::is_new_page() || self::is_checkout() ) ? 100 : 70,
'default' => $width_default,
'min' => 50,
'max' => 100,
'hidden' => self::hide_content_width(),
Expand Down Expand Up @@ -257,4 +287,26 @@ public static function is_checkout() {

return false;
}

/**
* Check if is post.
*/
public static function is_post() {
global $pagenow;

// New post.
if ( $pagenow === 'post-new.php' && ! isset( $_GET['post_type'] ) ) {
return true;
}

if ( ! isset( $_GET['post'] ) ) {
return false;
}

if ( get_post_type( absint( $_GET['post'] ) ) === 'post' ) {
return true;
}

return false;
}
}
17 changes: 14 additions & 3 deletions inc/admin/metabox/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Neve\Core\Settings\Config;
use Neve\Core\Settings\Mods;
use Neve\Customizer\Defaults\Layout;
use Neve\Customizer\Defaults\Single_Post;
use Neve\Customizer\Options\Layout_Single_Post;
use Neve\Views\Post_Layout;
Expand All @@ -20,6 +21,7 @@
*/
final class Manager {
use Single_Post;
use Layout;

/**
* Control instances.
Expand Down Expand Up @@ -375,9 +377,14 @@ public function meta_sidebar_script_enqueue() {
$container = $post_type === 'post' ? Mods::get( Config::MODS_SINGLE_POST_CONTAINER_STYLE, 'contained' ) : Mods::get( Config::MODS_DEFAULT_CONTAINER_STYLE, 'contained' );
$editor_width = Mods::get( Config::MODS_CONTAINER_WIDTH );

$advanced_layout = Mods::get( Config::MODS_ADVANCED_LAYOUT_OPTIONS );
$single_width = $post_type === 'post' ? Mods::get( Config::MODS_SINGLE_CONTENT_WIDTH, 70 ) : Mods::get( Config::MODS_OTHERS_CONTENT_WIDTH, 70 );
$content_width = $advanced_layout ? $single_width : Mods::get( Config::MODS_SITEWIDE_CONTENT_WIDTH, 70 );
$advanced_layout = Mods::get( Config::MODS_ADVANCED_LAYOUT_OPTIONS, neve_is_new_skin() );

$single_width = $post_type === 'post' ?
Mods::get( Config::MODS_SINGLE_CONTENT_WIDTH, $this->sidebar_layout_width_default( Config::MODS_SINGLE_CONTENT_WIDTH ) ) :
Mods::get( Config::MODS_OTHERS_CONTENT_WIDTH, $this->sidebar_layout_width_default( Config::MODS_OTHERS_CONTENT_WIDTH ) );
$content_width = $advanced_layout ?
$single_width :
Mods::get( Config::MODS_SITEWIDE_CONTENT_WIDTH, $this->sidebar_layout_width_default( Config::MODS_SITEWIDE_CONTENT_WIDTH ) );

$editor_width = isset( $editor_width['desktop'] ) ? (int) $editor_width['desktop'] : 1170;

Expand Down Expand Up @@ -459,6 +466,10 @@ private function get_author_avatar_state() {
* @param \WP_Post $post Post object.
*/
public function set_page_width( $post_id, $post ) {
if ( neve_is_new_skin() ) {
return;
}

$parent_id = wp_is_post_revision( $post_id );
if ( $parent_id ) {
$post_id = $parent_id;
Expand Down
22 changes: 12 additions & 10 deletions inc/compatibility/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use HFG\Core\Components\CartIcon;
use HFG\Core\Magic_Tags;
use Neve\Core\Settings\Config;
use Neve\Customizer\Defaults\Layout;
use Neve\Views\Layouts\Layout_Sidebar;

/**
Expand All @@ -20,6 +21,8 @@
*/
class Woocommerce {

use Layout;

/**
* Primary button selectors.
*
Expand Down Expand Up @@ -725,17 +728,16 @@ private function should_render_sidebar_toggle() {
if ( ! is_active_sidebar( 'shop-sidebar' ) ) {
return false;
}
if ( is_shop() ) {
$theme_mod = apply_filters( 'neve_sidebar_position', get_theme_mod( 'neve_shop_archive_sidebar_layout', 'right' ) );
if ( $theme_mod !== 'right' && $theme_mod !== 'left' ) {
return false;
}
}

$mod = 'neve_shop_archive_sidebar_layout';
if ( is_product() ) {
$theme_mod = apply_filters( 'neve_sidebar_position', get_theme_mod( 'neve_single_product_sidebar_layout', 'right' ) );
if ( $theme_mod !== 'right' && $theme_mod !== 'left' ) {
return false;
}
$mod = 'neve_single_product_sidebar_layout';
}

$default = $this->sidebar_layout_alignment_default( $mod );
$theme_mod = apply_filters( 'neve_sidebar_position', get_theme_mod( $mod, $default ) );
if ( $theme_mod !== 'right' && $theme_mod !== 'left' ) {
return false;
}

return true;
Expand Down
Loading