Skip to content

Commit

Permalink
Switch BorderBoxControl to use StyledLabel as legend element
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Jul 14, 2022
1 parent f7ed197 commit ba8a734
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import BorderBoxControlLinkedButton from '../border-box-control-linked-button';
import BorderBoxControlSplitControls from '../border-box-control-split-controls';
import { BorderControl } from '../../border-control';
import { HStack } from '../../h-stack';
import { StyledLabel } from '../../base-control/styles/base-control-styles';
import { View } from '../../view';
import { VisuallyHidden } from '../../visually-hidden';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
Expand All @@ -21,7 +22,7 @@ import type { BorderBoxControlProps } from '../types';
import type { LabelProps } from '../../border-control/types';

const BorderLabel = ( props: LabelProps ) => {
const { className, label, hideLabelFromVision } = props;
const { label, hideLabelFromVision } = props;

if ( ! label ) {
return null;
Expand All @@ -30,7 +31,7 @@ const BorderLabel = ( props: LabelProps ) => {
return hideLabelFromVision ? (
<VisuallyHidden as="legend">{ label }</VisuallyHidden>
) : (
<legend className={ className }>{ label }</legend>
<StyledLabel as="legend">{ label }</StyledLabel>
);
};

Expand All @@ -39,7 +40,6 @@ const BorderBoxControl = (
forwardedRef: React.ForwardedRef< any >
) => {
const {
borderLabelClassName,
className,
colors,
disableCustomColors,
Expand Down Expand Up @@ -83,7 +83,6 @@ const BorderBoxControl = (
<BorderLabel
label={ label }
hideLabelFromVision={ hideLabelFromVision }
className={ borderLabelClassName }
/>
<HStack alignment={ 'start' } expanded={ true } spacing={ 0 }>
{ isLinked ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,12 @@ export function useBorderBoxControl(
return cx( styles.BorderBoxControl, className );
}, [ cx, className ] );

const borderLabelClassName = useMemo( () => {
return cx( styles.borderLabel );
}, [ cx ] );

const linkedControlClassName = useMemo( () => {
return cx( styles.LinkedBorderControl );
}, [ cx ] );

return {
...otherProps,
borderLabelClassName,
className: classes,
hasMixedBorders: mixedBorders,
isLinked,
Expand Down
5 changes: 0 additions & 5 deletions packages/components/src/border-box-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,3 @@ export const CenteredBorderControl = css`
export const rightBorderControl = () => css`
${ rtl( { marginLeft: 'auto' }, { marginRight: 'auto' } )() }
`;

export const borderLabel = css`
display: inline-block;
margin-bottom: ${ space( 2 ) };
`;

0 comments on commit ba8a734

Please sign in to comment.