Skip to content

Commit

Permalink
Add ability to min/max size of rows/cols
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorlias committed Jan 20, 2023
1 parent 9ab0dcb commit 727f026
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rbxts/zenui-core",
"version": "0.6.3",
"version": "0.7.0",
"description": "",
"main": "out/init.lua",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions src/Layouts/ColumnView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ export interface ColumnProps {
* The width of this column
*/
readonly Width?: UDim;

/**
* The maximum width of this column
*/
readonly MaxWidth?: number;

/**
* The minimum width of this column
*/
readonly MinWidth?: number;

/**
* The vertical alignment of the contents in this column
*/
Expand Down Expand Up @@ -189,6 +200,17 @@ export class ColumnView extends Roact.Component<ColumnViewProps> {
}
AutomaticSize={useAutomaticSize ? "Y" : "None"}
>
{(props.MaxWidth !== undefined || props.MinWidth !== undefined) && (
<uisizeconstraint
Key="ColumnItemSizeConstraint"
MinSize={props.MinWidth !== undefined ? new Vector2(props.MinWidth, 0) : undefined}
MaxSize={
props.MaxWidth !== undefined
? new Vector2(props.MaxWidth, math.huge)
: undefined
}
/>
)}
<uilistlayout
VerticalAlignment={props.VerticalAlignment}
HorizontalAlignment={
Expand Down
23 changes: 23 additions & 0 deletions src/Layouts/RowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export interface RowProps {
* The height of this row
*/
readonly Height?: UDim;

/**
* The maximum height of this row
*/
readonly MaxHeight?: number;
/**
* The minimum height of this row
*/
readonly MinHeight?: number;

/**
* The vertical alignment of the contents in this row
*/
Expand Down Expand Up @@ -149,6 +159,19 @@ export class RowView extends Roact.Component<RowViewProps> {
}
AutomaticSize={this.props.RowWidth === new UDim() ? "X" : "None"}
>
{(props.MaxHeight !== undefined || props.MinHeight !== undefined) && (
<uisizeconstraint
Key="ColumnItemSizeConstraint"
MinSize={
props.MinHeight !== undefined ? new Vector2(0, props.MinHeight) : undefined
}
MaxSize={
props.MaxHeight !== undefined
? new Vector2(math.huge, props.MaxHeight)
: undefined
}
/>
)}
<uilistlayout
VerticalAlignment={
props.VerticalAlignment ??
Expand Down

0 comments on commit 727f026

Please sign in to comment.