Skip to content

Commit

Permalink
Quality: remove unused allowSides prop (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano authored Oct 20, 2024
1 parent 84ed103 commit 51915ec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 55 deletions.
29 changes: 13 additions & 16 deletions src/controls/border-color-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type Props = {
bottom?: Property.BorderBottomColor;
left?: Property.BorderLeftColor;
};
allowSides?: boolean;
hasIndicator?: boolean;
};

Expand All @@ -56,17 +55,18 @@ export default function BorderColorControl( {
help,
onChange,
values: valuesProp,
allowSides = true,
hasIndicator = true,
}: Props ) {
const values = {
...DEFAULT_VALUES,
...valuesProp,
};

const isMixed: boolean =
allowSides &&
! ( values.top === values.right && values.top === values.bottom && values.top === values.left );
const isMixed: boolean = ! (
values.top === values.right &&
values.top === values.bottom &&
values.top === values.left
);

const colors = useSelect( ( select ) => {
const settings = select(
Expand Down Expand Up @@ -132,7 +132,7 @@ export default function BorderColorControl( {
</div>
<div className="ftb-border-color-control__controls">
<div className="ftb-border-color-control__controls-inner">
{ ( isLinked || ! allowSides ) && (
{ isLinked && (
<div className="ftb-border-color-control__controls-row">
{ hasIndicator && <SideIndicatorControl /> }
<Button
Expand Down Expand Up @@ -166,7 +166,6 @@ export default function BorderColorControl( {
</div>
) }
{ ! isLinked &&
allowSides &&
SIDE_CONTROLS.map( ( item, index ) => (
<div className="ftb-border-color-control__controls-row" key={ index }>
{ hasIndicator && <SideIndicatorControl sides={ [ item.value ] } /> }
Expand Down Expand Up @@ -196,15 +195,13 @@ export default function BorderColorControl( {
</div>
) ) }
</div>
{ allowSides && (
<Button
className="ftb-border-color-control__header-linked-button"
label={ linkedLabel }
onClick={ toggleLinked }
icon={ isLinked ? link : linkOff }
size="small"
/>
) }
<Button
className="ftb-border-color-control__header-linked-button"
label={ linkedLabel }
onClick={ toggleLinked }
icon={ isLinked ? link : linkOff }
size="small"
/>
</div>
</div>
</BaseControl>
Expand Down
14 changes: 5 additions & 9 deletions src/controls/border-radius-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Props = {
bottomRight?: Property.BorderBottomRightRadius;
bottomLeft?: Property.BorderBottomLeftRadius;
};
allowSides?: boolean;
hasIndicator?: boolean;
};

Expand All @@ -56,21 +55,18 @@ export default function BorderRadiusControl( {
help,
onChange,
values: valuesProp,
allowSides = true,
hasIndicator = true,
}: Props ) {
const values = {
...DEFAULT_VALUES,
...valuesProp,
};

const isMixed: boolean =
allowSides &&
! (
values.topLeft === values.topRight &&
values.topLeft === values.bottomRight &&
values.topLeft === values.bottomLeft
);
const isMixed: boolean = ! (
values.topLeft === values.topRight &&
values.topLeft === values.bottomRight &&
values.topLeft === values.bottomLeft
);

const borderRadiusUnits = useCustomUnits( { availableUnits: BORDER_RADIUS_UNITS } );

Expand Down
23 changes: 9 additions & 14 deletions src/controls/border-spacing-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Props = {
help?: string;
onChange: ( event: any ) => void;
values: typeof DEFAULT_VALUES;
allowSides?: boolean;
hasIndicator?: boolean;
};

Expand All @@ -44,15 +43,14 @@ export default function BorderSpacingControl( {
help,
onChange,
values: valuesProp,
allowSides = true,
hasIndicator = true,
}: Props ) {
const values = {
...DEFAULT_VALUES,
...valuesProp,
};

const isMixed: boolean = allowSides && ! ( values.horizontal === values.vertical );
const isMixed: boolean = ! ( values.horizontal === values.vertical );

const borderSpacingUnits = useCustomUnits( { availableUnits: BORDER_SPACING_UNITS } );

Expand Down Expand Up @@ -125,7 +123,7 @@ export default function BorderSpacingControl( {
</div>
<div className="ftb-border-spacing-control__controls">
<div className="ftb-border-spacing-control__controls-inner">
{ ( isLinked || ! allowSides ) && (
{ isLinked && (
<div className="ftb-border-spacing-control__controls-row">
{ hasIndicator && <DirectionIndicatorControl /> }
<UnitControl
Expand All @@ -139,7 +137,6 @@ export default function BorderSpacingControl( {
</div>
) }
{ ! isLinked &&
allowSides &&
DIRECTION_CONTROLS.map( ( item, index ) => (
<div className="ftb-border-spacing-control__controls-row" key={ index }>
{ hasIndicator && <DirectionIndicatorControl directions={ [ item.value ] } /> }
Expand All @@ -154,15 +151,13 @@ export default function BorderSpacingControl( {
</div>
) ) }
</div>
{ allowSides && (
<Button
className="ftb-border-spacing-control__header-linked-button"
label={ linkedLabel }
icon={ isLinked ? link : linkOff }
onClick={ toggleLinked }
size="small"
/>
) }
<Button
className="ftb-border-spacing-control__header-linked-button"
label={ linkedLabel }
icon={ isLinked ? link : linkOff }
onClick={ toggleLinked }
size="small"
/>
</div>
</div>
</BaseControl>
Expand Down
30 changes: 14 additions & 16 deletions src/controls/padding-control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Props = {
bottom?: Property.PaddingBottom;
left?: Property.PaddingLeft;
};
allowSides?: boolean;
hasIndicator?: boolean;
};

Expand All @@ -55,14 +54,15 @@ export default function PaddingControl( {
help,
onChange,
values: valuesProp,
allowSides = true,
hasIndicator = true,
}: Props ) {
const values = { ...DEFAULT_VALUES, ...valuesProp };

const isMixed: boolean =
allowSides &&
! ( values.top === values.right && values.top === values.bottom && values.top === values.left );
const isMixed: boolean = ! (
values.top === values.right &&
values.top === values.bottom &&
values.top === values.left
);

const paddingUnits = useCustomUnits( { availableUnits: PADDING_UNITS } );

Expand Down Expand Up @@ -121,7 +121,7 @@ export default function PaddingControl( {
{ hasIndicator && (
<SideIndicatorControl sides={ side === undefined ? undefined : [ side ] } />
) }
{ ( isLinked || ! allowSides ) && (
{ isLinked && (
<UnitControl
placeholder={ allInputPlaceholder }
aria-label={ __( 'All', 'flexible-table-block' ) }
Expand All @@ -131,17 +131,15 @@ export default function PaddingControl( {
size="__unstable-large"
/>
) }
{ allowSides && (
<Button
className="ftb-padding-control__header-linked-button"
label={ linkedLabel }
onClick={ toggleLinked }
icon={ isLinked ? link : linkOff }
size="small"
/>
) }
<Button
className="ftb-padding-control__header-linked-button"
label={ linkedLabel }
onClick={ toggleLinked }
icon={ isLinked ? link : linkOff }
size="small"
/>
</div>
{ ! isLinked && allowSides && (
{ ! isLinked && (
<div className="ftb-padding-control__input-controls">
{ SIDE_CONTROLS.map( ( item ) => (
<UnitControl
Expand Down

0 comments on commit 51915ec

Please sign in to comment.