Skip to content

Commit 5bd097c

Browse files
committed
Timeline: Added autoHeight component and a vertical scrollbar
1 parent ed5596c commit 5bd097c

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

client/packages/lowcoder/src/comps/comps/timelineComp/timelineComp.tsx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "lowcoder-core";
99
import { trans } from "i18n";
1010
import { UICompBuilder, withDefault } from "../../generators";
11-
import { Section, sectionNames } from "lowcoder-design";
11+
import { ScrollBar, Section, sectionNames } from "lowcoder-design";
1212
import { hiddenPropertyView } from "comps/utils/propertyUtils";
1313
import { BoolControl } from "comps/controls/boolControl";
1414
import { stringExposingStateControl } from "comps/controls/codeStateControl";
@@ -62,6 +62,8 @@ const childrenMap = {
6262
value: jsonControl(convertTimeLineData, timelineDate),
6363
mode: dropdownControl(modeOptions, "alternate"),
6464
reverse: BoolControl,
65+
autoHeight: AutoHeightControl,
66+
verticalScrollbar: withDefault(BoolControl, false),
6567
pending: withDefault(StringControl, trans("timeLine.defaultPending")),
6668
onEvent: eventHandlerControl(EventOptions),
6769
style: styleControl(TimeLineStyle, 'style'),
@@ -136,31 +138,33 @@ const TimelineComp = (
136138
}));
137139

138140
return (
139-
<div
140-
style={{
141-
margin: style.margin ?? '3px',
142-
padding: style.padding !== '3px' ? style.padding : '20px 10px 0px 10px',
143-
width: widthCalculator(style.margin ?? '3px'),
144-
height: heightCalculator(style.margin ?? '3px'),
145-
background: style.background,
146-
overflow: "auto",
147-
overflowX: "hidden",
148-
borderRadius: style.radius,
149-
}}
150-
>
151-
<Timeline
152-
mode={props?.mode || "left"}
153-
reverse={props?.reverse}
154-
pending={
155-
props?.pending && (
156-
<span style={{ color: style?.titleColor }}>
157-
{props?.pending || ""}
158-
</span>
159-
)
160-
}
161-
items={timelineItems}
162-
/>
163-
</div>
141+
<ScrollBar hideScrollbar={!props.verticalScrollbar}>
142+
<div
143+
style={{
144+
margin: style.margin ?? '3px',
145+
padding: style.padding !== '3px' ? style.padding : '20px 10px 0px 10px',
146+
width: widthCalculator(style.margin ?? '3px'),
147+
height: heightCalculator(style.margin ?? '3px'),
148+
background: style.background,
149+
overflow: "auto",
150+
overflowX: "hidden",
151+
borderRadius: style.radius,
152+
}}
153+
>
154+
<Timeline
155+
mode={props?.mode || "left"}
156+
reverse={props?.reverse}
157+
pending={
158+
props?.pending && (
159+
<span style={{ color: style?.titleColor }}>
160+
{props?.pending || ""}
161+
</span>
162+
)
163+
}
164+
items={timelineItems}
165+
/>
166+
</div>
167+
</ScrollBar>
164168
);
165169
};
166170

@@ -187,6 +191,11 @@ let TimeLineBasicComp = (function () {
187191

188192
{["layout", "both"].includes(useContext(EditorContext).editorModeStatus) && (
189193
<><Section name={sectionNames.layout}>
194+
{children.autoHeight.getPropertyView()}
195+
{!children.autoHeight.getView() &&
196+
children.verticalScrollbar.propertyView({
197+
label: trans("prop.showVerticalScrollbar")
198+
})}
190199
{children.mode.propertyView({
191200
label: trans("timeLine.mode"),
192201
tooltip: trans("timeLine.modeTooltip"),
@@ -211,7 +220,7 @@ let TimeLineBasicComp = (function () {
211220

212221
TimeLineBasicComp = class extends TimeLineBasicComp {
213222
override autoHeight(): boolean {
214-
return false;
223+
return this.children.autoHeight.getView();
215224
}
216225
};
217226

0 commit comments

Comments
 (0)