Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Unbundle wp.components #5753

Merged
merged 11 commits into from
Dec 21, 2020
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
17 changes: 14 additions & 3 deletions client/profile-wizard/steps/store-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CardBody,
CardFooter,
CheckboxControl,
FlexItem,
FlexItem as MaybeFlexItem,
__experimentalText as Text,
Popover,
} from '@wordpress/components';
Expand All @@ -32,6 +32,17 @@ import UsageModal from '../usage-modal';
import { CurrencyContext } from '../../../lib/currency-context';
import './style.scss';

// FlexItem is not available until WP version 5.5. This code is safe to remove
// once the minimum WP supported version becomes 5.5.
const FlextItemSubstitute = ( { children, align } ) => {
const style = {
display: 'flex',
'justify-content': align ? 'center' : 'flex-start',
};
return <div style={ style }>{ children }</div>;
};
const FlexItem = MaybeFlexItem || FlextItemSubstitute;

class StoreDetails extends Component {
constructor( props ) {
super( props );
Expand Down Expand Up @@ -271,7 +282,7 @@ class StoreDetails extends Component {
</CardBody>

<CardFooter>
<FlexItem align="center">
<FlexItem>
<div className="woocommerce-profile-wizard__client">
<CheckboxControl
label={ __(
Expand All @@ -285,7 +296,7 @@ class StoreDetails extends Component {
</CardFooter>

<CardFooter justify="center">
<FlexItem>
<FlexItem align="center">
<div className="woocommerce-profile-wizard__submit">
<Button
isPrimary
Expand Down
7 changes: 3 additions & 4 deletions client/stylesheets/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


// Import our wp-admin reset.
@import './shared/_reset.scss';

Expand Down Expand Up @@ -30,5 +28,6 @@
// Import the embed-specific styles.
@import './shared/_embed.scss';

// Import gutenberg SCSS so that we can apply our theme colors.
@import './shared/gutenberg-components.scss';
:root {
@include admin-scheme( #007cba );
}
28 changes: 0 additions & 28 deletions client/stylesheets/shared/_gutenberg-components.scss

This file was deleted.

16 changes: 14 additions & 2 deletions packages/components/src/date-range-filter-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Dropdown } from '@wordpress/components';
import PropTypes from 'prop-types';
import { withViewportMatch } from '@wordpress/viewport';
import classnames from 'classnames';

/**
* Internal dependencies
Expand Down Expand Up @@ -122,13 +124,21 @@ class DateRangeFilterPicker extends Component {
afterError,
beforeError,
} = this.state;

const { isViewportMobile } = this.props;
const contentClasses = classnames(
'woocommerce-filters-date__content',
{
'is-mobile': isViewportMobile,
}
);
return (
<div className="woocommerce-filters-filter">
<span className="woocommerce-filters-label">
{ __( 'Date Range', 'woocommerce-admin' ) }:
</span>
<Dropdown
contentClassName="woocommerce-filters-date__content"
contentClassName={ contentClasses }
position="bottom"
expandOnMobile
renderToggle={ ( { isOpen, onToggle } ) => (
Expand Down Expand Up @@ -187,4 +197,6 @@ DateRangeFilterPicker.propTypes = {
} ).isRequired,
};

export default DateRangeFilterPicker;
export default withViewportMatch( {
isViewportMobile: '< medium',
} )( DateRangeFilterPicker );
4 changes: 4 additions & 0 deletions packages/components/src/date-range-filter-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
overflow: auto;
}
}

&.components-dropdown__content .components-popover__content > div {
padding: 0;
}
}

.woocommerce-filters-date__tabs {
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/summary/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ $border: $gray-200;
border-color: $border;
background-color: $gray-100;
box-shadow: inset -1px -1px 0 $border;
width: 100%;

@include breakpoint( '<782px' ) {
& {
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
=== WooCommerce Admin ===
Contributors: woocommerce, automattic
Tags: ecommerce, e-commerce, store, sales, reports, analytics, dashboard, activity, notices, insights, stats, woo commerce, woocommerce
Requires at least: 5.3.0
Tested up to: 5.4.2
Requires at least: 5.4.0
Tested up to: 5.6.0
Requires PHP: 5.6.20
Stable tag: 1.8.0-dev
License: GPLv3
Expand Down
34 changes: 33 additions & 1 deletion src/Features/Navigation/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,45 @@ public function __construct() {
}
}

/**
* Determine if sufficient versions are present to support Navigation feature
*/
public function is_nav_compatible() {
include_once ABSPATH . 'wp-admin/includes/plugin.php';

$gutenberg_minimum_version = '9.0.0'; // https://github.com/WordPress/gutenberg/releases/tag/v9.0.0.
$wp_minimum_version = '5.6';
$has_gutenberg = is_plugin_active( 'gutenberg/gutenberg.php' );
$gutenberg_version = $has_gutenberg ? get_plugin_data( WP_PLUGIN_DIR . '/gutenberg/gutenberg.php' )['Version'] : false;

if ( $gutenberg_version && version_compare( $gutenberg_version, $gutenberg_minimum_version, '>=' ) ) {
return true;
}

// Get unmodified $wp_version.
include ABSPATH . WPINC . '/version.php';

// Strip '-src' from the version string. Messes up version_compare().
$wp_version = str_replace( '-src', '', $wp_version );

if ( version_compare( $wp_version, $wp_minimum_version, '>=' ) ) {
return true;
}

return false;
}

/**
* Overwrites the allowed features array using a local `feature-config.php` file.
*
* @param array $features Array of feature slugs.
*/
public function maybe_remove_nav_feature( $features ) {
if ( in_array( 'navigation', $features, true ) && 'yes' !== get_option( 'woocommerce_navigation_enabled', 'no' ) ) {
$has_feature_enabled = in_array( 'navigation', $features, true );
$has_option_disabled = 'yes' !== get_option( 'woocommerce_navigation_enabled', 'no' );
$is_not_compatible = ! self::is_nav_compatible();

if ( ( $has_feature_enabled && $has_option_disabled ) || $is_not_compatible ) {
$features = array_diff( $features, array( 'navigation' ) );
}
return $features;
Expand Down
6 changes: 4 additions & 2 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public static function register_scripts() {
wp_register_script(
'wc-navigation',
self::get_url( 'navigation/index', 'js' ),
array( 'wp-url', 'wp-hooks', 'wp-element', 'wp-data', 'moment' ),
array( 'wp-url', 'wp-hooks', 'wp-element', 'wp-data', 'moment', 'wp-components' ),
$js_file_version,
true
);
Expand Down Expand Up @@ -454,6 +454,7 @@ public static function register_scripts() {
'wc-notices',
'wc-number',
'wc-store-data',
'wp-components',
),
$js_file_version,
true
Expand Down Expand Up @@ -490,6 +491,7 @@ public static function register_scripts() {
self::get_url( 'app/index', 'js' ),
array(
'wp-core-data',
'wp-components',
'wc-components',
'wp-date',
'wp-plugins',
Expand All @@ -516,7 +518,7 @@ public static function register_scripts() {
wp_register_style(
WC_ADMIN_APP,
self::get_url( "app/style{$rtl}", 'css' ),
array( 'wc-components', 'wc-customer-effort-score' ),
array( 'wc-components', 'wc-customer-effort-score', 'wp-components' ),
$css_file_version
);

Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const externals = {
'@wordpress/i18n': { this: [ 'wp', 'i18n' ] },
'@wordpress/data-controls': { this: [ 'wp', 'dataControls' ] },
'@wordpress/plugins': { this: [ 'wp', 'plugins' ] },
'@wordpress/components': { this: [ 'wp', 'components' ] },
'@wordpress/date': { this: [ 'wp', 'date' ] },
'@wordpress/compose': { this: [ 'wp', 'compose' ] },
tinymce: 'tinymce',
moment: 'moment',
react: 'React',
Expand Down