-
Notifications
You must be signed in to change notification settings - Fork 33
feat: Adjustable grid density #2151
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 5 commits
288702a
9d34bc4
137a3b3
2389947
21a37ff
b52373f
a83f745
6ba4057
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 |
|---|---|---|
| @@ -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(); | ||
|
Member
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.
Collaborator
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 doesn't seem to work with the thunk action I'm dispatching. Throws a TS error about the argument not being the right type
Collaborator
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. I think this might be because we aren't using |
||
|
|
||
| const updateDensity = useCallback( | ||
| (density: ItemKey | null) => { | ||
| if ( | ||
| density !== 'regular' && | ||
| density !== 'compact' && | ||
| density !== 'spacious' | ||
| ) { | ||
|
mofojed marked this conversation as resolved.
|
||
| 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; | ||
Uh oh!
There was an error while loading. Please reload this page.