Skip to content

Commit dcabdb5

Browse files
author
FalkWolsky
committed
Vertical Slider Orientation
1 parent 0de946e commit dcabdb5

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

client/packages/lowcoder/src/comps/comps/numberInputComp/rangeSliderComp.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import { UICompBuilder } from "../../generators";
55
import { CommonNameConfig, NameConfig, withExposingConfigs } from "../../generators/withExposing";
66
import { SliderChildren, SliderPropertyView, SliderStyled, SliderWrapper } from "./sliderCompConstants";
77
import { hasIcon } from "comps/utils";
8+
import { BoolControl } from "comps/controls/boolControl";
89

910
const RangeSliderBasicComp = (function () {
1011
const childrenMap = {
1112
...SliderChildren,
1213
start: numberExposingStateControl("start", 10),
1314
end: numberExposingStateControl("end", 60),
15+
vertical: BoolControl,
1416
};
1517
return new UICompBuilder(childrenMap, (props) => {
1618
return props.label({
@@ -19,6 +21,7 @@ const RangeSliderBasicComp = (function () {
1921
inputFieldStyle:props.inputFieldStyle,
2022
children: (
2123
<SliderWrapper
24+
vertical={props.vertical}
2225
onMouseDown={(e: any) => {
2326
e.stopPropagation();
2427
return false;
@@ -31,6 +34,7 @@ const RangeSliderBasicComp = (function () {
3134
value={[props.start.value, props.end.value]}
3235
$style={props.inputFieldStyle}
3336
style={{ margin: 0 }}
37+
vertical={props.vertical || false}
3438
onChange={([start, end]) => {
3539
props.start.onChange(start);
3640
props.end.onChange(end);
@@ -54,6 +58,7 @@ const RangeSliderBasicComp = (function () {
5458
label: trans("rangeSlider.step"),
5559
tooltip: trans("rangeSlider.stepTooltip"),
5660
})}
61+
{children.vertical.propertyView({ label: trans("slider.vertical") })}
5762
</Section>
5863

5964
<SliderPropertyView {...children} />

client/packages/lowcoder/src/comps/comps/numberInputComp/sliderComp.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CommonNameConfig, NameConfig, withExposingConfigs } from "../../generat
66
import { formDataChildren, FormDataPropertyView } from "../formComp/formDataConstants";
77
import { SliderChildren, SliderPropertyView, SliderStyled, SliderWrapper } from "./sliderCompConstants";
88
import { hasIcon } from "comps/utils";
9+
import { BoolControl } from "comps/controls/boolControl";
910

1011
const SliderBasicComp = (function () {
1112
/**
@@ -14,6 +15,7 @@ const SliderBasicComp = (function () {
1415
const childrenMap = {
1516
...SliderChildren,
1617
value: numberExposingStateControl("value", 60),
18+
vertical: BoolControl,
1719
...formDataChildren,
1820
};
1921
return new UICompBuilder(childrenMap, (props) => {
@@ -23,6 +25,7 @@ const SliderBasicComp = (function () {
2325
inputFieldStyle:props.inputFieldStyle,
2426
children: (
2527
<SliderWrapper
28+
vertical={props.vertical}
2629
onMouseDown={(e: any) => {
2730
e.stopPropagation();
2831
return false;
@@ -34,7 +37,7 @@ const SliderBasicComp = (function () {
3437
value={props.value.value}
3538
$style={props.inputFieldStyle}
3639
style={{margin: 0}}
37-
// FALK TODO : vertical={true}
40+
vertical={props.vertical || false}
3841
onChange={(e) => {
3942
props.value.onChange(e);
4043
props.onEvent("change");
@@ -56,6 +59,7 @@ const SliderBasicComp = (function () {
5659
label: trans("slider.step"),
5760
tooltip: trans("slider.stepTooltip"),
5861
})}
62+
{children.vertical.propertyView({ label: trans("slider.vertical") })}
5963
</Section>
6064
<FormDataPropertyView {...children} />
6165
<SliderPropertyView {...children} />

client/packages/lowcoder/src/comps/comps/numberInputComp/sliderCompConstants.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ChangeEventHandlerControl } from "../../controls/eventHandlerControl";
55
import { Section, sectionNames } from "lowcoder-design";
66
import { RecordConstructorToComp } from "lowcoder-core";
77
import { styleControl } from "comps/controls/styleControl";
8-
import { InputFieldStyle, LabelStyle, SliderStyle, SliderStyleType } from "comps/controls/styleControlConstants";
8+
import { InputFieldStyle, LabelStyle, SliderStyle, SliderStyleType, heightCalculator, widthCalculator } from "comps/controls/styleControlConstants";
99
import styled, { css } from "styled-components";
1010
import { default as Slider } from "antd/es/slider";
1111
import { darkenColor, fadeColor } from "lowcoder-design";
@@ -16,7 +16,7 @@ import { trans } from "i18n";
1616
import { useContext } from "react";
1717
import { EditorContext } from "comps/editorState";
1818

19-
const getStyle = (style: SliderStyleType) => {
19+
const getStyle = (style: SliderStyleType, vertical: boolean) => {
2020
return css`
2121
&.ant-slider:not(.ant-slider-disabled) {
2222
&,
@@ -41,16 +41,20 @@ const getStyle = (style: SliderStyleType) => {
4141
.ant-slider-handle:focus {
4242
box-shadow: 0 0 0 5px ${fadeColor(darkenColor(style.thumbBorder, 0.08), 0.12)};
4343
}
44+
${vertical && css`
45+
width: auto;
46+
min-height: calc(300px - ${style.margin});
47+
margin: ${style.margin} auto !important;
48+
`}
4449
}
4550
`;
4651
};
4752

48-
export const SliderStyled = styled(Slider)<{ $style: SliderStyleType }>`
49-
${(props) => props.$style && getStyle(props.$style)}
53+
export const SliderStyled = styled(Slider)<{ $style: SliderStyleType, vertical: boolean }>`
54+
${(props) => props.$style && getStyle(props.$style, props.vertical)}
5055
`;
5156

52-
// Falk TODO: height: 300px;
53-
export const SliderWrapper = styled.div`
57+
export const SliderWrapper = styled.div<{ vertical: boolean }>`
5458
width: 100%;
5559
display: inline-flex;
5660
align-items: center;

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,8 @@ export const en = {
16421642
},
16431643
"slider": {
16441644
"step": "Step",
1645-
"stepTooltip": "The Value Must Be Greater Than 0 and Divisible by (Max-Min)"
1645+
"stepTooltip": "The Value Must Be Greater Than 0 and Divisible by (Max-Min)",
1646+
"vertical": "Vertical Orientation",
16461647
},
16471648
"rating": {
16481649
"max": "Max Rating",

0 commit comments

Comments
 (0)