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

Add __unstable-large size variant on InputControl SelectControl UnitControl #35646

Merged
merged 27 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
56572c2
InputControl: Increase `default` size to 40px
mirka Oct 14, 2021
9720b37
InputControl: Flex `Suffix` for simpler alignment
mirka Oct 14, 2021
da29622
AnglePickerControl: Fix degree symbol alignment
mirka Oct 14, 2021
54b3920
BoxControl: Default to `small` inputs
mirka Oct 14, 2021
0608091
ColorPicker: Remove adhoc height
mirka Oct 19, 2021
f5c81c1
ColorPicker: Widen controls to work on mobile
mirka Oct 20, 2021
24cf17e
SelectControl: Increase `default` size to 40px
mirka Oct 19, 2021
9b1ffb2
CustomGradientPicker: Remove adhoc height
mirka Oct 19, 2021
40d3765
UnitControl: Align units
mirka Oct 19, 2021
a05caf7
RangeControl: Increase height to 40px
mirka Oct 19, 2021
eb0cc2d
RangeControl: Widen input to allow 3 digits
mirka Nov 2, 2021
47a5113
Add changelog entry
mirka Nov 2, 2021
190681d
Revert "RangeControl: Widen input to allow 3 digits"
mirka Nov 3, 2021
914094b
InputControl: Extract style changes to `unstable-large` variant
mirka Nov 3, 2021
db8dcbc
Revert "RangeControl: Increase height to 40px"
mirka Nov 3, 2021
08ec362
Revert "BoxControl: Default to `small` inputs"
mirka Nov 3, 2021
f24ffc9
SelectControl: Add `__unstable-large` variant
mirka Nov 3, 2021
e603f51
UnitControl: Add `__unstable-large` variant
mirka Nov 3, 2021
06b91c4
AnglePickerControl: Set to `__unstable-large`
mirka Nov 3, 2021
cee69a8
CustomGradientPicker: Set to `__unstable-large`
mirka Nov 3, 2021
b5974d4
RangeControl: Tweak specificity to work as before
mirka Nov 3, 2021
3f4dd50
Revert "ColorPicker: Remove adhoc height"
mirka Nov 4, 2021
345da0b
Revert "ColorPicker: Widen controls to work on mobile"
mirka Nov 4, 2021
1dd69a4
Update changelog
mirka Nov 4, 2021
8376cf0
InputControl: Revert default height back to 30px
mirka Nov 4, 2021
6227b6a
Revert "RangeControl: Tweak specificity to work as before"
mirka Nov 4, 2021
0896a65
Merge branch 'trunk' into enlarge-input-controls
mirka Nov 19, 2021
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 @@ -5,6 +5,7 @@
### Experimental

