Skip to content

Commit

Permalink
Removes 'classnames' package dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Mar 9, 2020
1 parent 6522d5d commit b58e927
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-polyfill'), 'version' => '615f4ee8a6512c878971d514da8cd9e1');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-polyfill'), 'version' => 'f164b385523b476f93eac22826d995d2');
7 changes: 1 addition & 6 deletions build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
},
"devDependencies": {
"@wordpress/scripts": "^7.1.2",
"classnames": "^2.2.6",
"css-loader": "^3.4.2",
"ignore-emit-webpack-plugin": "^2.0.2",
"mini-css-extract-plugin": "^0.9.0",
Expand Down
4 changes: 2 additions & 2 deletions src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getClassNames } from '../util';
describe( 'sortabrilliant/whatever', () => {
test( 'getClassNames returns aspect ratio class names for iframes with width and height', () => {
const html = '<iframe width="16" height="9"></iframe>';
const expected = 'wp-embed-aspect-16-9 wp-has-aspect-ratio';
expect( getClassNames( html ) ).toEqual( expected );
const expected = 'whatever wp-embed-aspect-16-9 wp-has-aspect-ratio';
expect( getClassNames( html, 'whatever' ) ).toEqual( expected );
} );
} );
14 changes: 5 additions & 9 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import classnames from 'classnames/dedupe';

export const ASPECT_RATIOS = [
// Common video resolutions.
{ ratio: '2.33', className: 'wp-embed-aspect-21-9' },
Expand Down Expand Up @@ -40,10 +35,11 @@ export function getClassNames( html, existingClassNames = '' ) {
) {
const potentialRatio = ASPECT_RATIOS[ ratioIndex ];
if ( aspectRatio >= potentialRatio.ratio ) {
return classnames( existingClassNames, {
[ potentialRatio.className ]: true,
'wp-has-aspect-ratio': true,
} );
return [
existingClassNames,
potentialRatio.className,
'wp-has-aspect-ratio',
].join( ' ' );
}
}
}
Expand Down

0 comments on commit b58e927

Please sign in to comment.