-
Notifications
You must be signed in to change notification settings - Fork 4.8k
DataViews: make it the root for pages and add details #57578
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
Changes from all commits
609db98
e827516
b2802d7
95c27d0
ef59b86
c7cb4d3
4568bf7
5964e8f
dac1cd8
e58041d
3666548
60a214b
537e399
e816a98
cb85da4
303a13f
f369561
5db86f7
7cb1249
9c85618
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 |
|---|---|---|
|
|
@@ -223,27 +223,69 @@ | |
|
|
||
| .dataviews-view-list { | ||
| margin: 0; | ||
| padding: $grid-unit-10; | ||
|
|
||
| li { | ||
| border-bottom: $border-width solid $gray-100; | ||
| margin: 0; | ||
| &:first-child { | ||
| border-top: $border-width solid $gray-100; | ||
|
|
||
| .dataviews-view-list__item-wrapper { | ||
| position: relative; | ||
| padding-right: $grid-unit-30; | ||
| border-radius: $grid-unit-05; | ||
|
|
||
| &::after { | ||
| position: absolute; | ||
| content: ""; | ||
| top: 100%; | ||
| left: $grid-unit-30; | ||
| right: $grid-unit-30; | ||
| background: $gray-100; | ||
| height: 1px; | ||
| } | ||
| } | ||
| &:last-child { | ||
| border-bottom: 0; | ||
|
|
||
| &:not(.is-selected):hover { | ||
| color: var(--wp-admin-theme-color); | ||
|
|
||
| .dataviews-view-list__fields { | ||
| color: var(--wp-admin-theme-color); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .dataviews-view-list__item { | ||
| padding: $grid-unit-15 $grid-unit-40; | ||
| cursor: default; | ||
| &:focus, | ||
oandregal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| &:hover { | ||
| background-color: lighten($gray-100, 3%); | ||
| li.is-selected, | ||
| li.is-selected:focus-within { | ||
| .dataviews-view-list__item-wrapper { | ||
| background-color: var(--wp-admin-theme-color); | ||
| color: $white; | ||
|
|
||
| .dataviews-view-list__fields, | ||
| .components-button { | ||
| color: $white; | ||
| } | ||
|
|
||
| &::after { | ||
| background: transparent; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .dataviews-view-list__item { | ||
| padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-30; | ||
| width: 100%; | ||
| cursor: pointer; | ||
| &:focus { | ||
| box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
| &::before { | ||
|
||
| position: absolute; | ||
| content: ""; | ||
| top: -1px; | ||
| right: -1px; | ||
| bottom: -1px; | ||
| left: -1px; | ||
| box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
| z-index: -1; | ||
| border-radius: $grid-unit-05; | ||
| } | ||
| } | ||
| h3 { | ||
| overflow: hidden; | ||
|
|
@@ -252,22 +294,12 @@ | |
| } | ||
| } | ||
|
|
||
| .dataviews-view-list__item-selected, | ||
| .dataviews-view-list__item-selected:hover { | ||
| background-color: $gray-100; | ||
|
|
||
| &:focus { | ||
| box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); | ||
| } | ||
| } | ||
|
|
||
| .dataviews-view-list__media-wrapper { | ||
| min-width: $grid-unit-40; | ||
| height: $grid-unit-40; | ||
| border-radius: $grid-unit-05; | ||
| overflow: hidden; | ||
| position: relative; | ||
| margin-top: $grid-unit-05; | ||
|
|
||
| &::after { | ||
| content: ""; | ||
|
|
@@ -301,6 +333,27 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| .dataviews-view-list__details-button { | ||
| align-self: center; | ||
| opacity: 0; | ||
| } | ||
|
|
||
| li.is-selected, | ||
| li:hover, | ||
| li:focus-within { | ||
| .dataviews-view-list__details-button { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| li.is-selected { | ||
| .dataviews-view-list__details-button { | ||
| &:focus { | ||
| box-shadow: 0 0 0 var(--wp-admin-border-width-focus) currentColor; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .dataviews-action-modal { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,15 +10,19 @@ import { useAsyncList } from '@wordpress/compose'; | |
| import { | ||
| __experimentalHStack as HStack, | ||
| __experimentalVStack as VStack, | ||
| Button, | ||
| } from '@wordpress/components'; | ||
| import { ENTER, SPACE } from '@wordpress/keycodes'; | ||
| import { info } from '@wordpress/icons'; | ||
| import { __ } from '@wordpress/i18n'; | ||
|
|
||
| export default function ViewList( { | ||
| view, | ||
| fields, | ||
| data, | ||
| getItemId, | ||
| onSelectionChange, | ||
| onDetailsChange, | ||
| selection, | ||
| deferredRendering, | ||
| } ) { | ||
|
|
@@ -49,28 +53,27 @@ export default function ViewList( { | |
| <ul className="dataviews-view-list"> | ||
| { usedData.map( ( item ) => { | ||
| return ( | ||
| <li key={ getItemId( item ) }> | ||
| <div | ||
| role="button" | ||
| tabIndex={ 0 } | ||
| aria-pressed={ selection.includes( item.id ) } | ||
| onKeyDown={ onEnter( item ) } | ||
| className={ classNames( | ||
| 'dataviews-view-list__item', | ||
| { | ||
| 'dataviews-view-list__item-selected': | ||
| selection.includes( item.id ), | ||
| } | ||
| ) } | ||
| onClick={ () => onSelectionChange( [ item ] ) } | ||
| > | ||
| <HStack spacing={ 3 } alignment="flex-start"> | ||
| <div className="dataviews-view-list__media-wrapper"> | ||
| { mediaField?.render( { item } ) || ( | ||
| <div className="dataviews-view-list__media-placeholder"></div> | ||
| ) } | ||
| </div> | ||
| <HStack> | ||
| <li | ||
|
||
| key={ getItemId( item ) } | ||
| className={ classNames( { | ||
| 'is-selected': selection.includes( item.id ), | ||
| } ) } | ||
| > | ||
| <HStack className="dataviews-view-list__item-wrapper"> | ||
| <div | ||
| role="button" | ||
| tabIndex={ 0 } | ||
| aria-pressed={ selection.includes( item.id ) } | ||
| onKeyDown={ onEnter( item ) } | ||
| className="dataviews-view-list__item" | ||
| onClick={ () => onSelectionChange( [ item ] ) } | ||
| > | ||
| <HStack spacing={ 3 } justify="start"> | ||
| <div className="dataviews-view-list__media-wrapper"> | ||
| { mediaField?.render( { item } ) || ( | ||
| <div className="dataviews-view-list__media-placeholder"></div> | ||
| ) } | ||
| </div> | ||
| <VStack spacing={ 1 }> | ||
| { primaryField?.render( { item } ) } | ||
| <div className="dataviews-view-list__fields"> | ||
|
|
@@ -89,8 +92,19 @@ export default function ViewList( { | |
| </div> | ||
| </VStack> | ||
| </HStack> | ||
| </HStack> | ||
| </div> | ||
| </div> | ||
| { onDetailsChange && ( | ||
| <Button | ||
| className="dataviews-view-list__details-button" | ||
| onClick={ () => | ||
| onDetailsChange( [ item ] ) | ||
| } | ||
| icon={ info } | ||
| label={ __( 'View details' ) } | ||
| size="compact" | ||
| /> | ||
| ) } | ||
| </HStack> | ||
| </li> | ||
| ); | ||
| } ) } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,27 @@ import { trash } from '@wordpress/icons'; | |
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { LAYOUT_TABLE, OPERATOR_IN } from '../../utils/constants'; | ||
| import { | ||
| LAYOUT_LIST, | ||
| LAYOUT_TABLE, | ||
| LAYOUT_GRID, | ||
| OPERATOR_IN, | ||
| } from '../../utils/constants'; | ||
|
|
||
| export const DEFAULT_CONFIG_PER_VIEW_TYPE = { | ||
|
Member
Author
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. This was moved from |
||
| [ LAYOUT_TABLE ]: {}, | ||
| [ LAYOUT_GRID ]: { | ||
| mediaField: 'featured-image', | ||
| primaryField: 'title', | ||
| }, | ||
| [ LAYOUT_LIST ]: { | ||
| primaryField: 'title', | ||
| mediaField: 'featured-image', | ||
| }, | ||
| }; | ||
|
|
||
| const DEFAULT_PAGE_BASE = { | ||
| type: LAYOUT_TABLE, | ||
| type: LAYOUT_LIST, | ||
| search: '', | ||
| filters: [], | ||
| page: 1, | ||
|
|
@@ -22,10 +39,12 @@ const DEFAULT_PAGE_BASE = { | |
| // All fields are visible by default, so it's | ||
| // better to keep track of the hidden ones. | ||
| hiddenFields: [ 'date', 'featured-image' ], | ||
| layout: {}, | ||
| layout: { | ||
| ...DEFAULT_CONFIG_PER_VIEW_TYPE[ LAYOUT_LIST ], | ||
| }, | ||
| }; | ||
|
|
||
| const DEFAULT_VIEWS = { | ||
| export const DEFAULT_VIEWS = { | ||
| page: [ | ||
| { | ||
| title: __( 'All' ), | ||
|
|
@@ -55,5 +74,3 @@ const DEFAULT_VIEWS = { | |
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export default DEFAULT_VIEWS; | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
I think there's a world where this is the same as
onSelectionChangein other words, when a single item is selected in list view we navigate to "details" and vice versaThere 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.
That's possible, indeed. The way it works now is optimized for being a listing: you navigate through the items, preview them, and can manage them. There's also the multi-selection use case for bulk editing that needs to be accommodated.