File tree 2 files changed +15
-1
lines changed
docs/pages/docs/components
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -53,3 +53,8 @@ n.paragraph({
53
53
types = { [' fun(lines: NuiLine[], component: Checkbox): nil' ]}
54
54
/>
55
55
56
+ #### max_lines
57
+
58
+ <Property
59
+ types = { [' number' ]}
60
+ />
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ function Paragraph:init(props, popup_options)
19
19
lines = " " ,
20
20
align = " left" ,
21
21
truncate = false ,
22
+ max_lines = nil ,
22
23
}, props ),
23
24
fn .deep_merge ({
24
25
buf_options = {
@@ -33,6 +34,7 @@ function Paragraph:prop_types()
33
34
lines = { " table" , " string" },
34
35
align = " string" ,
35
36
truncate = " boolean" ,
37
+ max_lines = " number" ,
36
38
}
37
39
end
38
40
@@ -132,10 +134,17 @@ function Paragraph:on_layout()
132
134
local parent = self :get_parent ()
133
135
local direction = parent and parent :get_direction () or " column"
134
136
local is_row_direction = direction == " row"
137
+ local props = self :get_props ()
138
+
139
+ local height = math.max (1 , # lines )
140
+
141
+ if props .max_lines then
142
+ height = math.min (props .max_lines , height )
143
+ end
135
144
136
145
return {
137
146
width = is_row_direction and math.max (1 , max_width ) or nil ,
138
- height = is_row_direction and nil or math.max ( 1 , # lines ) ,
147
+ height = is_row_direction and nil or height ,
139
148
}
140
149
end
141
150
You can’t perform that action at this time.
0 commit comments