Skip to content

Commit

Permalink
Reduce visual prominence of primary actions in table data views, and …
Browse files Browse the repository at this point in the history
…consolidate primary + secondary actions in ellipsis menu (#59128)

Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: andrewhayward <andrewhayward@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
  • Loading branch information
7 people authored Mar 8, 2024
1 parent 985ea06 commit 47c22e7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
8 changes: 8 additions & 0 deletions packages/dataviews/src/item-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
DropdownMenuGroupV2: DropdownMenuGroup,
DropdownMenuItemV2: DropdownMenuItem,
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
DropdownMenuSeparatorV2: DropdownMenuSeparator,
kebabCase,
} = unlock( componentsPrivateApis );

Expand Down Expand Up @@ -136,6 +137,7 @@ export default function ItemActions( { item, actions, isCompact } ) {
<HStack
spacing={ 1 }
justify="flex-end"
className="dataviews-view-table__actions"
style={ {
flexShrink: '0',
width: 'auto',
Expand Down Expand Up @@ -168,10 +170,16 @@ export default function ItemActions( { item, actions, isCompact } ) {
icon={ moreVertical }
label={ __( 'Actions' ) }
disabled={ ! secondaryActions.length }
className="dataviews-view-table__all-actions-button"
/>
}
placement="bottom-end"
>
<ActionsDropdownMenuGroup
actions={ primaryActions }
item={ item }
/>
<DropdownMenuSeparator />
<ActionsDropdownMenuGroup
actions={ secondaryActions }
item={ item }
Expand Down
11 changes: 8 additions & 3 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
border-bottom: 0;
}

&:hover {
&.is-hovered {
background-color: #f8f8f8;
}

Expand All @@ -137,9 +137,14 @@
}
}

.dataviews-view-table__actions .components-button:not(.dataviews-view-table__all-actions-button) {
opacity: 0;
}

&:focus-within,
&:hover {
.components-checkbox-control__input {
&.is-hovered {
.components-checkbox-control__input,
.dataviews-view-table__actions .components-button:not(.dataviews-view-table__all-actions-button) {
opacity: 1;
}
}
Expand Down
18 changes: 17 additions & 1 deletion packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,28 @@ function TableRow( {
data,
} ) {
const hasPossibleBulkAction = useHasAPossibleBulkAction( actions, item );

const isSelected = selection.includes( id );

const [ isHovered, setIsHovered ] = useState( false );

const handleMouseEnter = () => {
setIsHovered( true );
};

const handleMouseLeave = () => {
setIsHovered( false );
};

return (
<tr
className={ classnames( 'dataviews-view-table__row', {
'is-selected': hasPossibleBulkAction && isSelected,
'is-selected':
hasPossibleBulkAction && selection.includes( id ),
'is-hovered': isHovered,
} ) }
onMouseEnter={ handleMouseEnter }
onMouseLeave={ handleMouseLeave }
onClickCapture={ ( event ) => {
if ( event.ctrlKey || event.metaKey ) {
event.stopPropagation();
Expand Down

1 comment on commit 47c22e7

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 47c22e7.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8202135526
📝 Reported issues:

Please sign in to comment.