Skip to content

Commit

Permalink
merge latest
Browse files Browse the repository at this point in the history
  • Loading branch information
dgodinez-dh committed Dec 2, 2024
2 parents 45ccee9 + 2738a1d commit 3b24bb2
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 8 deletions.
100 changes: 100 additions & 0 deletions plugins/ui/docs/components/avatar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Avatar

An avatar is a small image or icon representing a user or organization.

## Example

```python
from deephaven import ui


my_avatar_basic = ui.avatar(
src="https://github.com/deephaven.png", alt="default avatar"
)
```


## Disabled State

The `is_disabled` prop disables avatars to prevent user interaction and gives them a silenced style.

```python
from deephaven import ui


my_avatar_is_disabled_example = ui.avatar(
src="https://github.com/deephaven.png", alt="default avatar", is_disabled=True
)
```


## Size

The `size` of an avatar can be set to one of the preset sizes, or a custom pixel value.

```python
from deephaven import ui


@ui.component
def ui_avatar_sizing_examples():
return [
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-50",
size="avatar-size-50",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-75",
size="avatar-size-75",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="davatar-size-100",
size="avatar-size-100",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-200",
size="avatar-size-200",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-300",
size="avatar-size-300",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-400",
size="avatar-size-400",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-500",
size="avatar-size-500",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-600",
size="avatar-size-600",
),
ui.avatar(
src="https://github.com/deephaven.png",
alt="avatar-size-700",
size="avatar-size-700",
),
ui.avatar(
src="https://github.com/deephaven.png", alt="custom pixel size", size=80
),
]


my_avatar_sizing_examples = ui_avatar_sizing_examples()
```

## API Reference

```{eval-rst}
.. dhautofunction:: deephaven.ui.avatar
```
19 changes: 19 additions & 0 deletions plugins/ui/docs/components/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ dash_stack = ui.dashboard(
)
```

### Stack with nested tabs

```python
from deephaven import ui

