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

MenuItem: Add right padding for unchecked radio and checkbox items #34406

Merged
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
9 changes: 9 additions & 0 deletions packages/components/src/menu-item/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
.components-menu-item__button.components-button {
width: 100%;

&[role="menuitemradio"],
&[role="menuitemcheckbox"] {
.components-menu-item__item:only-child {
// Ensure unchecked items have clearance for consistency
// with checked items containing an icon or shortcut.
padding-right: $grid-unit-60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment to denote what this particular value does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 👍

}
}

.components-menu-items__item-icon {
margin-right: -2px; // This optically balances the icon.
margin-left: $grid-unit-30;
Expand Down
26 changes: 19 additions & 7 deletions packages/components/src/tools-panel/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {

export const _default = () => {
const [ height, setHeight ] = useState();
const [ minHeight, setMinHeight ] = useState();
const [ width, setWidth ] = useState();

const resetAll = () => {
Expand All @@ -37,6 +38,18 @@ export const _default = () => {
label="Display options"
resetAll={ resetAll }
>
<ToolsPanelItem
className="single-column"
hasValue={ () => !! width }
label="Width"
onDeselect={ () => setWidth( undefined ) }
>
<UnitControl
label="Width"
value={ width }
onChange={ ( next ) => setWidth( next ) }
/>
</ToolsPanelItem>
<ToolsPanelItem
className="single-column"
hasValue={ () => !! height }
Expand All @@ -50,15 +63,14 @@ export const _default = () => {
/>
</ToolsPanelItem>
<ToolsPanelItem
className="single-column"
hasValue={ () => !! width }
label="Width"
onDeselect={ () => setWidth( undefined ) }
hasValue={ () => !! minHeight }
label="Minimum height"
onDeselect={ () => setMinHeight( undefined ) }
>
<UnitControl
label="Width"
value={ width }
onChange={ ( next ) => setWidth( next ) }
label="Minimum height"
value={ minHeight }
onChange={ ( next ) => setMinHeight( next ) }
/>
</ToolsPanelItem>
</ToolsPanel>
Expand Down