Skip to content

Commit

Permalink
fix tab panels and review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmmcken committed Sep 23, 2024
1 parent 70dd21f commit 85c60ee
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 15 deletions.
22 changes: 22 additions & 0 deletions plugins/ui/src/js/src/elements/Flex.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import {
Flex as DHCFlex,
FlexProps as DHCFlexProps,
} from '@deephaven/components';

import classNames from 'classnames';

export function Flex({
UNSAFE_className,
...restProps
}: DHCFlexProps): JSX.Element {
return (
<DHCFlex
UNSAFE_className={classNames('dh-flex', UNSAFE_className)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...restProps}
/>
);
}

export default Flex;
22 changes: 22 additions & 0 deletions plugins/ui/src/js/src/elements/Grid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import {
Grid as DHCGrid,
GridProps as DHCGridProps,
} from '@deephaven/components';

import classNames from 'classnames';

export function Grid({
UNSAFE_className,
...restProps
}: DHCGridProps): JSX.Element {
return (
<DHCGrid
UNSAFE_className={classNames('dh-grid', UNSAFE_className)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...restProps}
/>
);
}

export default Grid;
4 changes: 4 additions & 0 deletions plugins/ui/src/js/src/elements/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@deephaven/components';
import { isElementOfType } from '@deephaven/react-hooks';
import { ensureArray } from '@deephaven/utils';
import classNames from 'classnames';
import { TabPanels } from './TabPanels';

type TabProps = {
Expand Down Expand Up @@ -81,6 +82,7 @@ export function Tabs(props: TabComponentProps): JSX.Element {
children,
onSelectionChange: onSelectionChangeProp,
onChange,
UNSAFE_className,
...otherTabProps
} = props;
const childrenArray = useMemo(() => ensureArray(children), [children]);
Expand Down Expand Up @@ -137,6 +139,7 @@ export function Tabs(props: TabComponentProps): JSX.Element {
return (
<DHCTabs
onSelectionChange={onSelectionChange}
UNSAFE_className={classNames('dh-tabs', UNSAFE_className)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...otherTabProps}
>
Expand All @@ -148,6 +151,7 @@ export function Tabs(props: TabComponentProps): JSX.Element {
return (
<DHCTabs
onSelectionChange={onSelectionChange}
UNSAFE_className={classNames('dh-tabs', UNSAFE_className)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...otherTabProps}
>
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/js/src/elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export * from './ComboBox';
export * from './DateField';
export * from './DatePicker';
export * from './DateRangePicker';
export * from './Flex';
export * from './Form';
export * from './Grid';
export * from './hooks';
export * from './HTMLElementView';
export * from './IconElementView';
Expand Down
5 changes: 5 additions & 0 deletions plugins/ui/src/js/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
align-self: stretch;
}

.dh-tabs {
flex: auto;
height: 100%;
}

.iris-grid {
// we don't want the grid to ever collapse to 0 height, so we set a min-height
// let's users know that the grid is there
Expand Down
17 changes: 2 additions & 15 deletions plugins/ui/src/js/src/widget/WidgetUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
SpectrumCheckbox as Checkbox,
Content,
ContextualHelp,
Flex,
Grid,
Heading,
Item,
ListActionGroup,
Expand Down Expand Up @@ -54,7 +52,9 @@ import {
DateField,
DatePicker,
DateRangePicker,
Flex,
Form,
Grid,
IllustratedMessage,
Image,
ListView,
Expand Down Expand Up @@ -82,11 +82,6 @@ const shouldWrapTextChildren = new Set<string>([
ELEMENT_NAME.view,
]);

const shouldAddClassName = new Set<string>([
ELEMENT_NAME.flex,
ELEMENT_NAME.grid,
]);

const log = Log.module('@deephaven/js-plugin-ui/WidgetUtils');

/*
Expand Down Expand Up @@ -182,14 +177,6 @@ export function getComponentForElement(element: ElementNode): React.ReactNode {
</ContextualHelp>
);
}
// classes can be used for deephaven ui specific css
// "deephaven.ui.components.Grid" -> "dh-grid"
if (shouldAddClassName.has(newElement[ELEMENT_KEY])) {
props.UNSAFE_className = `${props.UNSAFE_className ?? ''} ${`dh-${
newElement[ELEMENT_KEY].split('.').pop()?.toLowerCase() ?? ''
}`}`.trim();
}

return <Component {...props} />;
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/app.d/ui_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ def ui_flex_test_component():
flex_19 = ui.panel(
ui.grid(ui.button("test"), _t_flex, _p_flex, rows="min-content 1fr 1fr")
)
flex_20 = ui.panel(
ui.tabs(
ui.tab(_p_flex, title="Tab A"),
ui.tab(_t_flex, title="Tab B"),
)
)
flex_21 = ui.panel(
ui.button("Test"),
ui.tabs(
ui.tab(_p_flex, title="Tab A"),
ui.tab(_t_flex, title="Tab B"),
),
ui.button("Test"),
_t_flex,
)
2 changes: 2 additions & 0 deletions tests/ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ test.describe('UI flex components', () => {
{ name: 'flex_17', traces: 0 },
{ name: 'flex_18', traces: 0 },
{ name: 'flex_19', traces: 1 },
{ name: 'flex_20', traces: 1 },
{ name: 'flex_21', traces: 1 },
].forEach(i => {
test(i.name, async ({ page }) => {
await gotoPage(page, '');
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 85c60ee

Please sign in to comment.