Skip to content

Commit

Permalink
remove ColorStopAndValue abstraction (#49588)
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 authored Apr 5, 2023
1 parent 88e3d88 commit 89d5743
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
8 changes: 2 additions & 6 deletions packages/components/src/custom-gradient-picker/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
* External dependencies
*/
import type gradientParser from 'gradient-parser';
/**
* Internal dependencies
*/
import type { ColorStopTypeAndValue } from './types';

export function serializeGradientColor( {
type,
value,
}: ColorStopTypeAndValue ) {
}: gradientParser.ColorStop ) {
if ( type === 'literal' ) {
return value;
}
Expand Down Expand Up @@ -38,7 +34,7 @@ export function serializeGradientColorStop( {
return `${ serializeGradientColor( {
type,
value,
} as ColorStopTypeAndValue ) } ${ serializeGradientPosition( length ) }`;
} as gradientParser.ColorStop ) } ${ serializeGradientPosition( length ) }`;
}

export function serializeGradientOrientation(
Expand Down
18 changes: 0 additions & 18 deletions packages/components/src/custom-gradient-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,6 @@ export type GradientTypePickerProps = {

export type ControlPoint = { color: string; position: number };

// When dealing with unions of objects, using `Pick` will result
// in a new type where each desired prop is a union of the values for that prop
// across all of the original union members. This does not maintain the specific
// combinations of props present in the original union.
// To avoid this, the `DistributivePick` type will
// "distribute" the `Pick` across the union. This allows the `Pick`
// to act on each member individually, maintaining the relationships between the
// resulting props.
// https://stackoverflow.com/questions/57103834/typescript-omit-a-property-from-all-interfaces-in-a-union-but-keep-the-union-s
type DistributivePick< T, K extends keyof T > = T extends any
? Pick< T, K >
: never;

export type ColorStopTypeAndValue = DistributivePick<
gradientParser.ColorStop,
'type' | 'value'
>;

export type CustomGradientBarProps = {
background: React.CSSProperties[ 'background' ];
hasGradient: boolean;
Expand Down

1 comment on commit 89d5743

@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 89d5743.
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/4615985250
📝 Reported issues:

Please sign in to comment.