-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DataViews: Add density option to
table
layout
- Loading branch information
1 parent
b7d989e
commit 77f3a3f
Showing
11 changed files
with
154 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/dataviews/src/dataviews-layouts/table/density-picker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalToggleGroupControl as ToggleGroupControl, | ||
__experimentalToggleGroupControlOption as ToggleGroupControlOption, | ||
} from '@wordpress/components'; | ||
import { __, _x } from '@wordpress/i18n'; | ||
import { useContext } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import DataViewsContext from '../../components/dataviews-context'; | ||
import type { ViewTable, Density } from '../../types'; | ||
|
||
export default function DensityPicker() { | ||
const context = useContext( DataViewsContext ); | ||
const view = context.view as ViewTable; | ||
return ( | ||
<ToggleGroupControl | ||
__nextHasNoMarginBottom | ||
size="__unstable-large" | ||
label={ __( 'Density' ) } | ||
value={ view.layout?.density || 'balanced' } | ||
onChange={ ( value ) => { | ||
context.onChangeView( { | ||
...view, | ||
layout: { | ||
...view.layout, | ||
density: value as Density, | ||
}, | ||
} ); | ||
} } | ||
isBlock | ||
> | ||
<ToggleGroupControlOption | ||
key="comfortable" | ||
value="comfortable" | ||
label={ _x( | ||
'Comfortable', | ||
'Density option for DataView layout' | ||
) } | ||
/> | ||
<ToggleGroupControlOption | ||
key="balanced" | ||
value="balanced" | ||
label={ _x( 'Balanced', 'Density option for DataView layout' ) } | ||
/> | ||
<ToggleGroupControlOption | ||
key="compact" | ||
value="compact" | ||
label={ _x( 'Compact', 'Density option for DataView layout' ) } | ||
/> | ||
</ToggleGroupControl> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.