Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 1fbc85a

Browse files
committed
Merge branch 'master' into release/2.7
2 parents 69d0b0a + 4e02035 commit 1fbc85a

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

assets/js/icons/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { default as Icon } from './icon';
22

33
export { default as arrowBack } from './library/arrow-back';
4+
export { default as arrowDownAlt2 } from './library/arrow-down-alt2';
45
export { default as bank } from './library/bank';
56
export { default as barcode } from './library/barcode';
67
export { default as bill } from './library/bill';
@@ -20,6 +21,7 @@ export { default as grid } from './library/grid';
2021
export { default as image } from './library/image';
2122
export { default as list } from './library/list';
2223
export { default as more } from './library/more';
24+
export { default as noAlt } from './library/no-alt';
2325
export { default as notes } from './library/notes';
2426
export { default as notice } from './library/notice';
2527
export { default as radioSelected } from './library/radio-selected';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { SVG } from 'wordpress-components';
5+
import classnames from 'classnames';
6+
7+
const arrowDownAlt2 = ( { className, size, ...extraProps } ) => {
8+
const iconClass = classnames(
9+
'dashicon',
10+
'dashicons-arrow-down-alt2',
11+
className
12+
);
13+
return (
14+
<SVG
15+
xmlns="http://www.w3.org/2000/svg"
16+
viewBox="0 0 20 20"
17+
className={ iconClass }
18+
width={ size }
19+
height={ size }
20+
{ ...extraProps }
21+
>
22+
<path d="M5 6l5 5 5-5 2 1-7 7-7-7z" />
23+
</SVG>
24+
);
25+
};
26+
27+
export default arrowDownAlt2;

assets/js/icons/library/no-alt.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { SVG } from 'wordpress-components';
5+
import classnames from 'classnames';
6+
const noAlt = ( { className, size, ...extraProps } ) => {
7+
const iconClass = classnames(
8+
'dashicon',
9+
'dashicons-arrow-down-alt2',
10+
className
11+
);
12+
return (
13+
<SVG
14+
xmlns="http://www.w3.org/2000/svg"
15+
viewBox="0 0 20 20"
16+
className={ iconClass }
17+
width={ size }
18+
height={ size }
19+
{ ...extraProps }
20+
>
21+
<path d="M14.95 6.46L11.41 10l3.54 3.54-1.41 1.41L10 11.42l-3.53 3.53-1.42-1.42L8.58 10 5.05 6.47l1.42-1.42L10 8.58l3.54-3.53z" />
22+
</SVG>
23+
);
24+
};
25+
26+
export default noAlt;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import {
5+
arrowDownAlt2 as ArrowDownIcon,
6+
noAlt as DismissIcon,
7+
} from '@woocommerce/icons';
8+
import { createElement } from '@wordpress/element';
9+
10+
export default ( { icon, size = 20, className, ...extraProps } ) => {
11+
let Icon = () => null;
12+
switch ( icon ) {
13+
case 'arrow-down-alt2':
14+
Icon = ArrowDownIcon;
15+
break;
16+
case 'no-alt':
17+
Icon = DismissIcon;
18+
break;
19+
}
20+
// can't use JSX here because the Webpack NormalModuleReplacementPlugin
21+
// is unable to parse JSX at that point in the build.
22+
return createElement( Icon, { size, className, ...extraProps } );
23+
};

bin/webpack-helpers.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ const MergeExtractFilesPlugin = require( './merge-extract-files-webpack-plugin'
66
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
77
const ProgressBarPlugin = require( 'progress-bar-webpack-plugin' );
88
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
9+
const { NormalModuleReplacementPlugin } = require( 'webpack' );
910
const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
1011
const chalk = require( 'chalk' );
1112
const { omit } = require( 'lodash' );
1213
const NODE_ENV = process.env.NODE_ENV || 'development';
1314

15+
const dashIconReplacementModule = path.resolve(
16+
__dirname,
17+
'../assets/js/module_replacements/dashicon.js'
18+
);
19+
1420
function findModuleMatch( module, match ) {
1521
if ( module.request && match.test( module.request ) ) {
1622
return true;
@@ -359,6 +365,10 @@ const getMainConfig = ( options = {} ) => {
359365
requestToExternal,
360366
requestToHandle,
361367
} ),
368+
new NormalModuleReplacementPlugin(
369+
/dashicon/,
370+
( result ) => ( result.resource = dashIconReplacementModule )
371+
),
362372
],
363373
resolve,
364374
};
@@ -454,6 +464,10 @@ const getFrontConfig = ( options = {} ) => {
454464
requestToExternal,
455465
requestToHandle,
456466
} ),
467+
new NormalModuleReplacementPlugin(
468+
/dashicon/,
469+
( result ) => ( result.resource = dashIconReplacementModule )
470+
),
457471
],
458472
resolve,
459473
};
@@ -586,6 +600,10 @@ const getPaymentMethodsExtensionConfig = ( options = {} ) => {
586600
requestToExternal,
587601
requestToHandle,
588602
} ),
603+
new NormalModuleReplacementPlugin(
604+
/dashicon/,
605+
( result ) => ( result.resource = dashIconReplacementModule )
606+
),
589607
],
590608
resolve,
591609
};

0 commit comments

Comments
 (0)