-
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 (#67170)
Unlinked contributors: annchichi. Co-authored-by: ntsekouras <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: rogermattic <[email protected]> Co-authored-by: oandregal <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: mtias <[email protected]> Co-authored-by: mcsf <[email protected]>
- Loading branch information
1 parent
2be64e4
commit 010cf1a
Showing
13 changed files
with
168 additions
and
67 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.