-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DataViews: Use Dropdown for views config dialog #65314
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import type { ChangeEvent } from 'react'; | |
*/ | ||
import { | ||
Button, | ||
Popover, | ||
Dropdown, | ||
__experimentalToggleGroupControl as ToggleGroupControl, | ||
__experimentalToggleGroupControlOption as ToggleGroupControlOption, | ||
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon, | ||
|
@@ -24,7 +24,7 @@ import { | |
BaseControl, | ||
} from '@wordpress/components'; | ||
import { __, _x, sprintf } from '@wordpress/i18n'; | ||
import { memo, useContext, useState, useMemo } from '@wordpress/element'; | ||
import { memo, useContext, useMemo } from '@wordpress/element'; | ||
import { chevronDown, chevronUp, cog, seen, unseen } from '@wordpress/icons'; | ||
import warning from '@wordpress/warning'; | ||
|
||
|
@@ -549,34 +549,32 @@ function _DataViewsViewConfig( { | |
setDensity: React.Dispatch< React.SetStateAction< number > >; | ||
defaultLayouts?: SupportedLayouts; | ||
} ) { | ||
const [ isShowingViewPopover, setIsShowingViewPopover ] = | ||
useState< boolean >( false ); | ||
|
||
return ( | ||
<> | ||
<ViewTypeMenu defaultLayouts={ defaultLayouts } /> | ||
<div> | ||
<Button | ||
size="compact" | ||
icon={ cog } | ||
label={ _x( 'View options', 'View is used as a noun' ) } | ||
onClick={ () => setIsShowingViewPopover( true ) } | ||
/> | ||
{ isShowingViewPopover && ( | ||
<Popover | ||
placement="bottom-end" | ||
onClose={ () => { | ||
setIsShowingViewPopover( false ); | ||
} } | ||
focusOnMount | ||
> | ||
<DataviewsViewConfigContent | ||
density={ density } | ||
setDensity={ setDensity } | ||
<Dropdown | ||
popoverProps={ { placement: 'bottom-end', offset: 9 } } | ||
contentClassName="dataviews-view-config" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also fixed in #65373 |
||
renderToggle={ ( { onToggle } ) => { | ||
return ( | ||
<Button | ||
size="compact" | ||
icon={ cog } | ||
label={ _x( | ||
'View options', | ||
'View is used as a noun' | ||
) } | ||
onClick={ onToggle } | ||
/> | ||
</Popover> | ||
); | ||
} } | ||
renderContent={ () => ( | ||
<DataviewsViewConfigContent | ||
density={ density } | ||
setDensity={ setDensity } | ||
/> | ||
) } | ||
</div> | ||
/> | ||
</> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
.dataviews-view-config { | ||
width: 320px; | ||
/* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */ | ||
container-type: inline-size; | ||
padding: $grid-unit-20; | ||
font-size: $default-font-size; | ||
line-height: $default-line-height; | ||
.components-popover__content { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using internal component classnames can really hinder our ability to make changes to the components without causing unintended breaking changes. In this case, we can use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your follow up! I wasn't aware of |
||
width: 320px; | ||
/* stylelint-disable-next-line property-no-unknown -- the linter needs to be updated to accepted the container-type property */ | ||
container-type: inline-size; | ||
padding: $grid-unit-20; | ||
font-size: $default-font-size; | ||
line-height: $default-line-height; | ||
} | ||
} | ||
|
||
.dataviews-view-config__sort-direction .components-toggle-group-control-option-base { | ||
text-transform: uppercase; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be extracted as a constant object, to avoid passing a new instance every re-render
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also done in #65373