1
- import { BoolCodeControl , NumberControl } from "../../controls/codeControl" ;
2
- import { LabelControl } from "../../controls/labelControl" ;
3
- import { withDefault } from "../../generators" ;
4
- import { ChangeEventHandlerControl } from "../../controls/eventHandlerControl" ;
5
- import { Section , sectionNames } from "lowcoder-design" ;
6
- import { RecordConstructorToComp } from "lowcoder-core" ;
7
- import { styleControl } from "comps/controls/styleControl" ;
8
- import { InputFieldStyle , LabelStyle , SliderStyle , SliderStyleType , heightCalculator , widthCalculator } from "comps/controls/styleControlConstants" ;
9
- import styled , { css } from "styled-components" ;
10
- import { default as Slider } from "antd/es/slider" ;
11
- import { darkenColor , fadeColor } from "lowcoder-design" ;
12
- import { disabledPropertyView , hiddenPropertyView } from "comps/utils/propertyUtils" ;
13
- import { IconControl } from "comps/controls/iconControl" ;
14
- import { trans } from "i18n" ;
1
+ import { BoolCodeControl , NumberControl } from '../../controls/codeControl' ;
2
+ import { LabelControl } from '../../controls/labelControl' ;
3
+ import { withDefault } from '../../generators' ;
4
+ import { ChangeEventHandlerControl } from '../../controls/eventHandlerControl' ;
5
+ import { Section , sectionNames } from 'lowcoder-design' ;
6
+ import { RecordConstructorToComp } from 'lowcoder-core' ;
7
+ import { styleControl } from 'comps/controls/styleControl' ;
8
+ import {
9
+ InputFieldStyle ,
10
+ LabelStyle ,
11
+ SliderStyle ,
12
+ SliderStyleType ,
13
+ heightCalculator ,
14
+ widthCalculator ,
15
+ } from 'comps/controls/styleControlConstants' ;
16
+ import styled , { css } from 'styled-components' ;
17
+ import { default as Slider } from 'antd/es/slider' ;
18
+ import { darkenColor , fadeColor } from 'lowcoder-design' ;
19
+ import {
20
+ disabledPropertyView ,
21
+ hiddenPropertyView ,
22
+ } from 'comps/utils/propertyUtils' ;
23
+ import { IconControl } from 'comps/controls/iconControl' ;
24
+ import { trans } from 'i18n' ;
15
25
16
- import { useContext } from " react" ;
17
- import { EditorContext } from " comps/editorState" ;
26
+ import { useContext } from ' react' ;
27
+ import { EditorContext } from ' comps/editorState' ;
18
28
19
29
const getStyle = ( style : SliderStyleType , vertical : boolean ) => {
30
+ console . log ( '🚀 ~ getStyle ~ style:' , style ) ;
20
31
return css `
21
32
& .ant-slider : not (.ant-slider-disabled ) {
22
33
& ,
@@ -39,66 +50,86 @@ const getStyle = (style: SliderStyleType, vertical: boolean) => {
39
50
}
40
51
}
41
52
.ant-slider-handle : focus {
42
- box-shadow : 0 0 0 5px ${ fadeColor ( darkenColor ( style . thumbBorder , 0.08 ) , 0.12 ) } ;
53
+ box-shadow : 0 0 0 5px
54
+ ${ fadeColor ( darkenColor ( style . thumbBorder , 0.08 ) , 0.12 ) } ;
43
55
}
44
- ${ vertical && css `
45
- width : auto;
56
+ ${ vertical &&
57
+ css `
58
+ width : auto;
46
59
min-height : calc (300px - ${ style . margin } );
47
60
margin : ${ style . margin } auto !important ;
48
61
` }
49
62
}
50
63
` ;
51
64
} ;
52
65
53
- export const SliderStyled = styled ( Slider ) < { $style : SliderStyleType , vertical : boolean } > `
66
+ export const SliderStyled = styled ( Slider ) < {
67
+ $style : SliderStyleType ;
68
+ vertical : boolean ;
69
+ } > `
54
70
${ ( props ) => props . $style && getStyle ( props . $style , props . vertical ) }
55
71
` ;
56
72
57
- export const SliderWrapper = styled . div < { vertical : boolean } > `
73
+ export const SliderWrapper = styled . div < {
74
+ $style : SliderStyleType ;
75
+ vertical : boolean ;
76
+ } > `
58
77
width: 100%;
59
78
display: inline-flex;
60
79
align-items: center;
61
80
justify-content: center;
62
81
.ant-slider {
63
82
width: 100%;
83
+ rotate: ${ ( props ) => props . $style . rotation } ;
64
84
}
65
- `
85
+ ` ;
66
86
67
87
export const SliderChildren = {
68
- max : withDefault ( NumberControl , " 100" ) ,
69
- min : withDefault ( NumberControl , "0" ) ,
70
- step : withDefault ( NumberControl , "1" ) ,
88
+ max : withDefault ( NumberControl , ' 100' ) ,
89
+ min : withDefault ( NumberControl , '0' ) ,
90
+ step : withDefault ( NumberControl , '1' ) ,
71
91
label : LabelControl ,
72
92
disabled : BoolCodeControl ,
73
93
onEvent : ChangeEventHandlerControl ,
74
94
style : styleControl ( InputFieldStyle ) ,
75
- labelStyle :styleControl ( LabelStyle . filter ( ( style ) => [ 'accent' , 'validate' ] . includes ( style . name ) === false ) ) ,
95
+ labelStyle : styleControl (
96
+ LabelStyle . filter (
97
+ ( style ) => [ 'accent' , 'validate' ] . includes ( style . name ) === false
98
+ )
99
+ ) ,
76
100
prefixIcon : IconControl ,
77
101
suffixIcon : IconControl ,
78
- inputFieldStyle :styleControl ( SliderStyle )
102
+ inputFieldStyle : styleControl ( SliderStyle ) ,
79
103
} ;
80
104
81
105
export const SliderPropertyView = (
82
- children : RecordConstructorToComp < typeof SliderChildren & { hidden : typeof BoolCodeControl } >
106
+ children : RecordConstructorToComp <
107
+ typeof SliderChildren & { hidden : typeof BoolCodeControl }
108
+ >
83
109
) => (
84
110
< >
85
-
86
- { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
111
+ { [ 'logic' , 'both' ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
87
112
< Section name = { sectionNames . interaction } >
88
113
{ children . onEvent . getPropertyView ( ) }
89
114
{ disabledPropertyView ( children ) }
90
115
{ hiddenPropertyView ( children ) }
91
116
</ Section >
92
117
) }
93
118
94
- { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
95
- children . label . getPropertyView ( )
96
- ) }
119
+ { [ 'layout' , 'both' ] . includes ( useContext ( EditorContext ) . editorModeStatus ) &&
120
+ children . label . getPropertyView ( ) }
97
121
98
- { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
99
- < > < Section name = { sectionNames . layout } >
100
- { children . prefixIcon . propertyView ( { label : trans ( "button.prefixIcon" ) } ) }
101
- { children . suffixIcon . propertyView ( { label : trans ( "button.suffixIcon" ) } ) }
122
+ { [ 'layout' , 'both' ] . includes (
123
+ useContext ( EditorContext ) . editorModeStatus
124
+ ) && (
125
+ < >
126
+ < Section name = { sectionNames . layout } >
127
+ { children . prefixIcon . propertyView ( {
128
+ label : trans ( 'button.prefixIcon' ) ,
129
+ } ) }
130
+ { children . suffixIcon . propertyView ( {
131
+ label : trans ( 'button.suffixIcon' ) ,
132
+ } ) }
102
133
</ Section >
103
134
< Section name = { sectionNames . style } >
104
135
{ children . style . getPropertyView ( ) }
0 commit comments