- Updated the `ToolsPanel` to use `Grid` internally to manage panel layout ([35621](https://github.com/WordPress/gutenberg/pull/35621)).
- Enlarged the `default` size variant of `InputControl` to the new 40px design. `AnglePickerControl`, `BoxControl`, `ColorPicker`, `CustomGradientPicker`, `RangeControl`, `SelectControl`, and `UnitControl` were also slightly modified (either visually or internally) to accommodate this change ([#35646](https://github.com/WordPress/gutenberg/pull/35646)).

## 19.0.0 (2021-10-22)

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/angle-picker-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default function AnglePickerControl( {
suffix={
<Spacer
as={ Text }
marginBottom={ 0 }
marginRight={ space( 3 ) }
style={ {
color: 'var( --wp-admin-theme-color )',
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/box-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { useControlledState } from '../utils/hooks';

const defaultInputProps = {
min: 0,
size: 'small',
};

function useUniqueId( idProp ) {
Expand Down
14 changes: 2 additions & 12 deletions packages/components/src/color-picker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const NumberControlWrapper = styled( NumberControl )`

export const SelectControl = styled( InnerSelectControl )`
margin-left: ${ space( -2 ) };
width: 5em;
width: 6.5em;
${ BackdropUI } {
display: none;
}
Expand All @@ -42,14 +42,6 @@ export const RangeControl = styled( InnerRangeControl )`
}
`;

// All inputs should be the same height so this should be changed at the component level.
// That involves changing heights of multiple input types probably buttons too etc.
// So until that is done we are already using the new height on the color picker so it matches the mockups.
const inputHeightStyle = `
&&& ${ Input } {
height: 40px;
}`;

// Make the Hue circle picker not go out of the bar
const interactiveHueStyles = `
.react-colorful__interactive {
Expand Down Expand Up @@ -107,8 +99,6 @@ export const ColorfulWrapper = styled.div`
${ StyledField } {
margin-bottom: 0;
}

${ inputHeightStyle }
`;

export const DetailsControlButton = styled( Button )`
Expand All @@ -119,5 +109,5 @@ export const DetailsControlButton = styled( Button )`
`;

export const ColorHexInputControl = styled( InputControl )`
width: 8em;
width: 9em;
`;
4 changes: 0 additions & 4 deletions packages/components/src/custom-gradient-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1

// All these styles should be made generic and changed on the inputs for all components.
.components-custom-gradient-picker {
.components-select-control__input,
.components-input-control__input {
height: 40px !important;
}
.components-input-control__label {
line-height: 1;
padding-bottom: $grid-unit-10 !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ const fontSizeStyles = ( { inputSize: size }: InputProps ) => {
const sizeStyles = ( { inputSize: size }: InputProps ) => {
const sizes = {
default: {
height: 30,
height: 40,
lineHeight: 1,
minHeight: 30,
minHeight: 40,
paddingLeft: 16,
paddingRight: 16,
},
small: {
height: 24,
lineHeight: 1,
minHeight: 24,
paddingLeft: 8,
paddingRight: 8,
},
};

Expand Down Expand Up @@ -205,8 +209,6 @@ export const Input = styled.input< InputProps >`
display: block;
margin: 0;
outline: none;
padding-left: 8px;
padding-right: 8px;
width: 100%;

${ dragStyles }
Expand Down Expand Up @@ -315,6 +317,8 @@ export const Prefix = styled.span`
`;

export const Suffix = styled.span`
align-items: center;
align-self: stretch;
box-sizing: border-box;
display: block;
display: flex;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import NumberControl from '../../number-control';
import { COLORS, reduceMotion, rtl } from '../../utils';
import { space } from '../../ui/utils/space';

const rangeHeightValue = 30;
const rangeHeightValue = 40;
const railHeight = 4;
const rangeHeight = () =>
css( { height: rangeHeightValue, minHeight: rangeHeightValue } );
Expand Down Expand Up @@ -298,7 +298,7 @@ export const InputNumber = styled( NumberControl )`
display: inline-block;
font-size: 13px;
margin-top: 0;
width: ${ space( 16 ) } !important;
width: ${ space( 20 ) } !important;

input[type='number']& {
${ rangeHeight };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const fontSizeStyles = ( { selectSize }: SelectProps ) => {
const sizeStyles = ( { selectSize }: SelectProps ) => {
const sizes = {
default: {
height: 30,
height: 40,
lineHeight: 1,
minHeight: 30,
minHeight: 40,
},
small: {
height: 24,
Expand All @@ -62,6 +62,20 @@ const sizeStyles = ( { selectSize }: SelectProps ) => {
return css( style );
};

const sizePaddings = ( { selectSize = 'default' }: SelectProps ) => {
const sizes = {
default: {
paddingLeft: 16,
paddingRight: 32,
},
small: {
paddingLeft: 8,
paddingRight: 24,
},
};
return rtl( sizes[ selectSize ] );
};

// TODO: Resolve need to use &&& to increase specificity
// https://github.com/WordPress/gutenberg/issues/18483

Expand All @@ -80,8 +94,7 @@ export const Select = styled.select< SelectProps >`
${ disabledStyles };
${ fontSizeStyles };
${ sizeStyles };

${ rtl( { paddingLeft: 8, paddingRight: 24 } ) }
${ sizePaddings };
}
`;

Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/unit-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ export const _default = () => {
return <Example />;
};

export const WithSingleUnit = ( props ) => {
const [ value, setValue ] = useState( '10px' );
return (
<ControlWrapperView>
<UnitControl
{ ...props }
value={ value }
onChange={ ( v ) => setValue( v ) }
/>
</ControlWrapperView>
);
};
WithSingleUnit.args = {
label: 'Value',
units: CSS_UNITS.slice( 0, 1 ),
};

export function WithCustomUnits() {
const [ value, setValue ] = useState( '10km' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,26 @@ type SelectProps = {

type InputProps = {
disableUnits?: boolean;
size: SelectSize;
};

export const Root = styled.div`
box-sizing: border-box;
position: relative;
`;

const paddingStyles = ( { disableUnits }: InputProps ) => {
const value = disableUnits ? 3 : 24;
const paddingStyles = ( { disableUnits, size }: InputProps ) => {
const paddings = {
default: {
paddingRight: disableUnits ? 16 : 8,
},
small: {
paddingRight: 8,
},
};

return css`
${ rtl( { paddingRight: value } )() };
${ rtl( paddings[ size ] )() };
`;
};

Expand Down Expand Up @@ -62,49 +70,24 @@ export const ValueInput = styled( NumberControl )`
}
`;

const unitSizeStyles = ( { selectSize }: SelectProps ) => {
const sizes = {
default: {
height: 28,
lineHeight: '24px',
minHeight: 28,
top: 1,
},
small: {
height: 22,
lineHeight: '18px',
minHeight: 22,
top: 1,
},
};

return css( sizes[ selectSize ] );
};

const baseUnitLabelStyles = ( props: SelectProps ) => {
return css`
appearance: none;
background: transparent;
border-radius: 2px;
border: none;
box-sizing: border-box;
color: ${ COLORS.darkGray[ 500 ] };
display: block;
font-size: 8px;
line-height: 1;
letter-spacing: -0.5px;
outline: none;
padding: 2px 1px;
position: absolute;
text-align-last: center;
text-transform: uppercase;
width: 20px;

${ rtl( { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } )() }
${ rtl( { right: 0 } )() }
${ unitSizeStyles( props ) }
`;
};
const baseUnitLabelStyles = css`
appearance: none;
background: transparent;
border-radius: 2px;
border: none;
box-sizing: border-box;
color: ${ COLORS.darkGray[ 500 ] };
display: block;
font-size: 8px;
letter-spacing: -0.5px;
outline: none;
padding: 2px 1px;
text-align-last: center;
text-transform: uppercase;
width: 20px;

${ rtl( { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } )() }
`;

export const UnitLabel = styled.div< SelectProps >`
&&& {
Expand All @@ -119,6 +102,7 @@ export const UnitSelect = styled.select< SelectProps >`
${ baseUnitLabelStyles };
cursor: pointer;
border: 1px solid transparent;
height: 100%;

&:hover {
background-color: ${ COLORS.lightGray[ 300 ] };
Expand Down