Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make RTL styles dynamic functions
  • Loading branch information
ciampo committed May 23, 2022
commit 8930b9f9dc17677bd48b63fe60afadf0db7dd6ef
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export function useBorderBoxControlSplitControls(
// Generate class names.
const cx = useCx();
const classes = useMemo( () => {
return cx( styles.BorderBoxControlSplitControls, className );
return cx( styles.borderBoxControlSplitControls(), className );
}, [ cx, className, rtl.watch() ] );

const centeredClassName = useMemo( () => {
return cx( styles.CenteredBorderControl, className );
}, [ cx, className ] );

const rightAlignedClassName = useMemo( () => {
return cx( styles.RightBorderControl, className );
return cx( styles.rightBorderControl(), className );
}, [ cx, className, rtl.watch() ] );

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function useBorderBoxControlVisualizer(
const cx = useCx();
const classes = useMemo( () => {
return cx(
styles.BorderBoxControlVisualizer( value, __next36pxDefaultSize ),
styles.borderBoxControlVisualizer( value, __next36pxDefaultSize ),
className
);
}, [ cx, className, value, __next36pxDefaultSize, rtl.watch() ] );
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/border-box-control/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const BorderBoxStyleWithFallback = ( border?: Border ) => {
return `${ color } ${ borderStyle } ${ clampedWidth }`;
};

export const BorderBoxControlVisualizer = (
export const borderBoxControlVisualizer = (
borders?: Borders,
__next36pxDefaultSize?: boolean
) => {
Expand All @@ -64,7 +64,7 @@ export const BorderBoxControlVisualizer = (
`;
};

export const BorderBoxControlSplitControls = css`
export const borderBoxControlSplitControls = () => css`
position: relative;
flex: 1;
${ rtl( { marginRight: space( 3 ) }, { marginLeft: space( 3 ) } )() }
Expand All @@ -75,6 +75,6 @@ export const CenteredBorderControl = css`
margin: 0 auto;
`;

export const RightBorderControl = css`
export const rightBorderControl = () => css`
${ rtl( { marginLeft: 'auto' }, { marginRight: 'auto' } )() }
`;