-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adjustable grid density (#2151)
Fixes #885 This adds a user setting for grid density in the theme section which applies to all grids without an explicit density prop. A separate dh.ui PR will allow setting the density per table and is not influenced by the global density setting.
- Loading branch information
1 parent
7875d03
commit 6bb11f9
Showing
25 changed files
with
278 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useCallback } from 'react'; | ||
import { | ||
Item, | ||
ItemKey, | ||
Picker, | ||
ThemePicker, | ||
useTheme, | ||
} from '@deephaven/components'; | ||
import { assertNotNull } from '@deephaven/utils'; | ||
import { useDispatch } from 'react-redux'; | ||
import { getSettings, updateSettings } from '@deephaven/redux'; | ||
import { useAppSelector } from '@deephaven/dashboard'; | ||
|
||
export function ThemeSectionContent(): JSX.Element { | ||
const theme = useTheme(); | ||
const settings = useAppSelector(getSettings); | ||
const dispatch = useDispatch(); | ||
|
||
const updateDensity = useCallback( | ||
(density: ItemKey | null) => { | ||
if ( | ||
density !== 'regular' && | ||
density !== 'compact' && | ||
density !== 'spacious' | ||
) { | ||
throw new Error(`Invalid grid density value: ${density}`); | ||
} | ||
dispatch(updateSettings({ gridDensity: density })); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
const density = settings.gridDensity; | ||
|
||
assertNotNull(theme, 'ThemeContext value is null'); | ||
|
||
return ( | ||
<> | ||
<ThemePicker /> | ||
<Picker | ||
label="Default table density" | ||
selectedKey={density} | ||
onChange={updateDensity} | ||
> | ||
<Item key="regular">Regular</Item> | ||
<Item key="compact">Compact</Item> | ||
<Item key="spacious">Spacious</Item> | ||
</Picker> | ||
</> | ||
); | ||
} | ||
|
||
export default ThemeSectionContent; |
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
Oops, something went wrong.