Skip to content

Commit

Permalink
feat: make ui.panel flex align-items start by default (#604)
Browse files Browse the repository at this point in the history
ui.panels implicitly wrap things in a flex, with a direction set to
column. Column makes sense, as tables typically are wide, and stacking
them makes more sense by default that side by side.

However, a key distinction is with row, the horizonal axis alignment is
equivalent to start. In column the horizonal axis (which is now a
cross-axis) is stretch.

I think we should set align-items: start for the implicit ui.flex column
wrapper of ui.panel so that it doesn't stretch buttons in the horizontal
cross-axis by default.

before:

![image](https://github.com/deephaven/deephaven-plugins/assets/1576283/8efc1b3a-0d6b-45ef-9f72-bdf9d73f43b9)

after:

![image_720](https://github.com/deephaven/deephaven-plugins/assets/1576283/7ce32114-238d-4c86-9293-d2b8faa776dc)

BREAKING CHANGE:

`ui.panel` implicitly created flexbox `align-items` property is now set
to `start` by default instead of `normal` (which is equivalent to
`stretch`). This results in a more pleasing default layout, as buttons
will no longer be stretched to the full panel width. You can match
previous behavior by explicitly returning a ui.panel with
`align-items="normal"` if required.
  • Loading branch information
dsmmcken authored Jul 5, 2024
1 parent 145493a commit be97ad8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/ui/src/deephaven/ui/components/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def panel(
wrap: Wrap | None = None,
justify_content: JustifyContent | None = None,
align_content: AlignContent | None = None,
align_items: AlignItems | None = None,
align_items: AlignItems | None = "start",
gap: DimensionValue | None = "size-100",
column_gap: DimensionValue | None = None,
row_gap: DimensionValue | None = None,
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/src/js/src/layout/ReactPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ReactPanel({
wrap,
justifyContent,
alignContent,
alignItems,
alignItems = 'start',
gap = 'size-100',
rowGap,
columnGap,
Expand Down
7 changes: 6 additions & 1 deletion tests/app.d/ui_render_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ def ui_html_elements():
ui.stack(
ui.panel(
ui.table(_column_types),
ui.grid(_my_components, _my_html_elements, columns=["1fr", "1fr", "1fr"]),
ui.grid(
_my_components,
_my_html_elements,
columns=["1fr", "1fr", "1fr"],
width="100%",
),
title="Panel B",
),
)
Expand Down
Binary file modified tests/ui.spec.ts-snapshots/UI-loads-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/ui.spec.ts-snapshots/UI-loads-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/ui.spec.ts-snapshots/UI-loads-1-webkit-linux.png
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 be97ad8

Please sign in to comment.