Skip to content

Commit

Permalink
Components: Remove unnecessary utils (#53679)
Browse files Browse the repository at this point in the history
* Components: Remove unnecessary utils

* Add CHANGELOG entry
  • Loading branch information
tyxla authored Aug 18, 2023
1 parent 6e9b902 commit 1d6368a
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 386 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- `ControlGroup`, `FormGroup`, `ControlLabel`, `Spinner`: Remove unused `ui/` components from the codebase ([#52953](https://github.com/WordPress/gutenberg/pull/52953)).
- `MenuItem`: Convert to TypeScript ([#53132](https://github.com/WordPress/gutenberg/pull/53132)).
- `MenuGroup`: Add Storybook stories ([#53090](https://github.com/WordPress/gutenberg/pull/53090)).
- Components: Remove unnecessary utils ([#53679](https://github.com/WordPress/gutenberg/pull/53679)).

## 25.5.0 (2023-08-10)

Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/color-palette/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import {
extractColorNameFromCurrentValue,
showTransparentBackground,
normalizeColorValue,
} from '../utils';

Expand All @@ -25,20 +24,6 @@ describe( 'ColorPalette: Utils', () => {
expect( result ).toBe( 'Blue' );
} );
} );
describe( 'showTransparentBackground', () => {
test( 'should return true for undefined color values', () => {
expect( showTransparentBackground( undefined ) ).toBe( true );
} );
test( 'should return true for transparent colors', () => {
expect( showTransparentBackground( 'transparent' ) ).toBe( true );
expect( showTransparentBackground( '#75757500' ) ).toBe( true );
} );
test( 'should return false for non-transparent colors', () => {
expect( showTransparentBackground( '#FFF' ) ).toBe( false );
expect( showTransparentBackground( '#757575' ) ).toBe( false );
expect( showTransparentBackground( '#f5f5f524' ) ).toBe( false ); // 0.14 alpha.
} );
} );

describe( 'normalizeColorValue', () => {
test( 'should return the value as is if the color value is not a CSS variable', () => {
Expand Down
7 changes: 0 additions & 7 deletions packages/components/src/color-palette/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ export const extractColorNameFromCurrentValue = (
return __( 'Custom' );
};

export const showTransparentBackground = ( currentValue?: string ) => {
if ( typeof currentValue === 'undefined' ) {
return true;
}
return colord( currentValue ).alpha() === 0;
};

// The PaletteObject type has a `colors` property (an array of ColorObject),
// while the ColorObject type has a `color` property (the CSS color value).
export const isMultiplePaletteObject = (
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/ui/context/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export const REACT_TYPEOF_KEY = '$$typeof';
export const COMPONENT_NAMESPACE = 'data-wp-component';
export const CONNECTED_NAMESPACE = 'data-wp-c16t';
export const CONTEXT_COMPONENT_NAMESPACE = 'data-wp-c5tc8t';

/**
* Special key where the connected namespaces are stored.
Expand Down
20 changes: 0 additions & 20 deletions packages/components/src/ui/utils/get-high-dpi.ts

This file was deleted.

36 changes: 0 additions & 36 deletions packages/components/src/utils/browsers.js

This file was deleted.

50 changes: 0 additions & 50 deletions packages/components/src/utils/events.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/components/src/utils/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,3 @@ export function roundClamp(
? getNumber( clampedValue.toFixed( precision ) )
: clampedValue;
}

/**
* Clamps a value based on a min/max range with rounding.
* Returns a string.
*
* @param {Parameters<typeof roundClamp>} args Arguments for roundClamp().
* @return {string} The rounded and clamped value.
*/
export function roundClampString( ...args ) {
return roundClamp( ...args ).toString();
}
63 changes: 0 additions & 63 deletions packages/components/src/utils/test/events.js

This file was deleted.

101 changes: 0 additions & 101 deletions packages/components/src/utils/test/values.js

This file was deleted.

Loading

1 comment on commit 1d6368a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 1d6368a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5900537822
📝 Reported issues:

Please sign in to comment.