dash_stack = ui.dashboard(
ui.stack(
ui.panel(
ui.tabs(ui.tab("A1 content", title="A1"), ui.tab("A2 content", title="A2")),
title="A",
),
ui.panel(
ui.tabs(ui.tab("B1 content", title="B1"), ui.tab("B2 content", title="B2")),
title="B",
),
)
)
```

### Stack in a layout

```python
Expand Down
4 changes: 4 additions & 0 deletions plugins/ui/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"label": "action_menu",
"path": "components/action_menu.md"
},
{
"label": "avatar",
"path": "components/avatar.md"
},
{
"label": "badge",
"path": "components/badge.md"
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .action_button import action_button
from .action_group import action_group
from .action_menu import action_menu
from .avatar import avatar
from .basic import (
component_element,
)
Expand Down Expand Up @@ -72,6 +73,7 @@
"action_button",
"action_group",
"action_menu",
"avatar",
"component_element",
"badge",
"button",
Expand Down
170 changes: 170 additions & 0 deletions plugins/ui/src/deephaven/ui/components/avatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
from __future__ import annotations
from .types import (
# Layout
AlignSelf,
CSSProperties,
DimensionValue,
JustifySelf,
LayoutFlex,
Position,
)
from ..types import AvatarSize
from .basic import component_element
from ..elements import Element


def avatar(
src: str,
is_disabled: bool | None = None,
size: AvatarSize | DimensionValue | None = "avatar-size-100",
alt: str | None = None,
flex: LayoutFlex | None = None,
flex_grow: float | None = None,
flex_shrink: float | None = None,
flex_basis: DimensionValue | None = None,
align_self: AlignSelf | None = None,
justify_self: JustifySelf | None = None,
order: int | None = None,
grid_area: str | None = None,
grid_row: str | None = None,
grid_column: str | None = None,
grid_row_start: str | None = None,
grid_row_end: str | None = None,
grid_column_start: str | None = None,
grid_column_end: str | None = None,
margin: DimensionValue | None = None,
margin_top: DimensionValue | None = None,
margin_bottom: DimensionValue | None = None,
margin_start: DimensionValue | None = None,
margin_end: DimensionValue | None = None,
margin_x: DimensionValue | None = None,
margin_y: DimensionValue | None = None,
width: DimensionValue | None = None,
height: DimensionValue | None = None,
min_width: DimensionValue | None = None,
min_height: DimensionValue | None = None,
max_width: DimensionValue | None = None,
max_height: DimensionValue | None = None,
position: Position | None = None,
top: DimensionValue | None = None,
bottom: DimensionValue | None = None,
left: DimensionValue | None = None,
right: DimensionValue | None = None,
start: DimensionValue | None = None,
end: DimensionValue | None = None,
z_index: int | None = None,
is_hidden: bool | None = None,
id: str | None = None,
aria_label: str | None = None,
aria_labelledby: str | None = None,
aria_describedby: str | None = None,
aria_details: str | None = None,
UNSAFE_class_name: str | None = None,
UNSAFE_style: CSSProperties | None = None,
) -> Element:
"""
An avatar is a thumbnail representation of an entity, such as a user or an organization.
Args:
src: The image URL for the avatar.
is_disabled: Whether the avatar is disabled or not.
size: The size of the avatar. It affects both height and width.
alt: Description of the avatar.
flex: When used in a flex layout, specifies how the element will grow or shrink to fit the space available.
flex_grow: When used in a flex layout, specifies how the element will grow to fit the space available.
flex_shrink: When used in a flex layout, specifies how the element will shrink to fit the space available.
flex_basis: When used in a flex layout, specifies the initial main size of the element.
align_self: Overrides the alignItems property of a flex or grid container.
justify_self: Species how the element is justified inside a flex or grid container.
order: The layout order for the element within a flex or grid container.
grid_area: When used in a grid layout specifies, specifies the named grid area that the element should be placed in within the grid.
grid_row: When used in a grid layout, specifies the row the element should be placed in within the grid.
grid_column: When used in a grid layout, specifies the column the element should be placed in within the grid.
grid_row_start: When used in a grid layout, specifies the starting row to span within the grid.
grid_row_end: When used in a grid layout, specifies the ending row to span within the grid.
grid_column_start: When used in a grid layout, specifies the starting column to span within the grid.
grid_column_end: When used in a grid layout, specifies the ending column to span within the grid.
margin: The margin for all four sides of the element.
margin_top: The margin for the top side of the element.
margin_bottom: The margin for the bottom side of the element.
margin_start: The margin for the logical start side of the element, depending on layout direction.
margin_end: The margin for the logical end side of the element, depending on layout direction.
margin_x: The margin for the left and right sides of the element.
margin_y: The margin for the top and bottom sides of the element.
width: The width of the element.
height: The height of the element.
min_width: The minimum width of the element.
min_height: The minimum height of the element.
max_width: The maximum width of the element.
max_height: The maximum height of the element.
position: Specifies how the element is position.
top: The top position of the element.
bottom: The bottom position of the element.
left: The left position of the element.
right: The right position of the element.
start: The logical start position of the element, depending on layout direction.
end: The logical end position of the element, depending on layout direction.
z_index: The stacking order for the element
is_hidden: Hides the element.
id: The unique identifier of the element.
aria_label: Defines a string value that labels the current element.
aria_labelledby: Identifies the element (or elements) that labels the current element.
aria_describedby: Identifies the element (or elements) that describes the object.
aria_details: Identifies the element (or elements) that provide a detailed, extended description for the object.
UNSAFE_class_name: Set the CSS className for the element. Only use as a last resort. Use style props instead.
UNSAFE_style: Set the inline style for the element. Only use as a last resort. Use style props instead.
Returns:
The rendered avatar element.
"""
return component_element(
"Avatar",
src=src,
is_disabled=is_disabled,
size=size,
alt=alt,
flex=flex,
flex_grow=flex_grow,
flex_shrink=flex_shrink,
flex_basis=flex_basis,
align_self=align_self,
justify_self=justify_self,
order=order,
grid_area=grid_area,
grid_row=grid_row,
grid_column=grid_column,
grid_row_start=grid_row_start,
grid_row_end=grid_row_end,
grid_column_start=grid_column_start,
grid_column_end=grid_column_end,
margin=margin,
margin_top=margin_top,
margin_bottom=margin_bottom,
margin_start=margin_start,
margin_end=margin_end,
margin_x=margin_x,
margin_y=margin_y,
width=width,
height=height,
min_width=min_width,
min_height=min_height,
max_width=max_width,
max_height=max_height,
position=position,
top=top,
bottom=bottom,
left=left,
right=right,
start=start,
end=end,
z_index=z_index,
is_hidden=is_hidden,
id=id,
aria_label=aria_label,
aria_labelledby=aria_labelledby,
aria_describedby=aria_describedby,
aria_details=aria_details,
UNSAFE_class_name=UNSAFE_class_name,
UNSAFE_style=UNSAFE_style,
)
11 changes: 11 additions & 0 deletions plugins/ui/src/deephaven/ui/types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,17 @@ class SliderChange(TypedDict):
TabDensity = Literal["compact", "regular"]
InlineAlertVariant = Literal["neutral", "info", "positive", "notice", "negative"]
LinkVariant = Literal["primary", "secondary", "over_background"]
AvatarSize = Literal[
"avatar-size-50",
"avatar-size-75",
"avatar-size-100",
"avatar-size-200",
"avatar-size-300",
"avatar-size-400",
"avatar-size-500",
"avatar-size-600",
"avatar-size-700",
]
BadgeVariant = Literal[
"neutral",
"info",
Expand Down
1 change: 1 addition & 0 deletions plugins/ui/src/js/src/elements/model/ElementConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ELEMENT_NAME = {
actionButton: uiComponentName('ActionButton'),
actionGroup: uiComponentName('ActionGroup'),
actionMenu: uiComponentName('ActionMenu'),
avatar: uiComponentName('Avatar'),
badge: uiComponentName('Badge'),
button: uiComponentName('Button'),
buttonGroup: uiComponentName('ButtonGroup'),
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/src/js/src/widget/DocumentUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function getRootChildren(
if (nonLayoutCount === childrenArray.length) {
// Just wrap it in a panel
return (
<ReactPanel key="root" title={widget.name ?? widget.id ?? widget.type}>
<ReactPanel title={widget.name ?? widget.id ?? widget.type}>
{children}
</ReactPanel>
);
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/js/src/widget/WidgetUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { JSONRPCServerAndClient } from 'json-rpc-2.0';
// wrapped due to how Spectrum collection components consume them.
import {
ActionMenu,
Avatar,
ButtonGroup,
SpectrumCheckbox as Checkbox,
CheckboxGroup,
Expand Down Expand Up @@ -117,6 +118,7 @@ export const elementComponentMap = {
[ELEMENT_NAME.actionButton]: ActionButton,
[ELEMENT_NAME.actionGroup]: ActionGroup,
[ELEMENT_NAME.actionMenu]: ActionMenu,
[ELEMENT_NAME.avatar]: Avatar,
[ELEMENT_NAME.badge]: Badge,
[ELEMENT_NAME.button]: Button,
[ELEMENT_NAME.buttonGroup]: ButtonGroup,
Expand Down
Loading

0 comments on commit 3b24bb2

Please sign in to comment.