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

Align Dropdown and DropdownMenu styles #18631

Merged
merged 5 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
39 changes: 2 additions & 37 deletions packages/components/src/dropdown-menu/style.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
.components-dropdown-menu {
padding: 3px;
display: flex;

.components-dropdown-menu__toggle {
width: auto;
margin: 0;
padding: 4px;
border: $border-width solid transparent;
display: flex;
flex-direction: row;

&.is-active,
&.is-active:hover {
box-shadow: none;
background-color: $dark-gray-500;
color: $white;
}

&:focus::before {
top: -3px;
right: -3px;
bottom: -3px;
left: -3px;
}

&:hover,
&:focus,
&:not(:disabled):not([aria-disabled="true"]):not(.is-default):hover {
@include formatting-button-style__hover();
}

// Add a dropdown arrow indicator.
.components-dropdown-menu__indicator::after {
@include dropdown-arrow();
}
}
.components-dropdown-menu__indicator::after {
@include dropdown-arrow();
}

.components-dropdown-menu__popover .components-popover__content {
Expand Down
7 changes: 6 additions & 1 deletion packages/components/src/dropdown/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -82,7 +87,7 @@ class Dropdown extends Component {
const args = { isOpen, onToggle: this.toggle, onClose: this.close };

return (
<div className={ className } ref={ this.containerRef }>
<div className={ classnames( 'components-dropdown', className ) } ref={ this.containerRef }>
{ renderToggle( args ) }
{ isOpen && (
<Popover
Expand Down
86 changes: 86 additions & 0 deletions packages/components/src/dropdown/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Internal dependencies
*/
import Dropdown from '../';
import IconButton from '../../icon-button';
import MenuGroup from '../../menu-group';
import MenuItem from '../../menu-item';
import DropdownMenu from '../../dropdown-menu';

export default { title: 'Components|Dropdown', component: Dropdown };

const DropdownAndDropdownMenuExample = () => {
return (
<>
<div>
<p>This is a DropdownMenu component:</p>
<DropdownMenu
icon="move"
label="Select a direction"
controls={ [
{
title: 'Up',
icon: 'arrow-up-alt',
},
{
title: 'Right',
icon: 'arrow-right-alt',
},
{
title: 'Down',
icon: 'arrow-down-alt',
},
{
title: 'Left',
icon: 'arrow-left-alt',
},
] }
/>
</div>
<div>
<p>This is an assembled Dropdown component:</p>
<Dropdown
className="my-container-class-name"
contentClassName="my-popover-content-classname"
position="bottom right"
renderToggle={ ( { isOpen, onToggle } ) => (
<IconButton
icon="move"
onClick={ onToggle }
aria-expanded={ isOpen }
label="Select a direction"
/>
) }
renderContent={ () => (
<MenuGroup>
<MenuItem
icon="arrow-up-alt"
>
Up
</MenuItem>
<MenuItem
icon="arrow-down-alt"
>
Down
</MenuItem>
<MenuItem
icon="arrow-left-alt"
>
Left
</MenuItem>
<MenuItem
icon="arrow-right-alt"
>
Right
</MenuItem>
</MenuGroup>
) }
/>
</div>
</>
);
};

export const _default = () => {
return <DropdownAndDropdownMenuExample />;
};
3 changes: 3 additions & 0 deletions packages/components/src/dropdown/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.components-dropdown {
display: inline-block;
Copy link

Choose a reason for hiding this comment

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

Thanks for fixing this! Changing the display of the div makes sense. Can confirm it's working in Storybook 👍

}
1 change: 1 addition & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@import "./disabled/style.scss";
@import "./draggable/style.scss";
@import "./drop-zone/style.scss";
@import "./dropdown/style.scss";
@import "./dropdown-menu/style.scss";
@import "./external-link/style.scss";
@import "./focal-point-picker/style.scss";
Expand Down