Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnglePickerControl: Add flag to remove bottom margin #43160

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- `UnitControl`: Update unit dropdown design for the large size variant ([#42000](https://github.com/WordPress/gutenberg/pull/42000)).
- `BaseControl`: Add `box-sizing` reset style ([#42889](https://github.com/WordPress/gutenberg/pull/42889)).
- `BoxControl`: Export `applyValueToSides` util function. ([#42733](https://github.com/WordPress/gutenberg/pull/42733/)).
- `AnglePickerControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#43160](https://github.com/WordPress/gutenberg/pull/43160/)).

### Internal

Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/angle-picker-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { Text } from '../text';
import { Spacer } from '../spacer';

export default function AnglePickerControl( {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMarginBottom = false,
className,
label = __( 'Angle' ),
onChange,
Expand All @@ -34,7 +36,11 @@ export default function AnglePickerControl( {
const classes = classnames( 'components-angle-picker-control', className );

return (
<Root className={ classes } gap={ 4 }>
<Root
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
className={ classes }
gap={ 4 }
>
<FlexBlock>
<NumberControl
label={ label }
Expand Down
13 changes: 8 additions & 5 deletions packages/components/src/angle-picker-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import AnglePickerControl from '../';
export default {
title: 'Components/AnglePickerControl',
component: AnglePickerControl,
argTypes: {
__nextHasNoMarginBottom: { control: { type: 'boolean' } },
},
};

const AnglePickerWithState = () => {
const AnglePickerWithState = ( args ) => {
const [ angle, setAngle ] = useState();
return <AnglePickerControl value={ angle } onChange={ setAngle } />;
return (
<AnglePickerControl { ...args } value={ angle } onChange={ setAngle } />
);
};

export const _default = () => {
return <AnglePickerWithState />;
};
export const Default = AnglePickerWithState.bind( {} );
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* External dependencies
*/
import { css } from '@emotion/react';
import styled from '@emotion/styled';

/**
Expand All @@ -14,8 +15,16 @@ import CONFIG from '../../utils/config-values';
const CIRCLE_SIZE = 32;
const INNER_CIRCLE_SIZE = 3;

const deprecatedBottomMargin = ( { __nextHasNoMarginBottom } ) => {
return ! __nextHasNoMarginBottom
? css`
margin-bottom: ${ space( 2 ) };
`
: '';
};

export const Root = styled( Flex )`
margin-bottom: ${ space( 2 ) };
${ deprecatedBottomMargin }
`;

export const CircleRoot = styled.div`
Expand Down